'wprocket', 'title' => 'WP Rocket', 'capability' => 'rocket_manage_options', ], $args ); $this->slug = $args['slug']; $this->title = $args['title']; $this->capability = $args['capability']; $this->settings = $settings; $this->render = $render; $this->beacon = $beacon; $this->optimize = $optimize; $this->user_client = $user_client; } /** * Returns the settings page title. * * @since 3.3 * * @return string */ public function get_title() { return $this->title; } /** * Returns the settings page slug. * * @since 3.3 * * @return string */ public function get_slug() { return $this->slug; } /** * Returns the settings page capability. * * @since 3.3 * * @return string */ public function get_capability() { return $this->capability; } /** * Registers the settings, page sections, fields sections and fields. * * @since 3.0 */ public function configure() { register_setting( $this->slug, WP_ROCKET_SLUG, [ $this->settings, 'sanitize_callback' ] ); } /** * Renders the settings page. * * @since 3.0 */ public function render_page() { $rocket_valid_key = rocket_valid_key(); if ( $rocket_valid_key ) { $this->dashboard_section(); $this->cache_section(); $this->assets_section(); $this->media_section(); $this->preload_section(); $this->advanced_cache_section(); $this->database_section(); $this->cdn_section(); $this->heartbeat_section(); $this->addons_section(); $this->cloudflare_section(); $this->sucuri_section(); } else { $this->license_section(); } $this->render->set_settings( $this->settings->get_settings() ); $this->hidden_fields(); $this->render->set_hidden_settings( $this->settings->get_hidden_settings() ); $btn_submit_text = $rocket_valid_key ? __( 'Save Changes', 'rocket' ) : __( 'Validate License', 'rocket' ); echo $this->render->generate( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Dynamic content is properly escaped in the view. 'page', [ 'slug' => $this->slug, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Dynamic content is properly escaped in the view. 'btn_submit_text' => $btn_submit_text, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Dynamic content is properly escaped in the view. ] ); } /** * Enqueues WP Rocket scripts on the settings page * * @since 3.6.1 * * @param string $hook The current admin page. * * @return void */ public function enqueue_rocket_scripts( $hook ) { if ( 'settings_page_wprocket' !== $hook ) { return; } wp_enqueue_script( 'wistia-e-v1', 'https://fast.wistia.com/assets/external/E-v1.js', [], null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion } /** * Adds the async attribute to the Wistia script * * @since 3.6.1 * * @param string $tag The