Plugin Directory


Ignore:
Timestamp:
11/12/2026 01:25:30 PM (less than one hour ago)
Author:
wpdevteam
Message:

Update to version 1.4.8 from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • xspeed/trunk/includes/modules/Minify/MinifyModule.php

    r3754746 r3798397  
    9393                                'default'     => false,
    9494                                'label'       => __( 'Load CSS without blocking', 'xspeed' ),
    95                                 'description' => __( 'On pages that have critical CSS, the page shows before the rest of its CSS finishes loading. Pages without critical CSS keep loading their CSS normally, because deferring it makes the page show unstyled and then jump.', 'xspeed' ),
     95                                'description' => __( 'On pages that have critical CSS, the page shows before the rest of its CSS finishes loading. Pages without critical CSS keep loading their CSS normally, because deferring it makes the page show unstyled and then jump. Pages with a slider, carousel or masonry grid also load their CSS normally, because those scripts lay the page out before late CSS would arrive.', 'xspeed' ),
    9696                        ),
    9797                        'remove_query_strings' => array(
    … …  
    153153                                'default'     => false,
    154154                                'label'       => __( 'Combine CSS files', 'xspeed' ),
    155                                 'description' => __( 'Joins your site\'s own CSS files into one. This helps only on old HTTP/1.1 servers, so leave it off on most hosts.', 'xspeed' ),
     155                                'description' => __( 'Joins your site\'s own CSS files into one. This helps only on old HTTP/1.1 servers, so leave it off on most hosts. Runs for logged-in visitors too, so an admin browsing the site sees the combined page.', 'xspeed' ),
    156156                                'advanced'    => true,
    157157                        ),
    … …  
    160160                                'default'     => false,
    161161                                'label'       => __( 'Combine JavaScript files', 'xspeed' ),
    162                                 'description' => __( 'Joins your site\'s own scripts into one file. Turn off if a script stops working after you enable it.', 'xspeed' ),
     162                                'description' => __( 'Joins your site\'s own scripts into one file. Turn off if a script stops working after you enable it. Runs for logged-in visitors too, so an admin browsing the site sees the combined page.', 'xspeed' ),
    163163                                'advanced'    => true,
    164164                        ),
    … …  
    258258                 */
    259259                add_action( 'init', array( $this, 'boot_on_init' ) );
     260                // A saved change can lift the reason a page was left alone, so the
     261                // panel starts its list again from the next cache MISS. (#553)
     262                add_action(
     263                        'update_option_' . Settings_Manager::OPTION_PREFIX . self::SLUG,
     264                        static function (): void {
     265                                delete_transient( Minify_Filters::ASYNC_CSS_SKIPS_TRANSIENT );
     266                        }
     267                );
    260268        }
    261269
    … …  
    286294         */
    287295        public function ui_notices(): array {
    288                 $opts = $this->get_settings();
     296                $opts    = $this->get_settings();
     297                $notices = $this->async_css_notices( $opts );
    289298                if ( empty( $opts['minify_html'] ) ) {
    290                         return array();
     299                        return $notices;
    291300                }
    292301
    293302                $reason = LegacyMinifier::skip_reason();
    294303                if ( '' === $reason ) {
    295                         return array();
     304                        return $notices;
    296305                }
    297306
    … …  
    302311                        : __( 'HTML minification is paused because a plugin or theme is returning true from the xspeed_skip_minify filter. Cached pages are served un-minified until that filter stops suppressing it.', 'xspeed' );
    303312
    304                 return array(
    305                         array(
     313                $notices[] = array(
     314                        'tone'  => 'info',
     315                        'title' => __( 'HTML minification is on but currently paused', 'xspeed' ),
     316                        'body'  => $body,
     317                );
     318                return $notices;
     319        }
     320
     321        /**
     322         * Say which pages Load CSS without blocking left alone, and why.
     323         *
     324         * Both guards in Minify_Filters::async_style_tag() are deliberate, but
     325         * the setting read "on" while a slider page's stylesheets stayed
     326         * render-blocking, with nothing saying why. (#553)
     327         *
     328         * @param array<string,mixed> $opts This module's settings.
     329         * @return array<int,array<string,mixed>>
     330         */
     331        private function async_css_notices( array $opts ): array {
     332                if ( empty( $opts['async_css'] ) ) {
     333                        return array();
     334                }
     335                $report = get_transient( Minify_Filters::ASYNC_CSS_SKIPS_TRANSIENT );
     336                if ( ! is_array( $report ) ) {
     337                        return array();
     338                }
     339
     340                $notices = array();
     341                foreach ( array( 'no_critical_css', 'js_measured_layout' ) as $reason ) {
     342                        if ( empty( $report[ $reason ]['paths'] ) || ! is_array( $report[ $reason ]['paths'] ) ) {
     343                                continue;
     344                        }
     345                        $paths   = implode( ', ', array_map( 'strval', $report[ $reason ]['paths'] ) );
     346                        $handles = isset( $report[ $reason ]['handles'] ) && is_array( $report[ $reason ]['handles'] )
     347                                ? implode( ', ', array_map( 'strval', $report[ $reason ]['handles'] ) )
     348                                : '';
     349
     350                        if ( 'no_critical_css' === $reason ) {
     351                                $body = sprintf(
     352                                        /* translators: %s: comma-separated page paths, e.g. "/, /shop/". */
     353                                        __( 'Stylesheets stayed render-blocking on %s because those pages have no critical CSS. Without it, deferred CSS makes the page show unstyled and then jump. A theme or plugin that inlines critical CSS for a page can return true from the xspeed_async_css_page_has_critical_css filter.', 'xspeed' ),
     354                                        $paths
     355                                );
     356                        } elseif ( '' !== $handles ) {
     357                                $body = sprintf(
     358                                        /* translators: 1: comma-separated page paths, 2: comma-separated script handles, e.g. "swiper". */
     359                                        __( 'Stylesheets stayed render-blocking on %1$s because a script there lays the page out by measuring it (%2$s). Sliders, carousels and masonry grids stay broken when their CSS arrives after the script has run. If the layout on those pages is pure CSS, return false from the xspeed_async_css_js_measured_layout filter.', 'xspeed' ),
     360                                        $paths,
     361                                        $handles
     362                                );
     363                        } else {
     364                                $body = sprintf(
     365                                        /* translators: %s: comma-separated page paths, e.g. "/, /shop/". */
     366                                        __( 'Stylesheets stayed render-blocking on %s because the xspeed_async_css_js_measured_layout filter reports a layout built by a script there. Return false from that filter if the layout on those pages is pure CSS.', 'xspeed' ),
     367                                        $paths
     368                                );
     369                        }
     370
     371                        $notices[] = array(
    306372                                'tone'  => 'info',
    307                                 'title' => __( 'HTML minification is on but currently paused', 'xspeed' ),
     373                                'title' => 'no_critical_css' === $reason
     374                                        ? __( 'Load CSS without blocking skipped pages without critical CSS', 'xspeed' )
     375                                        : __( 'Load CSS without blocking skipped pages with a slider or grid', 'xspeed' ),
    308376                                'body'  => $body,
    309                         ),
    310                 );
     377                        );
     378                }
     379                return $notices;
    311380        }
    312381
Note: See TracChangeset for help on using the changeset viewer.