Changeset 3473914 for kagg-pagespeed-module/trunk/src/php/Main.php
- Timestamp:
- 03/03/2026 06:25:09 PM (4 weeks ago)
- File:
-
- 1 edited
-
kagg-pagespeed-module/trunk/src/php/Main.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kagg-pagespeed-module/trunk/src/php/Main.php
r3048396 r3473914 18 18 * @var array 19 19 */ 20 private $options;20 private array $options; 21 21 22 22 /** 23 23 * Admin screen id. 24 24 */ 25 const SCREEN_ID = 'settings_page_mod-pagespeed';25 private const SCREEN_ID = 'settings_page_mod-pagespeed'; 26 26 27 27 /** 28 28 * Option page. 29 29 */ 30 const PAGE = 'mod-pagespeed';30 private const PAGE = 'mod-pagespeed'; 31 31 32 32 /** 33 33 * Ajax action name. 34 34 */ 35 const ACTION = 'mod-pagespeed-action';35 private const ACTION = 'mod-pagespeed-action'; 36 36 37 37 /** 38 38 * Admin script handle. 39 39 */ 40 const HANDLE = 'mod-pagespeed-admin';40 private const HANDLE = 'mod-pagespeed-admin'; 41 41 42 42 /** 43 43 * Init class. 44 44 */ 45 public function init() {46 $this->options = get_option( 'mod_pagespeed_settings', [] );45 public function init(): void { 46 $this->options = (array) get_option( 'mod_pagespeed_settings', [] ); 47 47 48 48 $this->hooks(); … … 54 54 * @return void 55 55 */ 56 private function hooks() {56 private function hooks(): void { 57 57 add_action( 'admin_menu', [ $this, 'add_settings_page' ] ); 58 58 add_filter( … … 72 72 * Add the settings page to the menu. 73 73 */ 74 public function add_settings_page() {74 public function add_settings_page(): void { 75 75 $page_title = __( 'PageSpeed', 'kagg-pagespeed-module' ); 76 76 $menu_title = __( 'PageSpeed', 'kagg-pagespeed-module' ); … … 88 88 * Options page. 89 89 */ 90 public function mod_pagespeed_settings_page() {90 public function mod_pagespeed_settings_page(): void { 91 91 ?> 92 92 <div class="wrap"> … … 111 111 * Setup options fields. 112 112 */ 113 public function setup_fields() {113 public function setup_fields(): void { 114 114 add_settings_section( 115 115 'purge_section', … … 129 129 * Purge Cache section. 130 130 */ 131 public function mod_pagespeed_purge_section() {131 public function mod_pagespeed_purge_section(): void { 132 132 $title = __( 'Purge Styles', 'kagg-pagespeed-module' ); 133 $text = __( 'Clear cached version of the current WordPress theme style.css file.<br><br>This is useful when styles were changed.', 'kagg-pagespeed-module' );133 $text = __( 'Clear cached version of the current WordPress theme style.css file.<br><br>This is useful when styles are changed.', 'kagg-pagespeed-module' ); 134 134 $button_text = __( 'Purge Styles', 'kagg-pagespeed-module' ); 135 135 136 $this->card_section( $title, $text, $button_text, 'purge_styles' ); 136 137 137 138 $title = __( 'Purge Entire Cache', 'kagg-pagespeed-module' ); 138 $text = __( 'Clear the entire PageSpeed cache on site. This action fetches fresh versions of all pages, images, and scripts on your website.<br><br>Please note that PageSpeed module will take some time to re-create cache after several page visits.', 'kagg-pagespeed-module' );139 $text = __( 'Clear the entire PageSpeed cache on site. This action fetches fresh versions of all pages, images, and scripts on your website.<br><br>Please note that the PageSpeed module will take some time to re-create the cache after several page visits.', 'kagg-pagespeed-module' ); 139 140 $button_text = __( 'Purge Entire Cache', 'kagg-pagespeed-module' ); 141 140 142 $this->card_section( $title, $text, $button_text, 'purge_entire_cache' ); 141 143 } … … 149 151 * @param string $button_id Button id. 150 152 */ 151 private function card_section( $title, $text, $button_text, $button_id ){153 private function card_section( string $title, string $text, string $button_text, string $button_id ): void { 152 154 ?> 153 155 <section class="ps-card"> … … 170 172 * Development Mode section. 171 173 */ 172 public function mod_pagespeed_development_section() {174 public function mod_pagespeed_development_section(): void { 173 175 $title = __( 'Development Mode', 'kagg-pagespeed-module' ); 174 176 $text = … … 201 203 </section> 202 204 <?php 205 203 206 echo '<div id="ps-success"></div>'; 204 207 echo '<div id="ps-error"></div>'; … … 208 211 * Load plugin text domain. 209 212 */ 210 public function load_textdomain() {213 public function load_textdomain(): void { 211 214 load_plugin_textdomain( 212 215 'kagg-pagespeed-module', … … 219 222 * Enqueue plugin scripts. 220 223 */ 221 public function admin_enqueue_scripts() {224 public function admin_enqueue_scripts(): void { 222 225 if ( ! is_admin() ) { 223 226 return; … … 267 270 * Process ajax request. 268 271 */ 269 public function ajax_action() {272 public function ajax_action(): void { 270 273 if ( 271 274 ! wp_verify_nonce( … … 308 311 * Purge cache for $link. 309 312 * 310 * @param string $link a link to file or * to be purged.311 */ 312 private function purge_link( $link ){313 * @param string $link a link to the file or * to be purged. 314 */ 315 private function purge_link( string $link ): void { 313 316 $result = wp_remote_request( site_url() ); 314 317 … … 373 376 * For any site url, add or remove ?ModPagespeed argument. 374 377 */ 375 public function mod_pagespeed_arg() {378 public function mod_pagespeed_arg(): void { 376 379 if ( wp_doing_ajax() || is_admin() || $this->is_rest() ) { 377 380 return; … … 417 420 418 421 /** 419 * Add link to plugin setting page onplugins page.422 * Add a link to the plugin setting page on the plugins page. 420 423 * 421 424 * @param array|mixed $links Plugin links.
Note: See TracChangeset
for help on using the changeset viewer.