Plugin Directory

Changeset 3401333


Ignore:
Timestamp:
11/23/2025 02:59:14 PM (4 months ago)
Author:
futtta
Message:

yet another collection of minor fixes and tweaks

Location:
autoptimize
Files:
13 edited
13 copied

Legend:

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

    r3208241 r3401333  
    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.13
     6 * Version: 3.1.14
    77 * Author: Frank Goossens (futtta)
    88 * Author URI: https://autoptimize.com/pro/
     
    2222}
    2323
    24 define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.13' );
     24define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.14' );
    2525
    2626// plugin_dir_path() returns the trailing slash!
  • autoptimize/tags/3.1.14/classes/autoptimizeBase.php

    r2878905 r3401333  
    600600                $content
    601601            );
     602
     603            // Check for error (for example, an error can occur if $content is very large).
     604            if ( null === $content ) {
     605                $error_message = 'Autoptimize: preg_replace_callback() failed';
     606                if ( function_exists( 'preg_last_error_msg' ) ) {
     607                    $error_message .= ': ' . preg_last_error_msg();
     608                }
     609                error_log( $error_message );
     610            }
    602611        }
    603612
  • autoptimize/tags/3.1.14/classes/autoptimizeCSSmin.php

    r3208241 r3401333  
    4040        // regex see tests at https://regex101.com/r/ofGQG9/1
    4141        if ( apply_filters( 'autoptimize_filter_css_hide_calc', true ) ) {
    42             $css = autoptimizeBase::replace_contents_with_marker_if_exists( 'CALC', 'calc(', '#(calc|min|max|clamp)\([^;]*\)#m', $css );
     42            $css = autoptimizeBase::replace_contents_with_marker_if_exists( 'CALC', 'calc(', '#(calc|min|max|clamp)\([^;}]*\)#m', $css );
    4343        }
    4444
  • autoptimize/tags/3.1.14/classes/autoptimizeCriticalCSSBase.php

    r3048250 r3401333  
    281281        );
    282282
    283         if ( strpos( $this->_options['domain'], 'http' ) === false && strpos( $this->_options['domain'], 'uggc' ) === 0 ) {
     283        if ( ( strpos( $this->_options['domain'], 'http' ) === false && strpos( $this->_options['domain'], 'uggc' ) === 0 ) || 'abar' === $this->_options['domain'] ) {
    284284            $this->_options['domain'] = str_rot13( $this->_options['domain'] );
    285285        } elseif ( strpos( $this->_options['domain'], 'http' ) !== false ) {
  • autoptimize/tags/3.1.14/classes/autoptimizeCriticalCSSCron.php

    r3208241 r3401333  
    9696
    9797            // Initialize counters.
    98             if ( 0 == $rtimelimit ) {
     98            if ( empty( $rtimelimit ) || 0 == $rtimelimit ) {
    9999                // no time limit set, let's go with 1000 seconds.
    100100                $rtimelimit = 1000;
    101101            }
    102             $mt = time() + $rtimelimit; // maxtime queue processing can run.
     102            $mt = time() + (int) $rtimelimit; // maxtime queue processing can run.
    103103            $jc = 1; // job count number.
    104104            $jr = 1; // jobs requests number.
  • autoptimize/tags/3.1.14/classes/autoptimizeImages.php

    r3208241 r3401333  
    10571057        $tag   = str_replace( $_from, $_to, $tag );
    10581058
    1059         // and remove title, alt, class and id.
    1060         $tag = preg_replace( '/ ((?:title|alt|class|id|loading|fetchpriority|decoding|data-no-lazy|width|height)=".*")/Um', '', $tag );
    1061         if ( str_replace( array( ' title=', ' class=', ' alt=', ' id=', ' fetchpriority=', ' decoding=', ' data-no-lazy=' ), '', $tag ) !== $tag ) {
    1062             // 2nd regex pass if still title/ class/ alt in case single quotes were used iso doubles.
    1063             $tag = preg_replace( '/ ((?:title|alt|class|id|loading|fetchpriority|decoding|data-no-lazy)=\'.*\')/Um', '', $tag );
    1064         }
    1065 
     1059        // and using kses, remove all unneeded attributes
     1060        // keeping only those we *know* are OK and/ or needed
     1061        $allowed_html = array(
     1062                'link' => array(
     1063                    'rel'           => true,
     1064                    'as'            => true,
     1065                    'href'          => true,
     1066                    'imagesizes'    => true,
     1067                    'imagesrcset'   => true,
     1068                    'type'          => true,
     1069                    'media'         => true,
     1070                ),
     1071            );
     1072        $tag = wp_kses( $tag, $allowed_html );
     1073       
    10661074        return $tag;
    10671075    }
  • autoptimize/tags/3.1.14/classes/autoptimizeMain.php

    r3048250 r3401333  
    766766    {
    767767        echo '<div class="updated"><p>';
    768         printf( esc_html_e( 'Autoptimize has just been updated. Please %1$stest your site now%2$s and adapt Autoptimize config if needed.', 'autoptimize' ), '<strong>', '</strong>' );
     768        printf( esc_html__( 'Autoptimize has just been updated. Please %1$stest your site now%2$s and adapt Autoptimize config if needed.', 'autoptimize' ), '<strong>', '</strong>' );
    769769        echo '</p></div>';
    770770    }
  • autoptimize/tags/3.1.14/config/autoptimize_404_handler.php

    r2786932 r3401333  
    4343if ( $original_request !== $fallback_target && file_exists( $fallback_path ) ) {
    4444    // error_log( 'Autoptimize file ' . $original_request . ' not found, using fallback instead.' );
    45     header( 'HTTP/1.1 301 Moved Permanently' );
     45    header( 'HTTP/1.1 302 Found' );
    4646    header( 'Location: ' . $fallback_target );
    4747} else {
  • autoptimize/tags/3.1.14/readme.txt

    r3298738 r3401333  
    66License URI: [https://www.gnu.org/licenses/gpl-3.0.html](https://www.gnu.org/licenses/gpl-3.0.html)
    77Requires at least: 5.3
    8 Tested up to: 6.8
    9 Requires PHP: 5.6
    10 Stable tag: 3.1.13
     8Tested up to: 6.9
     9Requires PHP: 7.1
     10Stable tag: 3.1.14
    1111
    1212Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
     
    322322== Changelog ==
    323323
     324= 3.1.14 =
     325* improve HTML output for <link rel="preload" images (based on report by Muhammad)
     326* let the 404-handler issue a 302 iso 301 HTTP response (as mentioned by thefitrv)
     327* small improvement in critical CSS cron job handling in case of an empty "time limit" (thanks for the help Jason)
     328* fix bug in "domain binding" in critical CSS advanced options (reported by Hazel)
     329* catch and report (exceptional) JS optimization issues causing preg_replace_callback to crash out (in case of a huge amount of JS code), thanks siliconforks
     330* confirmed OK with WordPress 6.9
     331
    324332= 3.1.13 =
    325333* multiple minor changes/ improvements/ bugfixes, see the [GitHub commit log](https://github.com/futtta/autoptimize/commits/beta).
  • autoptimize/trunk/autoptimize.php

    r3208241 r3401333  
    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.13
     6 * Version: 3.1.14
    77 * Author: Frank Goossens (futtta)
    88 * Author URI: https://autoptimize.com/pro/
     
    2222}
    2323
    24 define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.13' );
     24define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.14' );
    2525
    2626// plugin_dir_path() returns the trailing slash!
  • autoptimize/trunk/classes/autoptimizeBase.php

    r2878905 r3401333  
    600600                $content
    601601            );
     602
     603            // Check for error (for example, an error can occur if $content is very large).
     604            if ( null === $content ) {
     605                $error_message = 'Autoptimize: preg_replace_callback() failed';
     606                if ( function_exists( 'preg_last_error_msg' ) ) {
     607                    $error_message .= ': ' . preg_last_error_msg();
     608                }
     609                error_log( $error_message );
     610            }
    602611        }
    603612
  • autoptimize/trunk/classes/autoptimizeCSSmin.php

    r3208241 r3401333  
    4040        // regex see tests at https://regex101.com/r/ofGQG9/1
    4141        if ( apply_filters( 'autoptimize_filter_css_hide_calc', true ) ) {
    42             $css = autoptimizeBase::replace_contents_with_marker_if_exists( 'CALC', 'calc(', '#(calc|min|max|clamp)\([^;]*\)#m', $css );
     42            $css = autoptimizeBase::replace_contents_with_marker_if_exists( 'CALC', 'calc(', '#(calc|min|max|clamp)\([^;}]*\)#m', $css );
    4343        }
    4444
  • autoptimize/trunk/classes/autoptimizeCriticalCSSBase.php

    r3048250 r3401333  
    281281        );
    282282
    283         if ( strpos( $this->_options['domain'], 'http' ) === false && strpos( $this->_options['domain'], 'uggc' ) === 0 ) {
     283        if ( ( strpos( $this->_options['domain'], 'http' ) === false && strpos( $this->_options['domain'], 'uggc' ) === 0 ) || 'abar' === $this->_options['domain'] ) {
    284284            $this->_options['domain'] = str_rot13( $this->_options['domain'] );
    285285        } elseif ( strpos( $this->_options['domain'], 'http' ) !== false ) {
  • autoptimize/trunk/classes/autoptimizeCriticalCSSCron.php

    r3208241 r3401333  
    9696
    9797            // Initialize counters.
    98             if ( 0 == $rtimelimit ) {
     98            if ( empty( $rtimelimit ) || 0 == $rtimelimit ) {
    9999                // no time limit set, let's go with 1000 seconds.
    100100                $rtimelimit = 1000;
    101101            }
    102             $mt = time() + $rtimelimit; // maxtime queue processing can run.
     102            $mt = time() + (int) $rtimelimit; // maxtime queue processing can run.
    103103            $jc = 1; // job count number.
    104104            $jr = 1; // jobs requests number.
  • autoptimize/trunk/classes/autoptimizeImages.php

    r3208241 r3401333  
    10571057        $tag   = str_replace( $_from, $_to, $tag );
    10581058
    1059         // and remove title, alt, class and id.
    1060         $tag = preg_replace( '/ ((?:title|alt|class|id|loading|fetchpriority|decoding|data-no-lazy|width|height)=".*")/Um', '', $tag );
    1061         if ( str_replace( array( ' title=', ' class=', ' alt=', ' id=', ' fetchpriority=', ' decoding=', ' data-no-lazy=' ), '', $tag ) !== $tag ) {
    1062             // 2nd regex pass if still title/ class/ alt in case single quotes were used iso doubles.
    1063             $tag = preg_replace( '/ ((?:title|alt|class|id|loading|fetchpriority|decoding|data-no-lazy)=\'.*\')/Um', '', $tag );
    1064         }
    1065 
     1059        // and using kses, remove all unneeded attributes
     1060        // keeping only those we *know* are OK and/ or needed
     1061        $allowed_html = array(
     1062                'link' => array(
     1063                    'rel'           => true,
     1064                    'as'            => true,
     1065                    'href'          => true,
     1066                    'imagesizes'    => true,
     1067                    'imagesrcset'   => true,
     1068                    'type'          => true,
     1069                    'media'         => true,
     1070                ),
     1071            );
     1072        $tag = wp_kses( $tag, $allowed_html );
     1073       
    10661074        return $tag;
    10671075    }
  • autoptimize/trunk/classes/autoptimizeMain.php

    r3048250 r3401333  
    766766    {
    767767        echo '<div class="updated"><p>';
    768         printf( esc_html_e( 'Autoptimize has just been updated. Please %1$stest your site now%2$s and adapt Autoptimize config if needed.', 'autoptimize' ), '<strong>', '</strong>' );
     768        printf( esc_html__( 'Autoptimize has just been updated. Please %1$stest your site now%2$s and adapt Autoptimize config if needed.', 'autoptimize' ), '<strong>', '</strong>' );
    769769        echo '</p></div>';
    770770    }
  • autoptimize/trunk/config/autoptimize_404_handler.php

    r2786932 r3401333  
    4343if ( $original_request !== $fallback_target && file_exists( $fallback_path ) ) {
    4444    // error_log( 'Autoptimize file ' . $original_request . ' not found, using fallback instead.' );
    45     header( 'HTTP/1.1 301 Moved Permanently' );
     45    header( 'HTTP/1.1 302 Found' );
    4646    header( 'Location: ' . $fallback_target );
    4747} else {
  • autoptimize/trunk/readme.txt

    r3298738 r3401333  
    66License URI: [https://www.gnu.org/licenses/gpl-3.0.html](https://www.gnu.org/licenses/gpl-3.0.html)
    77Requires at least: 5.3
    8 Tested up to: 6.8
    9 Requires PHP: 5.6
    10 Stable tag: 3.1.13
     8Tested up to: 6.9
     9Requires PHP: 7.1
     10Stable tag: 3.1.14
    1111
    1212Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
     
    322322== Changelog ==
    323323
     324= 3.1.14 =
     325* improve HTML output for <link rel="preload" images (based on report by Muhammad)
     326* let the 404-handler issue a 302 iso 301 HTTP response (as mentioned by thefitrv)
     327* small improvement in critical CSS cron job handling in case of an empty "time limit" (thanks for the help Jason)
     328* fix bug in "domain binding" in critical CSS advanced options (reported by Hazel)
     329* catch and report (exceptional) JS optimization issues causing preg_replace_callback to crash out (in case of a huge amount of JS code), thanks siliconforks
     330* confirmed OK with WordPress 6.9
     331
    324332= 3.1.13 =
    325333* multiple minor changes/ improvements/ bugfixes, see the [GitHub commit log](https://github.com/futtta/autoptimize/commits/beta).
Note: See TracChangeset for help on using the changeset viewer.