Plugin Directory


Ignore:
Timestamp:
03/03/2026 06:25:09 PM (4 weeks ago)
Author:
kaggdesign
Message:

Update to version 2.2.0 from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kagg-pagespeed-module/trunk/src/php/Main.php

    r3048396 r3473914  
    1818     * @var array
    1919     */
    20     private $options;
     20    private array $options;
    2121
    2222    /**
    2323     * Admin screen id.
    2424     */
    25     const SCREEN_ID = 'settings_page_mod-pagespeed';
     25    private const SCREEN_ID = 'settings_page_mod-pagespeed';
    2626
    2727    /**
    2828     * Option page.
    2929     */
    30     const PAGE = 'mod-pagespeed';
     30    private const PAGE = 'mod-pagespeed';
    3131
    3232    /**
    3333     * Ajax action name.
    3434     */
    35     const ACTION = 'mod-pagespeed-action';
     35    private const ACTION = 'mod-pagespeed-action';
    3636
    3737    /**
    3838     * Admin script handle.
    3939     */
    40     const HANDLE = 'mod-pagespeed-admin';
     40    private const HANDLE = 'mod-pagespeed-admin';
    4141
    4242    /**
    4343     * Init class.
    4444     */
    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', [] );
    4747
    4848        $this->hooks();
     
    5454     * @return void
    5555     */
    56     private function hooks() {
     56    private function hooks(): void {
    5757        add_action( 'admin_menu', [ $this, 'add_settings_page' ] );
    5858        add_filter(
     
    7272     * Add the settings page to the menu.
    7373     */
    74     public function add_settings_page() {
     74    public function add_settings_page(): void {
    7575        $page_title = __( 'PageSpeed', 'kagg-pagespeed-module' );
    7676        $menu_title = __( 'PageSpeed', 'kagg-pagespeed-module' );
     
    8888     * Options page.
    8989     */
    90     public function mod_pagespeed_settings_page() {
     90    public function mod_pagespeed_settings_page(): void {
    9191        ?>
    9292        <div class="wrap">
     
    111111     * Setup options fields.
    112112     */
    113     public function setup_fields() {
     113    public function setup_fields(): void {
    114114        add_settings_section(
    115115            'purge_section',
     
    129129     * Purge Cache section.
    130130     */
    131     public function mod_pagespeed_purge_section() {
     131    public function mod_pagespeed_purge_section(): void {
    132132        $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' );
    134134        $button_text = __( 'Purge Styles', 'kagg-pagespeed-module' );
     135
    135136        $this->card_section( $title, $text, $button_text, 'purge_styles' );
    136137
    137138        $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' );
    139140        $button_text = __( 'Purge Entire Cache', 'kagg-pagespeed-module' );
     141
    140142        $this->card_section( $title, $text, $button_text, 'purge_entire_cache' );
    141143    }
     
    149151     * @param string $button_id   Button id.
    150152     */
    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 {
    152154        ?>
    153155        <section class="ps-card">
     
    170172     * Development Mode section.
    171173     */
    172     public function mod_pagespeed_development_section() {
     174    public function mod_pagespeed_development_section(): void {
    173175        $title    = __( 'Development Mode', 'kagg-pagespeed-module' );
    174176        $text     =
     
    201203        </section>
    202204        <?php
     205
    203206        echo '<div id="ps-success"></div>';
    204207        echo '<div id="ps-error"></div>';
     
    208211     * Load plugin text domain.
    209212     */
    210     public function load_textdomain() {
     213    public function load_textdomain(): void {
    211214        load_plugin_textdomain(
    212215            'kagg-pagespeed-module',
     
    219222     * Enqueue plugin scripts.
    220223     */
    221     public function admin_enqueue_scripts() {
     224    public function admin_enqueue_scripts(): void {
    222225        if ( ! is_admin() ) {
    223226            return;
     
    267270     * Process ajax request.
    268271     */
    269     public function ajax_action() {
     272    public function ajax_action(): void {
    270273        if (
    271274        ! wp_verify_nonce(
     
    308311     * Purge cache for $link.
    309312     *
    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 {
    313316        $result = wp_remote_request( site_url() );
    314317
     
    373376     * For any site url, add or remove ?ModPagespeed argument.
    374377     */
    375     public function mod_pagespeed_arg() {
     378    public function mod_pagespeed_arg(): void {
    376379        if ( wp_doing_ajax() || is_admin() || $this->is_rest() ) {
    377380            return;
     
    417420
    418421    /**
    419      * Add link to plugin setting page on plugins page.
     422     * Add a link to the plugin setting page on the plugins page.
    420423     *
    421424     * @param array|mixed $links Plugin links.
Note: See TracChangeset for help on using the changeset viewer.