ction( 'jetpack_boost_loaded', $this ); My_Jetpack_Initializer::init(); Deactivation_Handler::init( $this->plugin_name, __DIR__ . '/admin/deactivation-dialog.php' ); // Register the core Image CDN hooks. Image_CDN_Core::setup(); // Setup Site Health panel functionality. Site_Health::init(); Super_Cache_Tracking::setup(); } /** * Register deactivation hook. */ private function register_deactivation_hook() { $plugin_file = trailingslashit( dirname( __DIR__ ) ) . 'jetpack-boost.php'; register_deactivation_hook( $plugin_file, array( $this, 'deactivate' ) ); } /** * Add query args used by Boost to a list of allowed query args. * * @param array $allowed_query_args The list of allowed query args. * * @return array The modified list of allowed query args. */ public static function whitelist_query_args( $allowed_query_args ) { $allowed_query_args[] = Generator::GENERATE_QUERY_ACTION; $allowed_query_args[] = Modules_Index::DISABLE_MODULE_QUERY_VAR; return $allowed_query_args; } /** * Plugin activation handler. */ public static function activate() { // Make sure user sees the "Get Started" when first time opening. ( new Getting_Started_Entry() )->set( true ); Analytics::record_user_event( 'activate_plugin' ); $page_cache_status = new Status( Page_Cache::get_slug() ); if ( $page_cache_status->get() && Boost_Cache_Settings::get_instance()->get_enabled() ) { Page_Cache_Setup::run_setup(); } } /** * Plugin deactivation handler. Clear cache, and reset admin notices. */ public function deactivate() { do_action( 'jetpack_boost_deactivate' ); // Tell Minify JS/CSS to clean up. require_once JETPACK_BOOST_DIR_PATH . '/app/lib/minify/functions-helpers.php'; jetpack_boost_page_optimize_deactivate(); Regenerate_Admin_Notice::dismiss(); Analytics::record_user_event( 'deactivate_plugin' ); Page_Cache_Setup::deactivate(); } /** * Initialize the admin experience. */ public function init_admin( $modules_setup ) { REST_API::register( List_Site_Urls::class ); REST_API::register( List_Source_Providers::class ); REST_API::register( List_Cornerstone_Pages::class ); $this->connection->ensure_connection(); ( new Admin() )->init( $modules_setup ); } public function init_sync() { $jetpack_config = new Jetpack_Config(); $jetpack_config->ensure( 'sync', array( 'jetpack_sync_callable_whitelist' => array( 'boost_modules' => array( new Modules_Setup(), 'get_status' ), 'boost_sub_modules_state' => array( new Modules_Setup(), 'get_all_sub_modules_state' ), 'boost_latest_scores' => array( new Speed_Score_History( get_home_url() ), 'latest' ), 'boost_latest_no_boost_scores' => array( new Speed_Score_History( add_query_arg( Modules_Index::DISABLE_MODULE_QUERY_VAR, 'all', get_home_url() ) ), 'latest' ), 'critical_css_state' => array( new Critical_CSS_State(), 'get' ), ), ) ); } /** * Loads the textdomain. */ public function init_textdomain() { load_plugin_textdomain( 'jetpack-boost', false, JETPACK_BOOST_DIR_PATH . '/languages/' ); } /** * The name of the plugin used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @return string The name of the plugin. * @since 1.0.0 */ public function get_plugin_name() { return $this->plugin_name; } /** * Retrieve the version number of the plugin. * * @return string The version number of the plugin. * @since 1.0.0 */ public function get_version() { return $this->version; } /** * Handle an environment change to set the correct status to the Critical CSS request. * This is done here so even if the Critical CSS module is switched off we can * still capture the change of environment event and flag Critical CSS for a rebuild. */ public function handle_environment_change( $is_major_change, $change_type ) { if ( $is_major_change ) { Regenerate_Admin_Notice::enable(); } jetpack_boost_ds_set( 'critical_css_suggest_regenerate', $change_type ); } /** * Plugin uninstallation handler. Delete all settings and cache. */ public function uninstall() { global $wpdb; // When uninstalling, make sure all deactivation cleanups have run as well. $this->deactivate(); // Delete all Jetpack Boost options. //phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $option_names = $wpdb->get_col( " SELECT `option_name` FROM `$wpdb->options` WHERE `option_name` LIKE 'jetpack_boost_%'; " ); //phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching foreach ( $option_names as $option_name ) { delete_option( $option_name ); } // Delete stored Critical CSS. ( new Critical_CSS_Storage() )->clear(); // Delete all transients created by boost. Transient::delete_by_prefix( '' ); // Clear getting started value ( new Getting_Started_Entry() )->set( false ); Page_Cache_Setup::uninstall(); } }