| Server IP : 192.241.186.36 / Your IP : 216.73.216.199 Web Server : Apache/2.4.29 (Ubuntu) System : Linux webserver7 4.15.0-194-generic #205-Ubuntu SMP Fri Sep 16 19:49:27 UTC 2022 x86_64 User : root ( 0) PHP Version : 7.4.32 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/proxygeeko/wp-content/plugins/wp-optimize/includes/ |
Upload File : |
<?php
if (!defined('ABSPATH')) die('Access denied.');
if (!class_exists('WP_Optimize_Bypass')) :
/**
* WP_Optimize_Bypass class
*
* Handles bypass functionality to disable WP-Optimize optimizations
* when the config constant WPO_DISABLE_MODE_URL_PARAM is present
*
* @since 4.4.0
*/
class WP_Optimize_Bypass {
/**
* Singleton instance
*
* @var WP_Optimize_Bypass|null
*/
private static $instance = null;
/**
* Get a singleton instance
*
* @return WP_Optimize_Bypass
*/
public static function instance() {
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Check if we should bypass WP-Optimize optimizations
*
* @return bool True to indicate should bypass; false otherwise.
*/
public function should_bypass() {
$bypass = false;
if (is_admin()) {
return false;
}
// Check $_GET directly
if ($this->is_bypass_mode_enabled()) {
$bypass = true;
}
return $bypass;
}
/**
* Check if WP-Optimize bypass mode is enabled via secret URL parameter.
*
* @return bool
*/
private function is_bypass_mode_enabled() {
// Feature is OFF unless explicitly enabled
if (!defined('WPO_DISABLE_MODE_URL_PARAM') || empty(WPO_DISABLE_MODE_URL_PARAM)) {
return false;
}
$param = WPO_DISABLE_MODE_URL_PARAM;
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only flag, executes early
return isset($_GET[$param]);
}
/**
* Show bypass admin notice
* Called early in the request
*/
public function show_admin_notice() {
// Hook into early actions to set a bypass flag
add_action('plugins_loaded', array($this, 'maybe_add_admin_notice'), 5);
}
/**
* Add admin bar notice when bypass is active
*/
public function maybe_add_admin_notice() {
if (current_user_can('manage_options')) {
add_action('admin_bar_menu', array($this, 'add_bypass_notice_to_admin_bar'), 999);
}
}
/**
* Add bypass notice to admin bar
*
* @param WP_Admin_Bar $wp_admin_bar
*/
public function add_bypass_notice_to_admin_bar($wp_admin_bar) {
$wp_admin_bar->add_node(array(
'id' => 'wpo-bypass-notice',
'title' => '<span style="color: #ff6600;">⚠ ' . esc_html__('WP-Optimize bypassed', 'wp-optimize') . '</span>',
'href' => false,
'meta' => array(
'title' => __('WP-Optimize optimizations are currently bypassed via a custom URL parameter defined by WPO_DISABLE_MODE_URL_PARAM', 'wp-optimize'),
),
));
}
}
endif;