render = $render; $this->options_api = $options_api; $this->options = $options; } /** * Return an array of events that this subscriber wants to listen to. * * @since 3.0 * * @return array */ public static function get_subscribed_events() { return [ 'admin_print_footer_scripts-plugins.php' => 'insert_mixpanel_tracking', 'admin_footer' => 'insert_deactivation_intent_form', 'wp_ajax_rocket_safe_mode' => 'activate_safe_mode', ]; } /** * Inserts mixpanel tracking on plugins page to send deactivation data * * @since 3.0 * * @return void */ public function insert_mixpanel_tracking() { ?> id && 'plugins-network' !== $current_screen->id ) { return; } $this->render->render_form(); } /** * Activates WP Rocket safe mode by deactivating possibly layout breaking options * * @since 3.0 * * @return void */ public function activate_safe_mode() { check_ajax_referer( 'rocket-ajax', 'nonce' ); if ( ! current_user_can( 'rocket_manage_options' ) ) { wp_send_json_error(); return; } /** * Filters the array of options to reset when activating safe mode * * @since 3.7 * * @param array $options Array of options to reset. */ $reset_options = apply_filters( 'rocket_safe_mode_reset_options', [ 'embeds' => 0, 'defer_all_js' => 0, 'async_css' => 0, 'lazyload' => 0, 'lazyload_iframes' => 0, 'lazyload_youtube' => 0, 'minify_css' => 0, 'minify_concatenate_css' => 0, 'minify_js' => 0, 'minify_concatenate_js' => 0, 'minify_google_fonts' => 0, 'cdn' => 0, ] ); $this->options->set_values( $reset_options ); $this->options_api->set( 'settings', $this->options->get_options() ); wp_send_json_success(); } }