Plugin Directory

Changeset 3439148


Ignore:
Timestamp:
01/14/2026 04:59:20 AM (5 weeks ago)
Author:
sethta
Message:

Update to version 1.4.6

Location:
easy-critical-css
Files:
326 added
18 edited

Legend:

Unmodified
Added
Removed
  • easy-critical-css/trunk/composer.json

    r3395875 r3439148  
    2020  "autoload": {
    2121    "classmap": [
    22       "inc/"
     22      "inc/",
     23      "inc/compatibility/"
    2324    ]
    2425  },
  • easy-critical-css/trunk/easy-critical-css.php

    r3429798 r3439148  
    22/**
    33 * Plugin Name:       Easy Critical CSS
    4  * Description:       Easily inject Critical CSS and Secondary CSS (with unused styles removed) to improve site speed and performance.
    5  * Version:           1.4.5
     4 * Description:       Easily inject Critical CSS and Secondary CSS (with unused CSS styles removed) to improve site speed and performance.
     5 * Version:           1.4.6
    66 * Requires at least: 6.2
    77 * Tested up to:      6.8
  • easy-critical-css/trunk/inc/class-admin-settings.php

    r3402049 r3439148  
    222222                $status = Helpers::get_auto_mode_status();
    223223                $all_ok = $status['all_ok'];
    224                
     224
    225225                $status_color = $all_ok ? '#1e7e34' : '#b12331';
    226226                $status_icon  = $all_ok ? '✓' : '✗';
     
    327327        $getting_started_link = sprintf(
    328328            '<p style="margin:1.5em 0;"><a href="%s" target="_blank" rel="noopener noreferrer">%s</a></p>',
    329             'https://criticalcss.net/docs/',
     329            'https://criticalcss.net/docs/?utm_source=easy-critical-css-plugin&utm_medium=admin-documentation&utm_campaign=v' . Plugin::get_plugin_version(),
    330330            esc_html__( 'Need help getting started? View the Easy Critical CSS guides.', 'easy-critical-css' )
    331331        );
     
    334334            // translators: %s is a link to the API site.
    335335            __( 'Auto mode sends page data to an external API at %s and requires an API key.', 'easy-critical-css' ),
    336             '<a href="https://criticalcss.net/" target="_blank" rel="noopener noreferrer">CriticalCSS.net</a>'
     336            '<a href="https://criticalcss.net/?utm_source=easy-critical-css-plugin&utm_medium=admin-main&utm_campaign=v' . Plugin::get_plugin_version() . '" target="_blank" rel="noopener noreferrer">CriticalCSS.net</a>'
    337337        );
    338338
     
    353353                esc_html__( 'Add your API key', 'easy-critical-css' )
    354354            );
    355            
    356355
    357356            // Free/manual path.
    358357            $critical_css_mode_warn .= sprintf(
    359                 '<p>%1$s <a href="https://criticalcss.net/#free-generator" target="_blank" rel="noopener noreferrer">%2$s</a> %3$s</p>',
     358                '<p>%1$s <a href="https://criticalcss.net/#free-generator?utm_source=easy-critical-css-plugin&utm_medium=free-generator&utm_campaign=v' . Plugin::get_plugin_version() . '" target="_blank" rel="noopener noreferrer">%2$s</a> %3$s</p>',
    360359                esc_html__( 'Staying in free Manual mode? You can generate CSS manually at', 'easy-critical-css' ),
    361360                'CriticalCSS.net',
     
    368367
    369368    public static function get_exclude_css_strings() {
    370         $label_auto = __( 'Exclude CSS Files from Critical CSS', 'easy-critical-css' );
     369        $label_auto   = __( 'Exclude CSS Files from Critical CSS', 'easy-critical-css' );
    371370        $label_manual = __( 'Always Loaded CSS Files', 'easy-critical-css' );
    372371
    373         $desc_auto = __( 'Enter the CSS file URLs or partial matches that should be excluded from Critical CSS generation.', 'easy-critical-css' );
     372        $desc_auto   = __( 'Enter the CSS file URLs or partial matches that should be excluded from Critical CSS generation.', 'easy-critical-css' );
    374373        $desc_manual = __( 'Enter the CSS file URLs or partial matches that should always be loaded (not inlined) when using Manual mode.', 'easy-critical-css' );
    375374
     
    382381
    383382        return [
    384             'label_auto' => $label_auto,
     383            'label_auto'   => $label_auto,
    385384            'label_manual' => $label_manual,
    386             'desc_auto' => $desc_auto . $common,
    387             'desc_manual' => $desc_manual . $common,
     385            'desc_auto'    => $desc_auto . $common,
     386            'desc_manual'  => $desc_manual . $common,
    388387        ];
    389388    }
     
    422421            ],
    423422            'auto_mode_status'           => [
    424                 'label'         => '',
    425                 'type'          => 'status-indicator',
    426                 'value_type'    => 'string',
    427                 'desc'          => '',
    428                 'basic'         => true,
    429                 'hidden'        => true, // Don't register as a real setting
     423                'label'      => '',
     424                'type'       => 'status-indicator',
     425                'value_type' => 'string',
     426                'desc'       => '',
     427                'basic'      => true,
     428                'hidden'     => true, // Don't register as a real setting
    430429            ],
    431430            'secondary_css_behavior'     => [
     
    484483                'value_type'    => 'boolean',
    485484                'options'       => [
    486                     'label' => __( 'Ignore stylesheets from external domains when generating Critical CSS.', 'easy-critical-css' ),
     485                    'label' => __( 'Ignore stylesheets loaded from external domains when generating Critical CSS.', 'easy-critical-css' ),
    487486                ],
    488                 'desc'          => __( 'By default, external stylesheets (hosted on other domains) are ignored when generating Critical CSS. This avoids potential issues with dynamically loaded styles. Uncheck this box if you want to allow stylesheets from external domains (e.g., CDN-hosted styles) to be included in Critical CSS generation.', 'easy-critical-css' ),
     487                'desc'          => __( 'By default, external stylesheets (hosted on other domains) are ignored during Critical CSS generation. This prevents third-party and CDN-hosted styles from being inlined into Critical CSS. Uncheck this option only if you explicitly need stylesheets from external domains to be included during generation.', 'easy-critical-css' ),
    489488                'default_value' => 1,
    490489                'default_label' => __( 'Checked', 'easy-critical-css' ),
    491                 'warning'       => __( 'Warning: Unchecking this may cause issues with ad scripts or dynamically loaded styles.', 'easy-critical-css' ),
     490                'warning'       => __( 'Warning: Unchecking this can break ad layouts, third-party scripts, or styles that load dynamically. Unchecking this setting is strongly discouraged on monetized sites unless you fully understand the impact.', 'easy-critical-css' ),
    492491
    493492            ],
     
    542541                'type'       => 'text',
    543542                'value_type' => 'string',
    544                 'desc'       => __( 'Cloudflare account email for API access. If the CLOUDFLARE_EMAIL constant is defined, this field is disabled and the value is hidden for privacy.', 'easy-critical-css' ) . '<br><strong><a href="https://criticalcss.net/docs/cloudflare-setup/" target="_blank" rel="noopener noreferrer">' . __( 'View Cloudflare Setup Guide', 'easy-critical-css' ) . '</a></strong>',
     543                'desc'       => __( 'Cloudflare account email for API access. If the CLOUDFLARE_EMAIL constant is defined, this field is disabled and the value is hidden for privacy.', 'easy-critical-css' ) . '<br><strong><a href="https://criticalcss.net/docs/cloudflare-setup/?utm_source=easy-critical-css-plugin&utm_medium=admin-setup-guide&utm_campaign=v' . Plugin::get_plugin_version() . '" target="_blank" rel="noopener noreferrer">' . __( 'View Cloudflare Setup Guide', 'easy-critical-css' ) . '</a></strong>',
    545544            ],
    546545            'cloudflare_api_key'         => [
     
    692691        $settings = self::get_settings_schema();
    693692        foreach ( $settings as $key => $setting ) {
    694             $is_basic = isset( $setting['basic'] ) && $setting['basic'];
     693            $is_basic  = isset( $setting['basic'] ) && $setting['basic'];
    695694            $is_hidden = isset( $setting['hidden'] ) && $setting['hidden'];
    696             $section  = $is_basic ? 'easy-critical-css-basic-section' : 'easy-critical-css-advanced-section';
     695            $section   = $is_basic ? 'easy-critical-css-basic-section' : 'easy-critical-css-advanced-section';
    697696
    698697            add_settings_field(
     
    772771            'easyCriticalCss',
    773772            [
    774                 'restUrl' => esc_url_raw( rest_url( 'easy-critical-css/v1/' ) ),
    775                 'nonce'   => wp_create_nonce( 'wp_rest' ),
    776                 'excludeLabelAuto' => $exclude_strings['label_auto'],
     773                'restUrl'            => esc_url_raw( rest_url( 'easy-critical-css/v1/' ) ),
     774                'nonce'              => wp_create_nonce( 'wp_rest' ),
     775                'excludeLabelAuto'   => $exclude_strings['label_auto'],
    777776                'excludeLabelManual' => $exclude_strings['label_manual'],
    778                 'excludeDescAuto' => $exclude_strings['desc_auto'],
    779                 'excludeDescManual' => $exclude_strings['desc_manual'],
     777                'excludeDescAuto'    => $exclude_strings['desc_auto'],
     778                'excludeDescManual'  => $exclude_strings['desc_manual'],
    780779            ]
    781             );
     780        );
    782781
    783782        wp_enqueue_style(
     
    805804
    806805            // Clear cached transients related to site environment checks.
    807             TimedOption::delete_all();
     806            Timed_Option::delete_all();
    808807        }
    809808    }
  • easy-critical-css/trunk/inc/class-api-service.php

    r3429798 r3439148  
    1717    public static function test_receive_endpoint() {
    1818        // Check transient for cached result.
    19         $cached = TimedOption::get( 'is_rest_api_reachable' );
     19        $cached = Timed_Option::get( 'is_rest_api_reachable' );
    2020        if ( $cached !== false ) {
    2121            return (bool) $cached;
     
    2626
    2727        // Store the nonce in a transient for verification (5 minute expiry for the test).
    28         TimedOption::set( 'receive_test_nonce', $nonce, 5 * MINUTE_IN_SECONDS );
     28        Timed_Option::set( 'receive_test_nonce', $nonce, 5 * MINUTE_IN_SECONDS );
    2929
    3030        $api_url = self::get_api_url();
    31         $body = [
     31        $body    = [
    3232            'siteUrl' => esc_url_raw( home_url() ),
    3333            'nonce'   => $nonce,
     
    4444
    4545        if ( is_wp_error( $response ) ) {
    46             TimedOption::set( 'is_rest_api_reachable', '0', 6 * HOUR_IN_SECONDS );
     46            Timed_Option::set( 'is_rest_api_reachable', '0', 6 * HOUR_IN_SECONDS );
    4747
    4848            return false;
     
    5555
    5656        // Cache the result for 6 hours.
    57         TimedOption::set( 'is_rest_api_reachable', $success ? '1' : '0', 6 * HOUR_IN_SECONDS );
     57        Timed_Option::set( 'is_rest_api_reachable', $success ? '1' : '0', 6 * HOUR_IN_SECONDS );
    5858
    5959        return $success;
  • easy-critical-css/trunk/inc/class-database.php

    r3429798 r3439148  
    147147                Debug::ecc_log(
    148148                    [
    149                         'step'    => 'db_pick_by_hash',
    150                         'post_id' => $post_id,
    151                         'pick_id' => $by_hash['id'],
    152                         'url_hash'=> $expected_hash,
    153                         'reason'  => 'matched_permalink_hash'
     149                        'step'     => 'db_pick_by_hash',
     150                        'post_id'  => $post_id,
     151                        'pick_id'  => $by_hash['id'],
     152                        'url_hash' => $expected_hash,
     153                        'reason'   => 'matched_permalink_hash',
    154154                    ]
    155155                );
     
    177177            Debug::ecc_log(
    178178                [
    179                     'step'    => 'db_pick_best_row',
    180                     'post_id' => $post_id,
    181                     'pick_id' => $row['id'],
    182                     'url_hash'=> isset( $row['url_hash'] ) ? $row['url_hash'] : null,
    183                     'status'  => isset( $row['processing_status'] ) ? $row['processing_status'] : null,
     179                    'step'           => 'db_pick_best_row',
     180                    'post_id'        => $post_id,
     181                    'pick_id'        => $row['id'],
     182                    'url_hash'       => isset( $row['url_hash'] ) ? $row['url_hash'] : null,
     183                    'status'         => isset( $row['processing_status'] ) ? $row['processing_status'] : null,
    184184                    'generated_time' => isset( $row['generated_time'] ) ? $row['generated_time'] : null,
    185185                ]
     
    229229        } elseif ( ! empty( $sanitized_data['page_url'] ) ) {
    230230            $where['page_url'] = $sanitized_data['page_url'];
    231             $existing_row = self::get_row_by_url( $sanitized_data['page_url'] );
     231            $existing_row      = self::get_row_by_url( $sanitized_data['page_url'] );
    232232        }
    233233
     
    373373
    374374        if ( empty( $post_id ) ) {
    375             return [ 'action' => 'none', 'reason' => 'missing_post_id' ];
     375            return [
     376                'action' => 'none',
     377                'reason' => 'missing_post_id',
     378            ];
    376379        }
    377380
     
    383386
    384387        if ( ! is_array( $rows ) || count( $rows ) <= 1 ) {
    385             return [ 'action' => 'none', 'reason' => 'no_duplicates', 'rows' => $rows ];
     388            return [
     389                'action' => 'none',
     390                'reason' => 'no_duplicates',
     391                'rows'   => $rows,
     392            ];
    386393        }
    387394
     
    412419        // 3) Fallback: choose best by processing_status, generated_time, id.
    413420        if ( empty( $canonical ) ) {
    414             $best = null;
     421            $best     = null;
    415422            $priority = [ 'completed', 'pending', 'unprocessed', 'failed', 'expired' ];
    416423            foreach ( $rows as $r ) {
     
    453460
    454461        if ( empty( $canonical ) ) {
    455             return [ 'action' => 'error', 'reason' => 'could_not_pick_canonical' ];
     462            return [
     463                'action' => 'error',
     464                'reason' => 'could_not_pick_canonical',
     465            ];
    456466        }
    457467
     
    509519
    510520            // processing_status: prefer higher priority status.
    511             $priority = [ 'completed' => 5, 'pending' => 4, 'unprocessed' => 3, 'failed' => 2, 'expired' => 1 ];
    512             $cur_pr = isset( $merged['processing_status'] ) ? $merged['processing_status'] : 'unprocessed';
    513             $oth_pr = isset( $r['processing_status'] ) ? $r['processing_status'] : 'unprocessed';
     521            $priority = [
     522                'completed'   => 5,
     523                'pending'     => 4,
     524                'unprocessed' => 3,
     525                'failed'      => 2,
     526                'expired'     => 1,
     527            ];
     528            $cur_pr   = isset( $merged['processing_status'] ) ? $merged['processing_status'] : 'unprocessed';
     529            $oth_pr   = isset( $r['processing_status'] ) ? $r['processing_status'] : 'unprocessed';
    514530            if ( isset( $priority[ $oth_pr ] ) && isset( $priority[ $cur_pr ] ) && $priority[ $oth_pr ] > $priority[ $cur_pr ] ) {
    515531                $merged['processing_status'] = $oth_pr;
     
    518534
    519535        // Prepare sanitized data for DB write.
    520         $write_data = [];
     536        $write_data   = [];
    521537        $allowed_cols = [ 'page_url', 'url_hash', 'post_id', 'requested_time', 'generated_time', 'critical_css', 'remaining_css', 'secondary_css', 'size_savings', 'handshake', 'processing_status', 'settings', 'last_error' ];
    522538        foreach ( $allowed_cols as $c ) {
     
    527543
    528544        // Dry-run: return plan with what we'd do.
    529         $duplicate_ids = array_map( function ( $r ) use ( $canonical_id ) {
    530             return (int) $r['id'];
    531         }, array_filter( $rows, function ( $r ) use ( $canonical_id ) {
    532             return (int) $r['id'] !== $canonical_id;
    533         } ) );
     545        $duplicate_ids = array_map(
     546            function ( $r ) use ( $canonical_id ) {
     547                return (int) $r['id'];
     548            },
     549            array_filter(
     550                $rows,
     551                function ( $r ) use ( $canonical_id ) {
     552                    return (int) $r['id'] !== $canonical_id;
     553                }
     554            )
     555        );
    534556
    535557        $plan = [
    536             'action'        => $dry_run ? 'dry_run' : 'apply',
    537             'post_id'       => (int) $post_id,
    538             'canonical_id'  => $canonical_id,
    539             'canonical_hash'=> $canonical_hash,
    540             'merged'        => $write_data,
    541             'delete_ids'    => $duplicate_ids,
    542             'rows'          => $rows,
     558            'action'         => $dry_run ? 'dry_run' : 'apply',
     559            'post_id'        => (int) $post_id,
     560            'canonical_id'   => $canonical_id,
     561            'canonical_hash' => $canonical_hash,
     562            'merged'         => $write_data,
     563            'delete_ids'     => $duplicate_ids,
     564            'rows'           => $rows,
    543565        ];
    544566
     
    556578        if ( $updated === false ) {
    557579            $wpdb->query( 'ROLLBACK' );
    558             return [ 'action' => 'error', 'reason' => 'update_failed' ];
     580            return [
     581                'action' => 'error',
     582                'reason' => 'update_failed',
     583            ];
    559584        }
    560585
     
    564589            if ( $del_ok === false ) {
    565590                $wpdb->query( 'ROLLBACK' );
    566                 return [ 'action' => 'error', 'reason' => 'delete_failed', 'id' => $del_id ];
     591                return [
     592                    'action' => 'error',
     593                    'reason' => 'delete_failed',
     594                    'id'     => $del_id,
     595                ];
    567596            }
    568597        }
     
    576605        Critical_CSS::clear_cache( $post_id );
    577606
    578         return [ 'action' => 'applied', 'plan' => $plan ];
     607        return [
     608            'action' => 'applied',
     609            'plan'   => $plan,
     610        ];
    579611    }
    580612}
  • easy-critical-css/trunk/inc/class-helpers.php

    r3429798 r3439148  
    186186    public static function is_local_site( $host, $debug = false ) {
    187187        // Check transient.
    188         $cached = TimedOption::get( 'is_local_site' );
     188        $cached = Timed_Option::get( 'is_local_site' );
    189189        if ( ! $debug && $cached !== false ) {
    190190            return (bool) $cached;
     
    237237        // We need to store both true and false values as a transient, but only if no debug.
    238238        if ( ! $debug ) {
    239             TimedOption::set( 'is_local_site', $is_local ? '1' : '0', 6 * HOUR_IN_SECONDS );
     239            Timed_Option::set( 'is_local_site', $is_local ? '1' : '0', 6 * HOUR_IN_SECONDS );
    240240        } else {
    241241            // Give more info if debug.
     
    250250    public static function get_auto_mode_status( $force_refresh = false ) {
    251251        // Check transient.
    252         $cached = TimedOption::get( 'auto_mode_status' );
     252        $cached = Timed_Option::get( 'auto_mode_status' );
    253253        if ( ! $force_refresh && $cached !== false ) {
    254254            return $cached;
     
    264264        // Only run full status check if there's an active API key.
    265265        if ( empty( easy_cc_fs()->has_active_valid_license() ) ) {
    266             TimedOption::set( 'auto_mode_status', $status, 6 * HOUR_IN_SECONDS );
     266            Timed_Option::set( 'auto_mode_status', $status, 6 * HOUR_IN_SECONDS );
    267267
    268268            return $status;
    269269        }
    270270
    271         $status['active_key'] = true;
     271        $status['active_key']  = true;
    272272        $status['rest_api_ok'] = API_Service::test_receive_endpoint();
    273273
     
    275275        $status['all_ok'] = $status['active_key'] && $status['local_ok'] && $status['rest_api_ok'];
    276276
    277         TimedOption::set( 'auto_mode_status', $status, 6 * HOUR_IN_SECONDS );
     277        Timed_Option::set( 'auto_mode_status', $status, 6 * HOUR_IN_SECONDS );
    278278
    279279        return $status;
     
    282282    public static function is_rest_api_reachable( $debug = false ) {
    283283        // Check transient.
    284         $cached = TimedOption::get( 'is_rest_api_reachable' );
     284        $cached = Timed_Option::get( 'is_rest_api_reachable' );
    285285        if ( ! $debug && $cached !== false ) {
    286286            return (bool) $cached;
     
    292292        // We need to store both true and false values as a transient, but only if no debug.
    293293        if ( ! $debug ) {
    294             TimedOption::set( 'is_rest_api_reachable', $is_reachable ? '1' : '0', 6 * HOUR_IN_SECONDS );
     294            Timed_Option::set( 'is_rest_api_reachable', $is_reachable ? '1' : '0', 6 * HOUR_IN_SECONDS );
    295295        } else {
    296296            // Give more info if debug.
  • easy-critical-css/trunk/inc/class-notification.php

    r3429798 r3439148  
    2121
    2222        // Has the notification been dismissed?
    23         $notif_dismissed = TimedOption::get( 'auto_mode_setup_notif' );
     23        $notif_dismissed = Timed_Option::get( 'auto_mode_setup_notif' );
    2424        if ( $notif_dismissed !== false ) {
    2525            return false;
     
    6464            return;
    6565        }
    66        
     66
    6767        if ( ! self::should_show_notice() ) {
    6868            return;
     
    7777        );
    7878
    79         wp_localize_script( 'easy-critical-css-admin', 'eccSubscriptionNotice', [
    80             'restUrl' => esc_url_raw( rest_url( 'easy-critical-css/v1/' ) ),
    81             'nonce'   => wp_create_nonce( 'wp_rest' ),
    82             'plugin'   => [
    83                 'name'    => 'Easy Critical CSS',
    84                 'version' => Plugin::get_plugin_version(),
    85             ],
    86         ] );
     79        wp_localize_script(
     80            'easy-critical-css-admin',
     81            'eccSubscriptionNotice',
     82            [
     83                'restUrl' => esc_url_raw( rest_url( 'easy-critical-css/v1/' ) ),
     84                'nonce'   => wp_create_nonce( 'wp_rest' ),
     85                'plugin'  => [
     86                    'name'    => 'Easy Critical CSS',
     87                    'version' => Plugin::get_plugin_version(),
     88                ],
     89            ]
     90        );
    8791    }
    8892
     
    9397
    9498        $settings_url = admin_url( 'options-general.php?page=easy-critical-css-settings' );
    95         $docs_url     = 'https://criticalcss.net/docs';
     99        $docs_url     = 'https://criticalcss.net/docs?utm_source=easy-critical-css-plugin&utm_medium=notification&utm_campaign=v' . Plugin::get_plugin_version();
    96100        $plugin_name  = 'Easy Critical CSS';
    97101        $plugin_ver   = Plugin::get_plugin_version();
  • easy-critical-css/trunk/inc/class-plugin.php

    r3429798 r3439148  
    1010    private static $instance = null;
    1111
    12     private static $plugin_version = '1.4.5';
     12    private static $plugin_version = '1.4.6';
    1313
    1414    private static $db_version = '2';
  • easy-critical-css/trunk/inc/class-reset-handler.php

    r3402049 r3439148  
    5555
    5656        // Remove transients.
    57         TimedOption::delete_all();
     57        Timed_Option::delete_all();
    5858
    5959        // Remove old transients.
  • easy-critical-css/trunk/inc/class-rest-api.php

    r3429798 r3439148  
    216216                'permission_callback' => function () {
    217217                    return current_user_can( 'manage_options' );
    218                 }
     218                },
    219219            ]
    220220        );
     
    571571
    572572        if ( empty( $resolved_post_id ) ) {
    573             Debug::ecc_log( [ 'step' => 'receive_dedupe_skipped', 'reason' => 'no_post_id', 'hash' => $params['hash'] ] );
     573            Debug::ecc_log(
     574                [
     575                    'step'   => 'receive_dedupe_skipped',
     576                    'reason' => 'no_post_id',
     577                    'hash'   => $params['hash'],
     578                ]
     579            );
    574580        } else {
    575581            global $wpdb;
     
    580586            if ( (int) $count > 1 ) {
    581587                $dedupe_result = Database::dedupe_post_rows( $resolved_post_id, $handshake, false );
    582                 Debug::ecc_log( [ 'step' => 'receive_dedupe_apply', 'result' => $dedupe_result ] );
     588                Debug::ecc_log(
     589                    [
     590                        'step'   => 'receive_dedupe_apply',
     591                        'result' => $dedupe_result,
     592                    ]
     593                );
    583594            } else {
    584                 Debug::ecc_log( [ 'step' => 'receive_dedupe_skipped', 'reason' => 'no_duplicates', 'post_id' => $resolved_post_id ] );
     595                Debug::ecc_log(
     596                    [
     597                        'step'    => 'receive_dedupe_skipped',
     598                        'reason'  => 'no_duplicates',
     599                        'post_id' => $resolved_post_id,
     600                    ]
     601                );
    585602            }
    586603        }
     
    588605        // Mark REST API reachability as successful so we don't trigger repeated
    589606        // remote tests immediately after receiving CSS. Cache for 6 hours.
    590         TimedOption::set( 'is_rest_api_reachable', '1', 6 * HOUR_IN_SECONDS );
     607        Timed_Option::set( 'is_rest_api_reachable', '1', 6 * HOUR_IN_SECONDS );
    591608
    592609        /**
     
    675692            ]
    676693        );
     694    }
     695
     696    /**
     697     * Extracts and validates a nonce from request headers or params.
     698     *
     699     * @param  WP_REST_Request $request
     700     *
     701     * @return boolean|WP_Error  True if valid, WP_Error if invalid or missing.
     702     */
     703    private static function validate_nonce( WP_REST_Request $request ) {
     704        $nonce = $request->get_header( 'X-WP-Nonce' );
     705        if ( empty( $nonce ) ) {
     706            $nonce = $request->get_param( '_wpnonce' );
     707        }
     708
     709        if ( ! $nonce || ! wp_verify_nonce( $nonce, 'wp_rest' ) ) {
     710            return new WP_Error(
     711                'invalid_nonce',
     712                __( 'Invalid security token.', 'easy-critical-css' ),
     713                [ 'status' => 403 ]
     714            );
     715        }
     716
     717        return true;
    677718    }
    678719
     
    837878        }
    838879
    839         $stored_nonce = TimedOption::get( 'receive_test_nonce' );
     880        $stored_nonce = Timed_Option::get( 'receive_test_nonce' );
    840881        if ( ! $stored_nonce || $stored_nonce !== $nonce ) {
    841882            return new WP_Error(
     
    847888
    848889        // Success, clean it up.
    849         TimedOption::delete( 'receive_test_nonce' );
     890        Timed_Option::delete( 'receive_test_nonce' );
    850891
    851892        return rest_ensure_response( [ 'success' => true ] );
     
    853894
    854895    public static function refresh_auto_mode_status( WP_REST_Request $request ) {
    855         $nonce = $request->get_header( 'X-WP-Nonce' ) ?: $request->get_param( '_wpnonce' );
    856         if ( ! $nonce || ! wp_verify_nonce( $nonce, 'wp_rest' ) ) {
    857             return new WP_Error(
    858                 'invalid_nonce',
    859                 __( 'Invalid security token.', 'easy-critical-css' ),
    860                 [ 'status' => 403 ]
    861             );
     896        $nonce = self::validate_nonce( $request );
     897        if ( is_wp_error( $nonce ) ) {
     898            return $nonce;
    862899        }
    863900
     
    878915
    879916    public static function dismiss_notification( WP_REST_Request $request ) {
    880         $nonce = $request->get_header( 'X-WP-Nonce' ) ?: $request->get_param( '_wpnonce' );
    881         if ( ! $nonce || ! wp_verify_nonce( $nonce, 'wp_rest' ) ) {
    882             return new WP_Error(
    883                 'invalid_nonce',
    884                 __( 'Invalid security token.', 'easy-critical-css' ),
    885                 [ 'status' => 403 ]
    886             );
     917        $nonce = self::validate_nonce( $request );
     918        if ( is_wp_error( $nonce ) ) {
     919            return $nonce;
    887920        }
    888921
    889922        // Dismiss for a year to avoid nagging.
    890         TimedOption::set( 'auto_mode_setup_notif', time(), YEAR_IN_SECONDS );
     923        Timed_Option::set( 'auto_mode_setup_notif', time(), YEAR_IN_SECONDS );
    891924
    892925        return rest_ensure_response( [ 'success' => true ] );
     
    894927
    895928    public static function activate_auto_generation( WP_REST_Request $request ) {
    896         $nonce = $request->get_header( 'X-WP-Nonce' ) ?: $request->get_param( '_wpnonce' );
    897         if ( ! $nonce || ! wp_verify_nonce( $nonce, 'wp_rest' ) ) {
    898             return new WP_Error(
    899                 'invalid_nonce',
    900                 __( 'Invalid security token.', 'easy-critical-css' ),
    901                 [ 'status' => 403 ]
    902             );
     929        $nonce = self::validate_nonce( $request );
     930        if ( is_wp_error( $nonce ) ) {
     931            return $nonce;
    903932        }
    904933
     
    906935
    907936        // Dismiss notification for a day to avoid immediate nagging.
    908         TimedOption::set( 'auto_mode_setup_notif', time(), DAY_IN_SECONDS );
     937        Timed_Option::set( 'auto_mode_setup_notif', time(), DAY_IN_SECONDS );
    909938
    910939        return rest_ensure_response( [ 'success' => true ] );
  • easy-critical-css/trunk/inc/class-settings.php

    r3401089 r3439148  
    4848        // If Perfmatters conflicting CSS settings are active, Critical is paused
    4949        if ( Compatibility_Perfmatters::has_conflicting_css_settings() ) {
     50            return false;
     51        }
     52
     53        // If Jetpack Boost is installed, Critical is paused
     54        if ( Compatibility_Jetpack_Boost::is_jetpack_boost_installed() ) {
    5055            return false;
    5156        }
  • easy-critical-css/trunk/inc/class-timed-option.php

    r3429798 r3439148  
    77}
    88
    9 class TimedOption {
     9class Timed_Option {
    1010    const TIMED_OPTION_PREFIX = 'easy_cc_timed_';
    1111
  • easy-critical-css/trunk/inc/class-uninstall-handler.php

    r3429798 r3439148  
    2626        global $wpdb;
    2727        $table_name = $wpdb->prefix . 'easy_critical_css';
    28         $wpdb->query( "DROP TABLE IF EXISTS " . esc_sql( $table_name ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Dropping plugin table during uninstall requires direct database query.
     28        $wpdb->query( 'DROP TABLE IF EXISTS ' . esc_sql( $table_name ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Dropping plugin table during uninstall requires direct database query.
    2929
    3030        // Delete any static files.
  • easy-critical-css/trunk/inc/load-freemius.php

    r3402049 r3439148  
    5858
    5959// Clear auto_mode_status cache when license changes.
    60 easy_cc_fs()->add_action( 'after_license_change', [ __NAMESPACE__ . '\TimedOption', 'delete_all' ] );
    61 easy_cc_fs()->add_action( 'after_license_activation', [ __NAMESPACE__ . '\TimedOption', 'delete_all' ] );
    62 easy_cc_fs()->add_action( 'after_license_deactivation', [ __NAMESPACE__ . '\TimedOption', 'delete_all' ] );
     60easy_cc_fs()->add_action( 'after_license_change', [ __NAMESPACE__ . '\Timed_Option', 'delete_all' ] );
     61easy_cc_fs()->add_action( 'after_license_activation', [ __NAMESPACE__ . '\Timed_Option', 'delete_all' ] );
     62easy_cc_fs()->add_action( 'after_license_deactivation', [ __NAMESPACE__ . '\Timed_Option', 'delete_all' ] );
    6363
    6464// Signal that SDK was initiated.
  • easy-critical-css/trunk/readme.txt

    r3429798 r3439148  
    66Tested up to:      6.9
    77Requires PHP:      7.4
    8 Stable tag:        1.4.5
     8Stable tag:        1.4.6
    99License:           GPLv2 or later
    1010License URI:       https://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Easily inject Critical CSS and Secondary CSS (with unused styles removed) to improve site speed and performance.
     12Easily inject Critical CSS and Secondary CSS (with unused CSS styles removed) to improve site speed and performance.
    1313
    1414== Description ==
     
    102102== Changelog ==
    103103
     104= 1.4.6 =
     105- OPTIMIZATION: Improve performance of compatibility functionality
     106- COMPATIBILITY: Adds Jetpack Boost compatibility
     107- COMPATIBILITY: Adds AddToAny compatibility
     108
    104109= 1.4.5 =
    105110- OPTIMIZATION: Adds dismissible notification prompting users with active licenses to activate auto-generation
     
    191196== Upgrade Notice ==
    192197
     198= 1.4.6 =
     199* This update provides compatibility improvements.
     200
    193201= 1.4.5 =
    194202* This update includes bug fixes and improves code quality.
  • easy-critical-css/trunk/vendor/composer/autoload_classmap.php

    r3429798 r3439148  
    1111    'EasyCriticalCSS\\API_Service' => $baseDir . '/inc/class-api-service.php',
    1212    'EasyCriticalCSS\\Admin_Settings' => $baseDir . '/inc/class-admin-settings.php',
    13     'EasyCriticalCSS\\Compatibility_Cache' => $baseDir . '/inc/class-compatibility-cache.php',
    14     'EasyCriticalCSS\\Compatibility_Cloudflare' => $baseDir . '/inc/class-compatibility-cloudflare.php',
    15     'EasyCriticalCSS\\Compatibility_EWWW' => $baseDir . '/inc/class-compatibility-ewww.php',
    16     'EasyCriticalCSS\\Compatibility_Perfmatters' => $baseDir . '/inc/class-compatibility-perfmatters.php',
    17     'EasyCriticalCSS\\Compatibility_Trellis' => $baseDir . '/inc/class-compatibility-trellis.php',
    18     'EasyCriticalCSS\\Compatibility_WP_Rocket' => $baseDir . '/inc/class-compatibility-wp-rocket.php',
    19     'EasyCriticalCSS\\Compatibility_WooCommerce' => $baseDir . '/inc/class-compatibility-woocommerce.php',
     13    'EasyCriticalCSS\\Compatibility' => $baseDir . '/inc/compatibility/class-compatibility.php',
     14    'EasyCriticalCSS\\Compatibility_Add_To_Any' => $baseDir . '/inc/compatibility/class-compatibility-add-to-any.php',
     15    'EasyCriticalCSS\\Compatibility_Cache' => $baseDir . '/inc/compatibility/class-compatibility-cache.php',
     16    'EasyCriticalCSS\\Compatibility_Cloudflare' => $baseDir . '/inc/compatibility/class-compatibility-cloudflare.php',
     17    'EasyCriticalCSS\\Compatibility_EWWW' => $baseDir . '/inc/compatibility/class-compatibility-ewww.php',
     18    'EasyCriticalCSS\\Compatibility_Jetpack_Boost' => $baseDir . '/inc/compatibility/class-compatibility-jetpack-boost.php',
     19    'EasyCriticalCSS\\Compatibility_Perfmatters' => $baseDir . '/inc/compatibility/class-compatibility-perfmatters.php',
     20    'EasyCriticalCSS\\Compatibility_Trellis' => $baseDir . '/inc/compatibility/class-compatibility-trellis.php',
     21    'EasyCriticalCSS\\Compatibility_WP_Rocket' => $baseDir . '/inc/compatibility/class-compatibility-wp-rocket.php',
     22    'EasyCriticalCSS\\Compatibility_WooCommerce' => $baseDir . '/inc/compatibility/class-compatibility-woocommerce.php',
    2023    'EasyCriticalCSS\\Critical_CSS' => $baseDir . '/inc/class-critical-css.php',
    2124    'EasyCriticalCSS\\Critical_CSS_Injector' => $baseDir . '/inc/class-critical-css-injector.php',
     
    3437    'EasyCriticalCSS\\Reset_Handler' => $baseDir . '/inc/class-reset-handler.php',
    3538    'EasyCriticalCSS\\Settings' => $baseDir . '/inc/class-settings.php',
    36     'EasyCriticalCSS\\TimedOption' => $baseDir . '/inc/class-timed-option.php',
     39    'EasyCriticalCSS\\Timed_Option' => $baseDir . '/inc/class-timed-option.php',
    3740    'EasyCriticalCSS\\Uninstall_Handler' => $baseDir . '/inc/class-uninstall-handler.php',
    3841);
  • easy-critical-css/trunk/vendor/composer/autoload_static.php

    r3429798 r3439148  
    1616        'EasyCriticalCSS\\API_Service' => __DIR__ . '/../..' . '/inc/class-api-service.php',
    1717        'EasyCriticalCSS\\Admin_Settings' => __DIR__ . '/../..' . '/inc/class-admin-settings.php',
    18         'EasyCriticalCSS\\Compatibility_Cache' => __DIR__ . '/../..' . '/inc/class-compatibility-cache.php',
    19         'EasyCriticalCSS\\Compatibility_Cloudflare' => __DIR__ . '/../..' . '/inc/class-compatibility-cloudflare.php',
    20         'EasyCriticalCSS\\Compatibility_EWWW' => __DIR__ . '/../..' . '/inc/class-compatibility-ewww.php',
    21         'EasyCriticalCSS\\Compatibility_Perfmatters' => __DIR__ . '/../..' . '/inc/class-compatibility-perfmatters.php',
    22         'EasyCriticalCSS\\Compatibility_Trellis' => __DIR__ . '/../..' . '/inc/class-compatibility-trellis.php',
    23         'EasyCriticalCSS\\Compatibility_WP_Rocket' => __DIR__ . '/../..' . '/inc/class-compatibility-wp-rocket.php',
    24         'EasyCriticalCSS\\Compatibility_WooCommerce' => __DIR__ . '/../..' . '/inc/class-compatibility-woocommerce.php',
     18        'EasyCriticalCSS\\Compatibility' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility.php',
     19        'EasyCriticalCSS\\Compatibility_Add_To_Any' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-add-to-any.php',
     20        'EasyCriticalCSS\\Compatibility_Cache' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-cache.php',
     21        'EasyCriticalCSS\\Compatibility_Cloudflare' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-cloudflare.php',
     22        'EasyCriticalCSS\\Compatibility_EWWW' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-ewww.php',
     23        'EasyCriticalCSS\\Compatibility_Jetpack_Boost' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-jetpack-boost.php',
     24        'EasyCriticalCSS\\Compatibility_Perfmatters' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-perfmatters.php',
     25        'EasyCriticalCSS\\Compatibility_Trellis' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-trellis.php',
     26        'EasyCriticalCSS\\Compatibility_WP_Rocket' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-wp-rocket.php',
     27        'EasyCriticalCSS\\Compatibility_WooCommerce' => __DIR__ . '/../..' . '/inc/compatibility/class-compatibility-woocommerce.php',
    2528        'EasyCriticalCSS\\Critical_CSS' => __DIR__ . '/../..' . '/inc/class-critical-css.php',
    2629        'EasyCriticalCSS\\Critical_CSS_Injector' => __DIR__ . '/../..' . '/inc/class-critical-css-injector.php',
     
    3942        'EasyCriticalCSS\\Reset_Handler' => __DIR__ . '/../..' . '/inc/class-reset-handler.php',
    4043        'EasyCriticalCSS\\Settings' => __DIR__ . '/../..' . '/inc/class-settings.php',
    41         'EasyCriticalCSS\\TimedOption' => __DIR__ . '/../..' . '/inc/class-timed-option.php',
     44        'EasyCriticalCSS\\Timed_Option' => __DIR__ . '/../..' . '/inc/class-timed-option.php',
    4245        'EasyCriticalCSS\\Uninstall_Handler' => __DIR__ . '/../..' . '/inc/class-uninstall-handler.php',
    4346    );
  • easy-critical-css/trunk/vendor/composer/installed.php

    r3429798 r3439148  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => 'c8ce21f4f3bcf284c9a6b55f62219e608f3888e9',
     6        'reference' => '3b2bb5029610be84e005e35a02f50051e6763adc',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    2323            'pretty_version' => 'dev-main',
    2424            'version' => 'dev-main',
    25             'reference' => 'c8ce21f4f3bcf284c9a6b55f62219e608f3888e9',
     25            'reference' => '3b2bb5029610be84e005e35a02f50051e6763adc',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.