Plugin Directory

Changeset 2929596


Ignore:
Timestamp:
06/22/2023 09:43:32 AM (3 years ago)
Author:
futtta
Message:

pretty minor AO release

Location:
autoptimize
Files:
2 deleted
6 edited
46 copied

Legend:

Unmodified
Added
Removed
  • autoptimize/tags/3.1.8/autoptimize.php

    r2903008 r2929596  
    44 * Plugin URI: https://autoptimize.com/pro/
    55 * Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
    6  * Version: 3.1.7
     6 * Version: 3.1.8
    77 * Author: Frank Goossens (futtta)
    88 * Author URI: https://autoptimize.com/pro/
     
    2222}
    2323
    24 define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.7' );
     24define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.8' );
    2525
    2626// plugin_dir_path() returns the trailing slash!
     
    8080}
    8181
     82// filter to disable AO both on front- and backend.
     83if ( apply_filters( 'autoptimize_filter_disable_plugin', false ) ) {
     84    return;
     85}
     86
    8287/**
    8388 * Retrieve the instance of the main plugin class.
  • autoptimize/tags/3.1.8/classes/autoptimizeCriticalCSSCore.php

    r2878905 r2929596  
    108108                                return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    109109                            } else {
     110                                if ( $debug ) {
     111                                    $this->criticalcss->log( 'Path based rule with value "none" found.', 3 );
     112                                }
    110113                                $no_ccss = 'none';
    111114                            }
     
    131134                                return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    132135                            } else {
     136                                if ( $debug ) {
     137                                    $this->criticalcss->log( 'Conditional rule for is_front_page with value "none" found.', 3 );
     138                                }
    133139                                $no_ccss = 'none';
    134140                            }
     
    141147                                    return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    142148                                } else {
     149                                    if ( $debug ) {
     150                                        $this->criticalcss->log( 'Conditional rule custom_post with value "none" found.', 3 );
     151                                    }
    143152                                    $no_ccss = 'none';
    144153                                }
     
    152161                                    return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    153162                                } else {
     163                                    if ( $debug ) {
     164                                        $this->criticalcss->log( 'Conditional rule for template with value "none" found.', 3 );
     165                                    }
    154166                                    $no_ccss = 'none';
    155167                                }
     
    166178                                    return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    167179                                } else {
     180                                    if ( $debug ) {
     181                                        $this->criticalcss->log( 'Conditional rule for ' . $type . ' with value "none" found.', 3 );
     182                                    }
    168183                                    $no_ccss = 'none';
    169184                                }
     
    178193        // This also applies to logged in users if the option to add CCSS for logged in users has been disabled.
    179194        if ( ! empty( $inlined ) && 'none' !== $no_ccss ) {
     195            if ( $debug ) {
     196                $this->criticalcss->log( 'Using default "above the fold" CSS.', 3 );
     197            }
    180198            return apply_filters( 'autoptimize_filter_ccss_core_ccss', $inlined . $additional );
    181199        } else {
     200            if ( $debug ) {
     201                $this->criticalcss->log( 'No matching CCSS found, switching to inlining full CSS.', 3 );
     202            }
    182203            add_filter( 'autoptimize_filter_css_inline', '__return_true' );
    183204            return;
  • autoptimize/tags/3.1.8/classes/autoptimizeCriticalCSSEnqueue.php

    r2801903 r2929596  
    232232                $page_type = 'is_front_page';
    233233                break;
    234             } elseif ( strpos( $type, 'custom_post_' ) !== false && ( ! $forcepath || ! is_page() ) ) {
     234            } elseif ( strpos( $type, 'custom_post_' ) !== false && ( ! $forcepath || ! is_page() ) && is_singular() ) {
    235235                // Match custom post types and not page or page not forced to path-based.
    236236                if ( get_post_type( get_the_ID() ) === substr( $type, 12 ) ) {
  • autoptimize/tags/3.1.8/classes/autoptimizeImages.php

    r2878905 r2929596  
    262262    }
    263263
    264     public function get_imgopt_host()
     264    public static function get_imgopt_host()
    265265    {
    266266        static $imgopt_host = null;
     
    763763
    764764        // background-image in inline style.
    765         if ( strpos( $out, 'background-image:' ) !== false && apply_filters( 'autoptimize_filter_imgopt_backgroundimages', true ) ) {
     765        if ( ( strpos( $out, 'background-image:' ) !== false || strpos( $out, 'background:' ) !== false ) && strpos( $out, 'url(' ) !== false && apply_filters( 'autoptimize_filter_imgopt_backgroundimages', true ) ) {
    766766            $out = preg_replace_callback(
    767                 '/style=(?:"|\')[^<>]*?background-image:\s?url\((?:"|\')?([^"\')]*)(?:"|\')?\)/',
     767               '/style=(?:"|\')[^<>]*?background(?:-image)?:[^;"\'()>]*url\((?:"|\')?([^"\')]*)(?:"|\')?\)/',
    768768                array( $this, 'replace_img_callback' ),
    769769                $out
     
    12011201    public function fix_silly_bgimg_quotes( $tag_in ) {
    12021202        // some themes/ pagebuilders wrap backgroundimages in HTML-encoded quotes (or linebreaks) which breaks imgopt/ lazyloading, this removes them.
    1203         return trim( str_replace( array( "\r\n", '&quot;', '&#034;', '&apos;', '&#039;' ), '', $tag_in ) );
     1203        return trim( str_replace( array( "\r\n", '"', '&quot;', '&#034;', '&apos;', '&#039;' ), '', $tag_in ) );
    12041204    }
    12051205
  • autoptimize/tags/3.1.8/classes/critcss-inc/admin_settings_debug.php

    r2770441 r2929596  
    5050                <tr>
    5151                    <th scope="row">
    52                         <?php echo $option['name']; ?>
     52                        <?php echo wp_strip_all_tags( $option['name'] ); ?>
    5353                    </th>
    5454                    <td>
    5555                        <?php
    5656                        if ( 'autoptimize_ccss_queue' == $option['name'] || 'autoptimize_ccss_rules' == $option['name'] ) {
    57                             $value = print_r( json_decode( $option['value'], true ), true );
     57                            $value = print_r( json_decode( wp_strip_all_tags( $option['value'] ), true ), true );
    5858                            if ( $value ) {
    59                                 echo "Raw JSON:\n<pre>" . $option['value'] . "</pre>\n\nDecoded JSON:\n<pre>" . $value . '</pre>';
     59                                echo "Raw JSON:\n<pre>" . wp_strip_all_tags( $option['value'] ) . "</pre>\n\nDecoded JSON:\n<pre>" . wp_strip_all_tags( $value ) . '</pre>';
    6060                            } else {
    6161                                echo 'Empty';
    6262                            }
    6363                        } else {
    64                             echo $option['value'];
     64                            echo wp_strip_all_tags( $option['value'] );
    6565                        }
    6666                        ?>
  • autoptimize/tags/3.1.8/readme.txt

    r2903936 r2929596  
    66Tested up to: 6.2
    77Requires PHP: 5.6
    8 Stable tag: 3.1.7
     8Stable tag: 3.1.8
    99
    1010Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
     
    320320== Changelog ==
    321321
     322= 3.1.8 =
     323* Images: improve optmization logic for background images
     324* Critical CSS: don't trigger custom_post rule if not is_singular + adding debug logging for rule selection
     325* some other minor changes/ improvements/ filters, see the [GitHub commit log](https://github.com/futtta/autoptimize/commits/beta).
     326
    322327= 3.1.7 =
    323328* security: improve validation (import) and sanitization (output) of critical CSS rules, to fix a medium severity Admin+ Stored Cross-Site Scripting vulnerability as reported by WP Scan Security.
  • autoptimize/trunk/autoptimize.php

    r2903008 r2929596  
    44 * Plugin URI: https://autoptimize.com/pro/
    55 * Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
    6  * Version: 3.1.7
     6 * Version: 3.1.8
    77 * Author: Frank Goossens (futtta)
    88 * Author URI: https://autoptimize.com/pro/
     
    2222}
    2323
    24 define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.7' );
     24define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.8' );
    2525
    2626// plugin_dir_path() returns the trailing slash!
     
    8080}
    8181
     82// filter to disable AO both on front- and backend.
     83if ( apply_filters( 'autoptimize_filter_disable_plugin', false ) ) {
     84    return;
     85}
     86
    8287/**
    8388 * Retrieve the instance of the main plugin class.
  • autoptimize/trunk/classes/autoptimizeCriticalCSSCore.php

    r2878905 r2929596  
    108108                                return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    109109                            } else {
     110                                if ( $debug ) {
     111                                    $this->criticalcss->log( 'Path based rule with value "none" found.', 3 );
     112                                }
    110113                                $no_ccss = 'none';
    111114                            }
     
    131134                                return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    132135                            } else {
     136                                if ( $debug ) {
     137                                    $this->criticalcss->log( 'Conditional rule for is_front_page with value "none" found.', 3 );
     138                                }
    133139                                $no_ccss = 'none';
    134140                            }
     
    141147                                    return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    142148                                } else {
     149                                    if ( $debug ) {
     150                                        $this->criticalcss->log( 'Conditional rule custom_post with value "none" found.', 3 );
     151                                    }
    143152                                    $no_ccss = 'none';
    144153                                }
     
    152161                                    return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    153162                                } else {
     163                                    if ( $debug ) {
     164                                        $this->criticalcss->log( 'Conditional rule for template with value "none" found.', 3 );
     165                                    }
    154166                                    $no_ccss = 'none';
    155167                                }
     
    166178                                    return apply_filters( 'autoptimize_filter_ccss_core_ccss', $_ccss_contents . $additional );
    167179                                } else {
     180                                    if ( $debug ) {
     181                                        $this->criticalcss->log( 'Conditional rule for ' . $type . ' with value "none" found.', 3 );
     182                                    }
    168183                                    $no_ccss = 'none';
    169184                                }
     
    178193        // This also applies to logged in users if the option to add CCSS for logged in users has been disabled.
    179194        if ( ! empty( $inlined ) && 'none' !== $no_ccss ) {
     195            if ( $debug ) {
     196                $this->criticalcss->log( 'Using default "above the fold" CSS.', 3 );
     197            }
    180198            return apply_filters( 'autoptimize_filter_ccss_core_ccss', $inlined . $additional );
    181199        } else {
     200            if ( $debug ) {
     201                $this->criticalcss->log( 'No matching CCSS found, switching to inlining full CSS.', 3 );
     202            }
    182203            add_filter( 'autoptimize_filter_css_inline', '__return_true' );
    183204            return;
  • autoptimize/trunk/classes/autoptimizeCriticalCSSEnqueue.php

    r2801903 r2929596  
    232232                $page_type = 'is_front_page';
    233233                break;
    234             } elseif ( strpos( $type, 'custom_post_' ) !== false && ( ! $forcepath || ! is_page() ) ) {
     234            } elseif ( strpos( $type, 'custom_post_' ) !== false && ( ! $forcepath || ! is_page() ) && is_singular() ) {
    235235                // Match custom post types and not page or page not forced to path-based.
    236236                if ( get_post_type( get_the_ID() ) === substr( $type, 12 ) ) {
  • autoptimize/trunk/classes/autoptimizeImages.php

    r2878905 r2929596  
    262262    }
    263263
    264     public function get_imgopt_host()
     264    public static function get_imgopt_host()
    265265    {
    266266        static $imgopt_host = null;
     
    763763
    764764        // background-image in inline style.
    765         if ( strpos( $out, 'background-image:' ) !== false && apply_filters( 'autoptimize_filter_imgopt_backgroundimages', true ) ) {
     765        if ( ( strpos( $out, 'background-image:' ) !== false || strpos( $out, 'background:' ) !== false ) && strpos( $out, 'url(' ) !== false && apply_filters( 'autoptimize_filter_imgopt_backgroundimages', true ) ) {
    766766            $out = preg_replace_callback(
    767                 '/style=(?:"|\')[^<>]*?background-image:\s?url\((?:"|\')?([^"\')]*)(?:"|\')?\)/',
     767               '/style=(?:"|\')[^<>]*?background(?:-image)?:[^;"\'()>]*url\((?:"|\')?([^"\')]*)(?:"|\')?\)/',
    768768                array( $this, 'replace_img_callback' ),
    769769                $out
     
    12011201    public function fix_silly_bgimg_quotes( $tag_in ) {
    12021202        // some themes/ pagebuilders wrap backgroundimages in HTML-encoded quotes (or linebreaks) which breaks imgopt/ lazyloading, this removes them.
    1203         return trim( str_replace( array( "\r\n", '&quot;', '&#034;', '&apos;', '&#039;' ), '', $tag_in ) );
     1203        return trim( str_replace( array( "\r\n", '"', '&quot;', '&#034;', '&apos;', '&#039;' ), '', $tag_in ) );
    12041204    }
    12051205
  • autoptimize/trunk/classes/critcss-inc/admin_settings_debug.php

    r2770441 r2929596  
    5050                <tr>
    5151                    <th scope="row">
    52                         <?php echo $option['name']; ?>
     52                        <?php echo wp_strip_all_tags( $option['name'] ); ?>
    5353                    </th>
    5454                    <td>
    5555                        <?php
    5656                        if ( 'autoptimize_ccss_queue' == $option['name'] || 'autoptimize_ccss_rules' == $option['name'] ) {
    57                             $value = print_r( json_decode( $option['value'], true ), true );
     57                            $value = print_r( json_decode( wp_strip_all_tags( $option['value'] ), true ), true );
    5858                            if ( $value ) {
    59                                 echo "Raw JSON:\n<pre>" . $option['value'] . "</pre>\n\nDecoded JSON:\n<pre>" . $value . '</pre>';
     59                                echo "Raw JSON:\n<pre>" . wp_strip_all_tags( $option['value'] ) . "</pre>\n\nDecoded JSON:\n<pre>" . wp_strip_all_tags( $value ) . '</pre>';
    6060                            } else {
    6161                                echo 'Empty';
    6262                            }
    6363                        } else {
    64                             echo $option['value'];
     64                            echo wp_strip_all_tags( $option['value'] );
    6565                        }
    6666                        ?>
  • autoptimize/trunk/readme.txt

    r2903936 r2929596  
    66Tested up to: 6.2
    77Requires PHP: 5.6
    8 Stable tag: 3.1.7
     8Stable tag: 3.1.8
    99
    1010Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
     
    320320== Changelog ==
    321321
     322= 3.1.8 =
     323* Images: improve optmization logic for background images
     324* Critical CSS: don't trigger custom_post rule if not is_singular + adding debug logging for rule selection
     325* some other minor changes/ improvements/ filters, see the [GitHub commit log](https://github.com/futtta/autoptimize/commits/beta).
     326
    322327= 3.1.7 =
    323328* security: improve validation (import) and sanitization (output) of critical CSS rules, to fix a medium severity Admin+ Stored Cross-Site Scripting vulnerability as reported by WP Scan Security.
Note: See TracChangeset for help on using the changeset viewer.