%s

', sprintf( // translators: the minimum version of the PHP required by the plugin. \__( '"%1$s" requires PHP %2$s or newer. Plugin is automatically deactivated.', '0-day-analytics' ), ADVAN_NAME, ADVAN_MIN_PHP_VERSION ) ) ); } ); // Return early to prevent loading the plugin. return; } require_once ADVAN_PLUGIN_ROOT . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; // Query monitor grabs handler and cancel the process of error capturing, disable it. if ( ! defined( 'QM_DISABLE_ERROR_HANDLER' ) ) { define( 'QM_DISABLE_ERROR_HANDLER', true ); } \register_shutdown_function( array( WP_Error_Handler::class, 'shutdown' ) ); \add_action( 'doing_it_wrong_trigger_error', array( WP_Error_Handler::class, 'trigger_error' ), 0, 4 ); \add_action( 'doing_it_wrong_run', array( Advanced_Analytics::class, 'action_doing_it_wrong_run' ), 0, 3 ); \add_action( 'doing_it_wrong_run', array( Advanced_Analytics::class, 'action_doing_it_wrong_run' ), 20, 3 ); \add_action( 'doing_it_wrong_run', array( WP_Error_Handler::class, 'action_doing_it_wrong_run' ), 99, 3 ); if ( ! Settings::get_option( 'plugin_exception_handler_disable' ) ) { \set_exception_handler( array( WP_Error_Handler::class, 'exception_handler' ) ); } // All deprecated error following their own idea of what to pass and how to pass it. That list covers the most common ones. \add_action( 'deprecated_function_run', array( WP_Error_Handler::class, 'deprecated_error' ), 0, 3 ); \add_action( 'deprecated_constructor', array( WP_Error_Handler::class, 'deprecated_error' ), 0, 3 ); \add_action( 'deprecated_class_run', array( WP_Error_Handler::class, 'deprecated_error' ), 0, 3 ); \add_action( 'deprecated_file_included', array( WP_Error_Handler::class, 'deprecated_error' ), 0, 4 ); \add_action( 'deprecated_hook_run', array( WP_Error_Handler::class, 'deprecated_error' ), 0, 3 ); \add_action( 'deprecated_argument_run', array( WP_Error_Handler::class, 'deprecated_error' ), 0, 3 ); \add_action( 'http_api_debug', array( WP_Error_Handler::class, 'capture_request' ), 0, 5 ); Scanner::init(); // Need to add deprecated_argument_run as it is bit different than the others. if ( ! Settings::get_option( 'no_wp_die_monitor' ) ) { \add_filter( 'wp_die_ajax_handler', array( WP_Error_Handler::class, 'wp_die_handler' ), PHP_INT_MAX ); \add_filter( 'wp_die_json_handler', array( WP_Error_Handler::class, 'wp_die_handler' ), PHP_INT_MAX ); \add_filter( 'wp_die_jsonp_handler', array( WP_Error_Handler::class, 'wp_die_handler' ), PHP_INT_MAX ); \add_filter( 'wp_die_xmlrpc_handler', array( WP_Error_Handler::class, 'wp_die_handler' ), PHP_INT_MAX ); \add_filter( 'wp_die_xml_handler', array( WP_Error_Handler::class, 'wp_die_handler' ), PHP_INT_MAX ); \add_filter( 'wp_die_handler', array( WP_Error_Handler::class, 'wp_die_handler' ), PHP_INT_MAX ); } \register_activation_hook( ADVAN_PLUGIN_ABSOLUTE, array( Advanced_Analytics::class, 'plugin_activate' ) ); \add_action( 'plugins_loaded', array( Advanced_Analytics::class, 'init' ) ); if ( Settings::get_option( 'rest_api_module_enabled' ) ) { Rest_Api_Helper::init(); } if ( ! Settings::get_option( 'no_rest_api_monitor' ) ) { \add_filter( 'rest_post_dispatch', array( WP_Error_Handler::class, 'log_rest_api_errors' ), 10, 3 ); } \add_action( 'wp_mail_failed', array( WP_Error_Handler::class, 'on_mail_error' ), -1 ); // \add_action( 'plugin_loaded', 'advana_remove_plugins' ); // \add_action( 'network_plugin_loaded', 'advana_remove_plugins' ); if ( ! WP_Helper::is_multisite() && \wp_is_recovery_mode() ) { \add_action( 'plugin_loaded', function() { $paused_plugins = \wp_paused_plugins()->get_all(); if ( empty( $paused_plugins ) ) { $storage = new \WP_Paused_Extensions_Storage( 'plugin' ); foreach ( \wp_get_active_and_valid_plugins() as $plugin ) { $plugin_base = \plugin_basename( $plugin ); list( $plugin_file ) = explode( '/', $plugin_base ); if ( ADVAN_PLUGIN_BASENAME !== $plugin_base ) { $storage->set( $plugin_file, array( 'type' => __( 'Check 0 Day Analytics plugin, find fatal errors and fix them.', '0-day-analytics' ), 'line' => 0, 'file' => 0, 'message' => '', ) ); } } global $wp_theme_directories; $paused_themes = \wp_paused_themes()->get_all(); if ( ! empty( $wp_theme_directories ) && empty( $paused_themes ) ) { $storage = new \WP_Paused_Extensions_Storage( 'theme' ); $storage->set( \get_stylesheet(), array( 'type' => __( 'Check 0 Day Analytics plugin, find fatal errors and fix them.', '0-day-analytics' ), 'line' => 0, 'file' => 0, 'message' => '', ) ); } $redirect_to = 'wp-login.php?action=entered_recovery_mode'; if ( isset( $_SERVER['REQUEST_URI'] ) ) { // Sanitize and validate redirect target to the same host only. $redirect_to = \wp_validate_redirect( \esc_url_raw( \wp_unslash( $_SERVER['REQUEST_URI'] ) ), $redirect_to ); } if ( ! function_exists( 'wp_safe_redirect' ) ) { require_once ABSPATH . WPINC . '/pluggable.php'; } \wp_safe_redirect( $redirect_to ); exit; } } ); } \add_filter( 'det_display_environment_type', '__return_false' ); Requests_Log::init(); WP_Mail_Log::init(); URL_Tracker::init(); Endpoints::init(); Mail_SMTP_Settings::init(); Snippets_Controller::init(); Hooks_Capture::init(); // Security: Rate limiting runs early to block malicious requests ASAP. Rate_Limiter::init(); /* Security start */ if ( Settings::get_option( 'security_module_enabled' ) ) { Privilege_Guard::init(); Incident_Detector::init(); } /* Security end */ /* Login Audit start */ if ( Settings::get_option( 'login_auditor_module_enabled' ) ) { Login_Auth_Auditor::init(); } /* Login Audit end */ // Load WP-CLI commands if available. // if ( defined( 'WP_CLI' ) && WP_CLI ) { // require_once ADVAN_PLUGIN_ROOT . 'cli-commands.php'; // } if ( ! function_exists( 'advana_remove_plugins' ) ) { /** * Deactivating plugins which interfere with proper working. * * @param string $plugin - Currently activated plugin. * * @return void * * @since 1.9.8.1 */ function advana_remove_plugins( $plugin ) { /* * Note: Historically, certain logging plugins interfered with WordPress core error handling and stability. * This hook exists to provide a place to proactively deactivate known-problematic plugins if needed in the future. * Intentionally left blank. */ // if ( false !== strpos( $plugin, 'log-iq' . DIRECTORY_SEPARATOR ) ) { // \deactivate_plugins( $plugin, true, null ); // } //period. } } // Polyfill for str_starts_with (PHP < 8.0). if ( ! function_exists( 'str_starts_with' ) ) { /** * PHP lower than 8 is missing that function but it required in the newer versions of our plugin. * * @param string $haystack - The string to search in. * @param string $needle - The needle to search for. * * @return bool * * @since 1.1.1 */ function str_starts_with( $haystack, $needle ): bool { if ( '' === $needle ) { return true; } return 0 === strpos( $haystack, $needle ); } } // Offer our own error logging if there is no way to enable WP_DEBUG and nothing else works. if ( Settings::get_option( 'plugin_debug_enable' ) ) { if ( function_exists( 'error_reporting' ) ) { error_reporting( E_ALL ); } ini_set( 'display_errors', '0' ); // phpcs:ignore WordPress.PHP.IniSet.display_errors_Disallowed $log_path = WP_CONTENT_DIR . '/debug.log'; if ( is_string( $log_path ) && '' !== $log_path ) { ini_set( 'log_errors', '1' ); // phpcs:ignore WordPress.PHP.IniSet.log_errors_Disallowed ini_set( 'error_log', $log_path ); // phpcs:ignore WordPress.PHP.IniSet.Risky } }