Plugin Directory

Changeset 3307644


Ignore:
Timestamp:
06/06/2025 08:16:25 PM (9 months ago)
Author:
sethta
Message:

Update to version 1.1.0

Location:
easy-critical-css
Files:
300 added
17 edited

Legend:

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

    r3295017 r3307644  
    1313    "phpcompatibility/php-compatibility": "^9.3",
    1414    "wp-coding-standards/wpcs": "^3.1",
    15     "php-stubs/wordpress-stubs": "^6.7"
     15    "php-stubs/wordpress-stubs": "^6.7",
     16    "wp-phpunit/wp-phpunit": "^6.8",
     17    "yoast/phpunit-polyfills": "^4.0",
     18    "phpunit/phpunit": "^9.6",
     19    "phpcompatibility/phpcompatibility-wp": "^2.1"
    1620  },
    1721  "autoload": {
     
    2933    "sniff": "vendor/bin/phpcs . --extensions=php -s",
    3034    "post-install-cmd": "bash freemius-text-changes.sh",
    31     "post-update-cmd": "bash freemius-text-changes.sh"
     35    "post-update-cmd": "bash freemius-text-changes.sh",
     36    "test": "vendor/bin/phpunit",
     37    "test-coverage": "vendor/bin/phpunit --coverage-html tests/coverage",
     38    "test-setup": "sh tests/bin/install-wp-tests.sh wordpress_test root '' localhost latest",
     39    "test-teardown": "sh tests/bin/teardown-wp-tests.sh"
    3240  },
    3341  "extra": {
  • easy-critical-css/trunk/easy-critical-css.php

    r3295017 r3307644  
    33 * Plugin Name:       Easy Critical CSS
    44 * Description:       Easily inject Critical CSS and optimized Secondary CSS to improve page speed and performance.
    5  * Version:           1.0.3
     5 * Version:           1.1.0
    66 * Requires at least: 6.2
    77 * Tested up to:      6.8.1
  • easy-critical-css/trunk/inc/class-api-request-handler.php

    r3284313 r3307644  
    1616        $url  = $url_or_id;
    1717
    18         // If we have a number, it's a post ID
     18        // If we have a number, it's a post ID.
    1919        if ( is_numeric( $url_or_id ) ) {
    2020            $data['post_id'] = (int) $url;
     
    5252        $handshake = wp_generate_password( 20, false );
    5353
    54         // Construct the response URL dynamically
     54        // Construct the response URL dynamically.
    5555        $response_url = site_url( '/wp-json/easy-critical-css/v1/receive' );
     56
     57        // Response URL must be https.
     58        $scheme = wp_parse_url( $response_url, PHP_URL_SCHEME );
     59        if ( $scheme !== 'https' ) {
     60            return new WP_Error( 'no_ssl', __( 'The response URL must have SSL.', 'easy-critical-css' ) );
     61        }
    5662
    5763        $data = array_merge(
     
    7581                'nowprocket'          => '1',
    7682                'no_optimize'         => '1',
     83                'mvt_flags'           => 'disable_critical_css',
    7784            ],
    7885            $url
  • easy-critical-css/trunk/inc/class-compatibility-cache.php

    r3284313 r3307644  
    66    exit;
    77}
     8
     9/**
     10 * This file is for compatibility purposes and will not use the easy_cc prefix.
     11 * phpcs:disable WordPress.NamingConventions.PrefixAllGlobals
     12 */
    813
    914class Compatibility_Cache {
  • easy-critical-css/trunk/inc/class-compatibility-wp-rocket.php

    r3284313 r3307644  
    1414
    1515    public static function is_rocket_critical_activated() {
     16        // Allow override for testing or advanced use
     17        $override = apply_filters( 'easy_cc_mock_rocket_critical_active', null );
     18        if ( null !== $override ) {
     19            return (bool) $override;
     20        }
     21
    1622        // Is WP Rocket installed?
    1723        if ( ! defined( 'WP_ROCKET_VERSION' ) || ! function_exists( 'get_rocket_option' ) ) {
     
    2531        if ( ! self::is_rocket_critical_activated() ) {
    2632            return;
    27         } ?>
     33        }
     34
     35        $admin_url = wp_nonce_url(
     36            admin_url( 'admin-post.php?action=uncheck_wp_rocket_critical_css' ),
     37            'uncheck_wp_rocket_critical_css_action'
     38        ); ?>
    2839       
    2940        <div class="notice notice-warning">
     
    3344            <?php if ( current_user_can( 'manage_options' ) ) { ?>
    3445                <p>
    35                     <a href="<?php echo esc_url( admin_url( 'admin-post.php?action=uncheck_wp_rocket_critical_css' ) ); ?>" class="button button-primary">
    36                         <?php esc_html_e( 'Uncheck WP Rocket Optimize CSS Delivery.', 'easy-critical-css' ); ?>
     46                    <a href="<?php echo esc_url( $admin_url ); ?>" class="button button-primary">
     47                        <?php esc_html_e( 'Uncheck WP Rocket Optimize CSS Delivery', 'easy-critical-css' ); ?>
    3748                    </a>
    3849                </p>
     
    4455    public static function uncheck_wp_rocket_critical_css() {
    4556        // Verify permissions.
    46         if ( ! current_user_can( 'manage_options' ) ) {
     57        if ( ! current_user_can( 'manage_options' ) && check_admin_referer( 'uncheck_wp_rocket_critical_css_action' ) ) {
    4758            wp_die( esc_html( __( 'You do not have permission to perform this action.', 'easy-critical-css' ) ) );
    4859        }
  • easy-critical-css/trunk/inc/class-critical-css.php

    r3295017 r3307644  
    2929                'js',
    3030                'xml',
     31                'xsl',
    3132                'json',
    3233                'jpg',
     
    4445                'csv',
    4546                'zip',
     47                'gz',
    4648            ]
    4749        );
     
    116118        $status                  = ( ! empty( $generated_css['post_id'] ) && get_post_status( $generated_css['post_id'] ) !== 'publish' ) ? 'unprocessed' : $status;
    117119        $settings                = ( isset( $data['settings'] ) ) ? json_decode( $data['settings'], true ) : [];
    118         $is_active               = ( isset( $settings['activate_critical_css'] ) ) ? (bool) $settings['activate_critical_css'] : true;
     120        $is_active               = Settings::activate_critical_compatibility( isset( $settings['activate_critical_css'] ) ? (bool) $settings['activate_critical_css'] : true );
    119121        $generated_css['status'] = self::get_status( $status, $is_active );
    120122
     
    136138    public static function clear_cache( $identifier ) {
    137139        unset( self::$generated_css[ $identifier ] );
     140
     141        $hash = Helpers::get_url_hash( $identifier );
     142        if ( $hash !== (string) $identifier ) {
     143            unset( self::$generated_css[ $hash ] );
     144        }
    138145    }
    139146
     
    241248    public static function should_skip_critical() {
    242249        // Does the url skip critical?
    243         // phpcs:disable WordPress.Security.NonceVerification.Recommended -- No need for nonce verification as we are using this to check for Gutenberg.
     250        // phpcs:disable WordPress.Security.NonceVerification.Recommended -- No need for nonce verification as we are using this for read-only purposes.
    244251        if ( isset( $_GET['critical-css'] ) && substr( sanitize_text_field( wp_unslash( $_GET['critical-css'] ) ), 0, 4 ) === 'skip' ) {
    245252            return true;
  • easy-critical-css/trunk/inc/class-database.php

    r3284313 r3307644  
    3434            id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    3535            page_url TEXT NOT NULL,
    36             url_hash VARCHAR(255) UNIQUE,
     36            url_hash CHAR(32) NOT NULL,
    3737            post_id BIGINT UNSIGNED DEFAULT NULL,
    3838            requested_time DATETIME NOT NULL,
     
    4343            secondary_css LONGTEXT DEFAULT NULL,
    4444            size_savings TEXT DEFAULT NULL,
    45             handshake VARCHAR(64) NOT NULL UNIQUE,
     45            handshake VARCHAR(64) DEFAULT NULL,
    4646            processing_status ENUM('completed', 'expired', 'failed', 'pending', 'unprocessed') DEFAULT 'unprocessed',
    4747            settings LONGTEXT DEFAULT NULL,
    4848            last_error TEXT,
    4949            PRIMARY KEY (id),
    50             KEY post_id (post_id)
     50            UNIQUE KEY url_hash (url_hash),
     51            KEY post_id (post_id),
     52            KEY handshake (handshake)
    5153        ) $charset_collate";
    5254
     
    5860    /**
    5961     * Ensures database is correct version.
     62     *
     63     * This method is excluded from coverage because it wraps wpdb logic and triggers side effects
     64     * that are difficult to test in isolation (e.g., dbDelta and option checks).
     65     *
     66     * @codeCoverageIgnore
    6067     */
    6168    public static function ensure_db_correct() {
  • easy-critical-css/trunk/inc/class-helpers.php

    r3295017 r3307644  
    257257        return trim( $css );
    258258    }
     259
     260    /**
     261     * Parses a newline-separated string into a clean array.
     262     *
     263     * @param string $selector_string Raw newline-separated string.
     264     *
     265     * @return array Cleaned array of selectors.
     266     */
     267    public static function parse_newline_list( $selector_string ) {
     268        return array_values(
     269            array_filter(
     270                array_map( 'trim', explode( "\n", $selector_string ) ),
     271                function ( $item ) {
     272                    return $item !== '';
     273                }
     274            )
     275        );
     276    }
    259277}
  • easy-critical-css/trunk/inc/class-plugin.php

    r3295017 r3307644  
    1010    private static $instance = null;
    1111
    12     private static $plugin_version = '1.0.3';
     12    private static $plugin_version = '1.1.0';
    1313
    14     private static $db_version = '1.0';
     14    private static $db_version = '2';
    1515
    1616    private static $plugin_file;
     
    7272        Compatibility_Cache::init();
    7373        Compatibility_WP_Rocket::init();
     74        Compatibility_Trellis::init();
    7475        Critical_CSS::init();
    7576        Database::init();
  • easy-critical-css/trunk/inc/class-settings.php

    r3284313 r3307644  
    1919        return get_option( "easy_cc_$setting_name", $default_value );
    2020    }
     21
    2122    /**
    2223     * Gets an individual setting from the ECC table.
     
    3435    }
    3536
    36     /**
    37      * Gets the individual Activate Critical CSS setting.
    38      *
    39      * @param string|int $identifier URL, Post ID, or URL hash.
    40      *
    41      * @return bool
    42      */
    43     public static function get_individual_activate_critical( $identifier ) {
     37    public static function activate_critical_compatibility( $setting ) {
    4438        // If WP Rocket is installed, Critical is paused
    4539        if ( Compatibility_WP_Rocket::is_rocket_critical_activated() ) {
     
    4741        }
    4842
    49         return (bool) self::get_individual_setting( $identifier, 'activate_critical_css', true );
     43        // If Trellis is installed, Critical is paused
     44        if ( Compatibility_Trellis::is_trellis_critical_activated() ) {
     45            return false;
     46        }
     47
     48        return (bool) $setting;
     49    }
     50
     51    /**
     52     * Gets the individual Activate Critical CSS setting.
     53     *
     54     * @param string|int $identifier URL, Post ID, or URL hash.
     55     *
     56     * @return bool
     57     */
     58    public static function get_individual_activate_critical( $identifier ) {
     59        return self::activate_critical_compatibility( self::get_individual_setting( $identifier, 'activate_critical_css', true ) );
    5060    }
    5161
     
    107117    public static function get_global_forced_critical() {
    108118        $selectors = self::get_global_setting( 'forced_critical_selectors', '' );
    109         return array_filter( array_map( 'trim', explode( "\n", $selectors ) ) );
     119        return Helpers::parse_newline_list( $selectors );
    110120    }
    111121
     
    120130        $global    = self::get_global_forced_critical();
    121131        $selectors = (string) self::get_individual_setting( $identifier, 'forced_critical_selectors', implode( "\n", $global ) );
    122         return array_filter( array_map( 'trim', explode( "\n", $selectors ) ) );
     132        return Helpers::parse_newline_list( $selectors );
    123133    }
    124134
     
    130140    public static function get_global_forced_secondary() {
    131141        $selectors = self::get_global_setting( 'forced_secondary_selectors', '' );
    132         return array_filter( array_map( 'trim', explode( "\n", $selectors ) ) );
     142        return Helpers::parse_newline_list( $selectors );
    133143    }
    134144
     
    143153        $global    = self::get_global_forced_secondary();
    144154        $selectors = (string) self::get_individual_setting( $identifier, 'forced_secondary_selectors', implode( "\n", $global ) );
    145         return array_filter( array_map( 'trim', explode( "\n", $selectors ) ) );
     155        return Helpers::parse_newline_list( $selectors );
    146156    }
    147157
     
    168178
    169179    /**
    170      * Gets the individual Default Critical CSS.
     180     * Gets the individual Manual Critical CSS.
    171181     *
    172182     * @param string|int $identifier URL, Post ID, or URL hash.
     
    185195    public static function get_global_excluded_css_files() {
    186196        $files = self::get_global_setting( 'exclude_css_files', '' );
    187         return array_filter( array_map( 'trim', explode( "\n", $files ) ) );
     197        return Helpers::parse_newline_list( $files );
    188198    }
    189199
     
    198208        $global = self::get_global_excluded_css_files();
    199209        $files  = (string) self::get_individual_setting( $identifier, 'exclude_css_files', implode( "\n", $global ) );
    200         return array_filter( array_map( 'trim', explode( "\n", $files ) ) );
     210        return Helpers::parse_newline_list( $files );
    201211    }
    202212
  • easy-critical-css/trunk/inc/load-freemius.php

    r3284313 r3307644  
    4444// This isn't done for registered users so their preference isn't overwritten.
    4545if ( ! easy_cc_fs()->is_registered() && get_option( 'easy_cc_activation', false ) ) {
    46     $initial_time = strtotime( get_gmt_from_date( get_option( 'easy_cc_activation' ) ) );
    47     $elapsed_time = time() - $initial_time;
     46    $easy_cc_initial_time = strtotime( get_gmt_from_date( get_option( 'easy_cc_activation' ) ) );
     47    $easy_cc_elapsed_time = time() - $easy_cc_initial_time;
    4848
    49     if ( $elapsed_time < 15 ) {
     49    if ( $easy_cc_elapsed_time < 15 ) {
    5050        easy_cc_fs()->skip_connection();
    5151    } else {
  • easy-critical-css/trunk/readme.txt

    r3295020 r3307644  
    103103== Changelog ==
    104104
     105= 1.1.0 =
     106- OPTIMIZATION: Improved database structure for better performance and compatibility
     107- FEATURE: Adds compatibility with Trellis theme
     108- FIX: Excludes additional non-page file types from generating Critical CSS
     109- FIX: Excludes non-SSL requests from generating Critical CSS
     110- FIX: More accurate detection and fallback for Critical CSS settings
     111- FIX: Fixes compatibility issue with WP Rocket
     112
     113= 1.0.3 =
     114- FIX: Fixes issue where inline data SVGs were sometimes stripped
     115- FIX: Assigns proper status on non-published pages/posts
     116
     117= 1.0.2 =
     118- FIX: Fixes logic when outputting Secondary CSS
     119- FIX: Prevents 404 pages from auto generating Critical CSS
     120
     121= 1.0.1 =
     122- FIX: Prevents feeds from auto generating Critical CSS
     123
    105124= 1.0.0 =
    106125- Initial release
     
    108127- FEATURE: Automated Critical CSS generation through API
    109128- FEATURE: Integration with popular caching plugins
    110 
    111 = 1.0.1 =
    112 - FIX: Prevents feeds from auto generating Critical CSS
    113 
    114 = 1.0.2 =
    115 - FIX: Fixes logic when outputting Secondary CSS
    116 - FIX: Prevents 404 pages from auto generating Critical CSS
    117 
    118 = 1.0.3 =
    119 - FIX: Fixes issue where inline data SVGs were sometimes stripped
    120 - FIX: Assigns proper status on non-published pages/posts
  • easy-critical-css/trunk/vendor/autoload.php

    r3284313 r3307644  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitf64b91f1568066102d4da696ba6c13f4::getLoader();
     25return ComposerAutoloaderInitf8afcd59529b943371ccaad06587b0c3::getLoader();
  • easy-critical-css/trunk/vendor/composer/autoload_classmap.php

    r3284313 r3307644  
    1212    'EasyCriticalCSS\\Admin_Settings' => $baseDir . '/inc/class-admin-settings.php',
    1313    'EasyCriticalCSS\\Compatibility_Cache' => $baseDir . '/inc/class-compatibility-cache.php',
     14    'EasyCriticalCSS\\Compatibility_Trellis' => $baseDir . '/inc/class-compatibility-trellis.php',
    1415    'EasyCriticalCSS\\Compatibility_WP_Rocket' => $baseDir . '/inc/class-compatibility-wp-rocket.php',
    1516    'EasyCriticalCSS\\Critical_CSS' => $baseDir . '/inc/class-critical-css.php',
  • easy-critical-css/trunk/vendor/composer/autoload_real.php

    r3284313 r3307644  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitf64b91f1568066102d4da696ba6c13f4
     5class ComposerAutoloaderInitf8afcd59529b943371ccaad06587b0c3
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitf64b91f1568066102d4da696ba6c13f4', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitf8afcd59529b943371ccaad06587b0c3', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitf64b91f1568066102d4da696ba6c13f4', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitf8afcd59529b943371ccaad06587b0c3', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInitf64b91f1568066102d4da696ba6c13f4::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitf8afcd59529b943371ccaad06587b0c3::getInitializer($loader));
    3333
    3434        $loader->register(true);
    3535
    36         $filesToLoad = \Composer\Autoload\ComposerStaticInitf64b91f1568066102d4da696ba6c13f4::$files;
     36        $filesToLoad = \Composer\Autoload\ComposerStaticInitf8afcd59529b943371ccaad06587b0c3::$files;
    3737        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3838            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • easy-critical-css/trunk/vendor/composer/autoload_static.php

    r3284313 r3307644  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitf64b91f1568066102d4da696ba6c13f4
     7class ComposerStaticInitf8afcd59529b943371ccaad06587b0c3
    88{
    99    public static $files = array (
     
    3131        'EasyCriticalCSS\\Admin_Settings' => __DIR__ . '/../..' . '/inc/class-admin-settings.php',
    3232        'EasyCriticalCSS\\Compatibility_Cache' => __DIR__ . '/../..' . '/inc/class-compatibility-cache.php',
     33        'EasyCriticalCSS\\Compatibility_Trellis' => __DIR__ . '/../..' . '/inc/class-compatibility-trellis.php',
    3334        'EasyCriticalCSS\\Compatibility_WP_Rocket' => __DIR__ . '/../..' . '/inc/class-compatibility-wp-rocket.php',
    3435        'EasyCriticalCSS\\Critical_CSS' => __DIR__ . '/../..' . '/inc/class-critical-css.php',
     
    5455    {
    5556        return \Closure::bind(function () use ($loader) {
    56             $loader->prefixLengthsPsr4 = ComposerStaticInitf64b91f1568066102d4da696ba6c13f4::$prefixLengthsPsr4;
    57             $loader->prefixDirsPsr4 = ComposerStaticInitf64b91f1568066102d4da696ba6c13f4::$prefixDirsPsr4;
    58             $loader->classMap = ComposerStaticInitf64b91f1568066102d4da696ba6c13f4::$classMap;
     57            $loader->prefixLengthsPsr4 = ComposerStaticInitf8afcd59529b943371ccaad06587b0c3::$prefixLengthsPsr4;
     58            $loader->prefixDirsPsr4 = ComposerStaticInitf8afcd59529b943371ccaad06587b0c3::$prefixDirsPsr4;
     59            $loader->classMap = ComposerStaticInitf8afcd59529b943371ccaad06587b0c3::$classMap;
    5960
    6061        }, null, ClassLoader::class);
  • easy-critical-css/trunk/vendor/composer/installed.php

    r3295017 r3307644  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '8ff0c86678351dba677186ec5148c109aead3371',
     6        'reference' => '31bc22ab17fe61a4e32d8212848435a763845868',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    3232            'pretty_version' => 'dev-main',
    3333            'version' => 'dev-main',
    34             'reference' => '8ff0c86678351dba677186ec5148c109aead3371',
     34            'reference' => '31bc22ab17fe61a4e32d8212848435a763845868',
    3535            'type' => 'wordpress-plugin',
    3636            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.