Plugin Directory

Changeset 3295017


Ignore:
Timestamp:
05/16/2025 09:08:08 PM (11 months ago)
Author:
sethta
Message:

Update to version 1.0.3

Location:
easy-critical-css
Files:
290 added
11 edited

Legend:

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

    r3284313 r3295017  
    11{
    22  "name": "sethta/easy-critical-css",
    3   "description": "A WordPress plugin boilerplate",
     3  "description": "Easily inject Critical CSS and optimized Secondary CSS to improve page speed and performance.",
    44  "type": "wordpress-plugin",
    55  "require": {
  • easy-critical-css/trunk/easy-critical-css.php

    r3286607 r3295017  
    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.2
     5 * Version:           1.0.3
    66 * Requires at least: 6.2
    77 * Tested up to:      6.8.1
  • easy-critical-css/trunk/inc/class-admin-settings.php

    r3285342 r3295017  
    184184            // translators: %s is a link to the API.
    185185            __( 'The Auto mode sends page data to an API at %s that requires a key.', 'easy-critical-css' ),
    186             '<a href="https://criticalcss.net" target="_blank">CriticalCSS.net</a>'
     186            '<a href="https://criticalcss.net/" target="_blank" rel="noopener noreferrer">CriticalCSS.net</a>'
    187187        );
    188188        $critical_css_mode_warn = "<p style=\"color: #a32b2d; font-weight: bold;\">$critical_css_mode_text</p>";
     
    190190        if ( empty( Helpers::get_api_key() ) ) {
    191191            $critical_css_mode_warn = sprintf(
    192                 '<p style="color: #a32b2d; font-weight: bold;">%s <a href="%s">%s</a>. <span class="activate-license easy-critical-css"><a href="#">Add API Key</a>.</span></p>',
     192                '<p style="color: #a32b2d; font-weight: bold;">%s <a href="%s">%s</a>. <span class="activate-license easy-critical-css"><a href="#">Add API Key</a>.</span></p><p style="font-weight: bold;">Want to get started without an API key? Use <a href="https://criticalcss.net/#pricing" target="_blank" rel="noopener noreferrer">CriticalCSS.net</a> to generate Critical CSS manually and paste it into your settings.</p>',
    193193                $critical_css_mode_text,
    194194                esc_url( admin_url( 'admin.php?page=easy-critical-css-settings-pricing' ) ),
  • easy-critical-css/trunk/inc/class-critical-css-injector.php

    r3286607 r3295017  
    5252        wp_register_style( 'easy-critical-css', false, [], null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
    5353        wp_enqueue_style( 'easy-critical-css' );
    54         wp_add_inline_style( 'easy-critical-css', wp_strip_all_tags( trim( $critical_css ) ) );
     54        wp_add_inline_style( 'easy-critical-css', Helpers::esc_css( $critical_css ) );
    5555    }
    5656
     
    163163        if ( ! empty( $inline_styles ) ) {
    164164            $merged_styles = implode( "\n", $inline_styles );
    165             wp_add_inline_style( 'easy-secondary-css', wp_strip_all_tags( trim( $merged_styles ) ) );
     165            wp_add_inline_style( 'easy-secondary-css', Helpers::esc_css( $merged_styles ) );
    166166        }
    167167    }
  • easy-critical-css/trunk/inc/class-critical-css-server.php

    r3284313 r3295017  
    6161
    6262        header( 'Content-Type: text/css' );
    63         // We escape through `wp_strip_all_tags` instead of a standard WP escaping function because '>' is needed for CSS rules.
    64         echo wp_strip_all_tags( trim( $css_output ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     63        // We escape through a custom CSS escaping function instead of a standard WP escaping function because '>' is needed for CSS rules, and tags are needed fro inline SVGs.
     64        echo Helpers::esc_css( $css_output ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    6565        exit;
    6666    }
  • easy-critical-css/trunk/inc/class-critical-css-status.php

    r3284313 r3295017  
    7070    public static function get_status( $identifier ) {
    7171        $generated = Critical_CSS::get_generated_css( $identifier );
     72
     73        // Is this a non-published post status?
     74        if ( ! empty( $generated['post_id'] ) && get_post_status( $generated['post_id'] ) !== 'publish' ) {
     75            return 'unprocessed';
     76        }
    7277
    7378        // Are we out of pending purgatory?
  • easy-critical-css/trunk/inc/class-critical-css.php

    r3286607 r3295017  
    109109            'settings'       => ( isset( $data['settings'] ) ) ? $data['settings'] : '',
    110110            'url_hash'       => ( isset( $data['url_hash'] ) ) ? $data['url_hash'] : '',
     111            'post_id'        => ( isset( $data['post_id'] ) ) ? $data['post_id'] : '',
    111112        ];
    112113
    113114        // Compute status dynamically.
    114115        $status                  = ( isset( $data['processing_status'] ) ) ? $data['processing_status'] : 'unprocessed';
     116        $status                  = ( ! empty( $generated_css['post_id'] ) && get_post_status( $generated_css['post_id'] ) !== 'publish' ) ? 'unprocessed' : $status;
    115117        $settings                = ( isset( $data['settings'] ) ) ? json_decode( $data['settings'], true ) : [];
    116118        $is_active               = ( isset( $settings['activate_critical_css'] ) ) ? (bool) $settings['activate_critical_css'] : true;
  • easy-critical-css/trunk/inc/class-helpers.php

    r3284313 r3295017  
    249249        return $is_reachable;
    250250    }
     251
     252    public static function esc_css( $css ) {
     253        // Remove any script/style/etc. tags that might've been injected
     254        $css = preg_replace( '/<\/?(script|style|iframe|html|body|head)[^>]*>/i', '', $css );
     255
     256        // Trim and normalize whitespace
     257        return trim( $css );
     258    }
    251259}
  • easy-critical-css/trunk/inc/class-plugin.php

    r3286607 r3295017  
    1010    private static $instance = null;
    1111
    12     private static $plugin_version = '1.0.2';
     12    private static $plugin_version = '1.0.3';
    1313
    1414    private static $db_version = '1.0';
  • easy-critical-css/trunk/readme.txt

    r3286607 r3295017  
    1818**Features:**
    1919- Easily add **Critical CSS** and **Secondary CSS** to any page
    20 - **Secondary CSS** removes all unused stylesheets, ensuring only a single optimized CSS file loads
     20- **Secondary CSS** removes all unused CSS rules and stylesheets, ensuring only a single optimized CSS file loads
    2121- Supports **posts, pages, archives, and taxonomy pages**
    2222- Fully **compatible with caching plugins** (WP Rocket, W3 Total Cache, WP Super Cache, etc.)
    2323- **Customizable settings** for individual pages
    24 - **Background processing** to prevent performance impact
    25 - **Optional API service** (*API key required*) for automated Critical & Secondary CSS generation
     24- Stores Critical CSS in your choice of the **database or as static files**
     25- **Optional API service** (*API key required*) for automated Critical & Secondary CSS generation through [CriticalCSS.net](https://criticalcss.net/)
     26- **Background processing** to for smooth, non-blocking performance
    2627
    2728### Why Use Critical CSS?
    28 Critical CSS ensures that essential styles for above-the-fold content load first, reducing render-blocking and **boosting Core Web Vitals**, page speed, and SEO rankings.
     29Critical CSS ensures above-the-fold content loads first by reducing render-blocking styles. This helps you **boost Core Web Vitals, improve page speed scores**, and deliver a better experience to your visitors.
     30
     31Want to try it out first? You can generate free one-off Critical CSS at [CriticalCSS.net](https://criticalcss.net) and manually apply it to your site using the plugin settings.
    2932
    3033== Installation ==
     
    7477
    7578= Does Easy Critical CSS work with caching plugins? =
    76 Yes! It integrates with popular caching plugins and clears their cache when new Critical CSS is applied.
     79Yes! It integrates smoothly with popular caching plugins and clears their cache when Critical CSS updates, ensuring your visitors always see optimized styles.
    7780
    7881= Can I exclude specific CSS files? =
     
    8083
    8184= How does the plugin generate Critical CSS? =
    82 The plugin extracts Critical CSS using an **API-based service (API key required)**. It scans your page, isolates the above-the-fold styles, and **removes unused selectors**, optimizing CSS size and performance.
     85It integrates with [CriticalCSS.net](https://criticalcss.net), a fast and privacy-focused CSS generation service. It analyzes your page, extracts the above-the-fold styles, and returns optimized Critical and Secondary CSS automatically.
    8386
    8487= Can I use this without an API key? =
    85 Absolutely! You can manually add a **default Critical CSS** that applies to all pages. Additionally, you can **override** it per page with custom Critical CSS and use **Secondary CSS** to remove unnecessary stylesheets.
     88Yes! You can manually enter Critical CSS that applies to your entire site, or override it on specific pages. You don't need an API key unless you want automatic generation.
     89
     90= How do I generate Critical CSS for manual usage? =
     91You can use the free generator at CriticalCSS.net to create both Critical and Secondary CSS for any page. Just copy the results into the appropriate fields in this plugin's settings.
    8692
    8793= Where is Critical CSS stored? =
     
    109115- FIX: Fixes logic when outputting Secondary CSS
    110116- 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/composer/installed.php

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