Plugin Directory

Changeset 3721894


Ignore:
Timestamp:
09/30/2026 07:05:29 PM (2 weeks ago)
Author:
andergmartins
Message:

Update to version 3.113.1 from GitHub

Location:
ml-slider
Files:
820 added
22 deleted
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ml-slider/tags/3.113.1/admin/lib/helpers.php

    r3674480 r3721894  
    500500 *
    501501 * @since 3.103
     502 * @since 3.113.1 Use the prefixed MSHTMLPurifier classes so another plugin's copy of
     503 *                the library can no longer answer for ours.
    502504 *
    503505 * @param string $content    The HTML content to be purified
    … …  
    511513{
    512514    try {
    513         if ( ! class_exists( 'HTMLPurifier_Config' ) || ! class_exists( 'HTMLPurifier' ) ) {
    514             $autoloader = METASLIDER_PATH . 'lib/htmlpurifier/library/HTMLPurifier.auto.php';
     515        if ( ! class_exists( 'MSHTMLPurifier_Config' ) || ! class_exists( 'MSHTMLPurifier' ) ) {
     516            $autoloader = METASLIDER_PATH . 'lib/htmlpurifier/library/MSHTMLPurifier.auto.php';
    515517            if ( ! file_exists( $autoloader ) ) {
    516518                throw new RuntimeException( 'HTMLPurifier autoloader not found: ' . $autoloader );
    … …  
    518520            require_once( $autoloader );
    519521        }
    520         $config = HTMLPurifier_Config::createDefault();
     522        $config = MSHTMLPurifier_Config::createDefault();
    521523        // How to filter:
    522524        // add_filter('metaslider_html_purifier_config', function($config) {
    … …  
    526528        // });
    527529        $config   = apply_filters('metaslider_html_purifier_config', $config, $slide, $slider_id, $settings);
    528         $purifier = new HTMLPurifier( $config );
     530        $purifier = new MSHTMLPurifier( $config );
    529531        $content  = $purifier->purify( $content );
    530532    } catch ( Throwable $e ) {
  • ml-slider/tags/3.113.1/inc/slide/metaslide.image.class.php

    r3700496 r3721894  
    11481148     *
    11491149     * @since 3.101
     1150     * @since 3.113.1 Placeholder generation moved to lazy_load_placeholder(), which
     1151     *                falls back to a 1x1 GIF instead of fataling on an unusable size
    11501152     */
    11511153    public function image_attributes( $attributes, $slide, $slider_id )
    … …  
    11641166            }
    11651167
    1166             try {
    1167                 $width  = $attributes['width'];
    1168                 $height = $attributes['height'];
    1169 
    1170                 // Create a blank image with lowest ratio
    1171                 for ( $i = $height; $i > 1; $i-- ) {
    1172                     if ( ( $width % $i ) == 0 && ( $height % $i ) == 0 ) {
    1173                         $width = $width / $i;
    1174                         $height = $height / $i;
    1175                     }
    1176                 }
    1177                 $image = imagecreatetruecolor( $width, $height );
    1178 
    1179                 // Make it transparent
    1180                 imagesavealpha( $image, true );
    1181                 imagealphablending( $image, false );
    1182                 $white = imagecolorallocatealpha( $image, 255, 255, 255, 127 );
    1183                 imagefill( $image, 0, 0, $white );
    1184 
    1185                 // Capture the image output
    1186                 ob_start();
    1187                     imagepng( $image );
    1188                     $contents = base64_encode( ob_get_contents() );
    1189                 ob_end_clean();
    1190 
    1191                 // Free up the memory
    1192                 imagedestroy( $image );
    1193             } catch ( Exception $e ) {
    1194                 // 1x1 pixel backup - Note: might need some creative CSS to make this work given the dimensions
    1195                 $contents = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
    1196             }
    1197 
    1198             // Convert to base64
    1199             $data_uri = "data:image/jpeg;base64," . $contents;
     1168            $data_uri = $this->lazy_load_placeholder( $attributes['width'], $attributes['height'] );
    12001169
    12011170            $attributes['data-ms-src'] = $attributes['src'];
    … …  
    12211190        return $attributes;
    12221191    }
     1192
     1193    /**
     1194     * Transparent placeholder image for lazy loading, as a data URI
     1195     *
     1196     * Falls back to a 1x1 transparent GIF when the slideshow has no usable width
     1197     * or height setting, when the ratio is too large to draw, or when GD is missing -
     1198     * PHP 8 raises an Error, not an Exception, for a non-numeric or zero size, so it
     1199     * can't be caught below (#2488)
     1200     *
     1201     * @since 3.113.1
     1202     *
     1203     * @param mixed $width  Width setting, may be empty or non-numeric
     1204     * @param mixed $height Height setting, may be empty or non-numeric
     1205     *
     1206     * @return string
     1207     */
     1208    public function lazy_load_placeholder( $width, $height )
     1209    {
     1210        // 1x1 pixel backup - Note: might need some creative CSS to make this work given the dimensions
     1211        $fallback = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
     1212
     1213        // A placeholder only carries the aspect ratio, so a larger one is a runaway
     1214        // setting - and allocating it exhausts memory, which PHP cannot catch
     1215        $max_pixels = 1000000;
     1216
     1217        $width  = is_numeric( $width ) ? absint( $width ) : 0;
     1218        $height = is_numeric( $height ) ? absint( $height ) : 0;
     1219
     1220        if ( $width < 1 || $height < 1 || ! function_exists( 'imagecreatetruecolor' ) ) {
     1221            return $fallback;
     1222        }
     1223
     1224        // Draw at the lowest ratio the size reduces to
     1225        $divisor = $this->greatest_common_divisor( $width, $height );
     1226        $width   = intdiv( $width, $divisor );
     1227        $height  = intdiv( $height, $divisor );
     1228
     1229        if ( ( $width * $height ) > $max_pixels ) {
     1230            return $fallback;
     1231        }
     1232
     1233        // Discard a half-filled output buffer if capturing the image throws
     1234        $ob_level = ob_get_level();
     1235
     1236        try {
     1237            $image = imagecreatetruecolor( $width, $height );
     1238
     1239            // Make it transparent
     1240            imagesavealpha( $image, true );
     1241            imagealphablending( $image, false );
     1242            $white = imagecolorallocatealpha( $image, 255, 255, 255, 127 );
     1243            imagefill( $image, 0, 0, $white );
     1244
     1245            // Capture the image output
     1246            ob_start();
     1247                imagepng( $image );
     1248                $contents = base64_encode( ob_get_contents() );
     1249            ob_end_clean();
     1250
     1251            // Free up the memory
     1252            imagedestroy( $image );
     1253        } catch ( Throwable $e ) {
     1254            while ( ob_get_level() > $ob_level ) {
     1255                ob_end_clean();
     1256            }
     1257
     1258            return $fallback;
     1259        }
     1260
     1261        return 'data:image/png;base64,' . $contents;
     1262    }
     1263
     1264    /**
     1265     * Greatest common divisor of two positive integers, used to reduce a
     1266     * placeholder to the lowest ratio it can be drawn at
     1267     *
     1268     * @since 3.113.1
     1269     *
     1270     * @param int $a First integer
     1271     * @param int $b Second integer
     1272     *
     1273     * @return int
     1274     */
     1275    private function greatest_common_divisor( $a, $b )
     1276    {
     1277        while ( $b ) {
     1278            $remainder = $a % $b;
     1279            $a = $b;
     1280            $b = $remainder;
     1281        }
     1282
     1283        return $a;
     1284    }
    12231285}
  • ml-slider/tags/3.113.1/ml-slider.php

    r3700496 r3721894  
    66 * Plugin URI:  https://www.metaslider.com
    77 * Description: MetaSlider gives you the power to create a beautiful slideshow, carousel, or gallery on your WordPress site.
    8  * Version:     3.113.0
     8 * Version:     3.113.1
    99 * Author:      MetaSlider
    1010 * Author URI:  https://www.metaslider.com
    … …  
    4545         * @var string
    4646         */
    47         public $version = '3.113.0';
     47        public $version = '3.113.1';
    4848
    4949        /**
    … …  
    176176                $assets_version = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? uniqid() : $this->version;
    177177
    178                 define('METASLIDER_VERSION', '3.113.0');
     178                define('METASLIDER_VERSION', '3.113.1'); // We need it defined as string due `composer build` doesn't detect $this->version
    179179                define('METASLIDER_ASSETS_VERSION', $assets_version);
    180180                define('METASLIDER_BASE_URL', plugin_dir_url(metaslider_plugin_is_installed('ml-slider')));
  • ml-slider/trunk/admin/lib/helpers.php

    r3674480 r3721894  
    500500 *
    501501 * @since 3.103
     502 * @since 3.113.1 Use the prefixed MSHTMLPurifier classes so another plugin's copy of
     503 *                the library can no longer answer for ours.
    502504 *
    503505 * @param string $content    The HTML content to be purified
    … …  
    511513{
    512514    try {
    513         if ( ! class_exists( 'HTMLPurifier_Config' ) || ! class_exists( 'HTMLPurifier' ) ) {
    514             $autoloader = METASLIDER_PATH . 'lib/htmlpurifier/library/HTMLPurifier.auto.php';
     515        if ( ! class_exists( 'MSHTMLPurifier_Config' ) || ! class_exists( 'MSHTMLPurifier' ) ) {
     516            $autoloader = METASLIDER_PATH . 'lib/htmlpurifier/library/MSHTMLPurifier.auto.php';
    515517            if ( ! file_exists( $autoloader ) ) {
    516518                throw new RuntimeException( 'HTMLPurifier autoloader not found: ' . $autoloader );
    … …  
    518520            require_once( $autoloader );
    519521        }
    520         $config = HTMLPurifier_Config::createDefault();
     522        $config = MSHTMLPurifier_Config::createDefault();
    521523        // How to filter:
    522524        // add_filter('metaslider_html_purifier_config', function($config) {
    … …  
    526528        // });
    527529        $config   = apply_filters('metaslider_html_purifier_config', $config, $slide, $slider_id, $settings);
    528         $purifier = new HTMLPurifier( $config );
     530        $purifier = new MSHTMLPurifier( $config );
    529531        $content  = $purifier->purify( $content );
    530532    } catch ( Throwable $e ) {
  • ml-slider/trunk/inc/slide/metaslide.image.class.php

    r3700496 r3721894  
    11481148     *
    11491149     * @since 3.101
     1150     * @since 3.113.1 Placeholder generation moved to lazy_load_placeholder(), which
     1151     *                falls back to a 1x1 GIF instead of fataling on an unusable size
    11501152     */
    11511153    public function image_attributes( $attributes, $slide, $slider_id )
    … …  
    11641166            }
    11651167
    1166             try {
    1167                 $width  = $attributes['width'];
    1168                 $height = $attributes['height'];
    1169 
    1170                 // Create a blank image with lowest ratio
    1171                 for ( $i = $height; $i > 1; $i-- ) {
    1172                     if ( ( $width % $i ) == 0 && ( $height % $i ) == 0 ) {
    1173                         $width = $width / $i;
    1174                         $height = $height / $i;
    1175                     }
    1176                 }
    1177                 $image = imagecreatetruecolor( $width, $height );
    1178 
    1179                 // Make it transparent
    1180                 imagesavealpha( $image, true );
    1181                 imagealphablending( $image, false );
    1182                 $white = imagecolorallocatealpha( $image, 255, 255, 255, 127 );
    1183                 imagefill( $image, 0, 0, $white );
    1184 
    1185                 // Capture the image output
    1186                 ob_start();
    1187                     imagepng( $image );
    1188                     $contents = base64_encode( ob_get_contents() );
    1189                 ob_end_clean();
    1190 
    1191                 // Free up the memory
    1192                 imagedestroy( $image );
    1193             } catch ( Exception $e ) {
    1194                 // 1x1 pixel backup - Note: might need some creative CSS to make this work given the dimensions
    1195                 $contents = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
    1196             }
    1197 
    1198             // Convert to base64
    1199             $data_uri = "data:image/jpeg;base64," . $contents;
     1168            $data_uri = $this->lazy_load_placeholder( $attributes['width'], $attributes['height'] );
    12001169
    12011170            $attributes['data-ms-src'] = $attributes['src'];
    … …  
    12211190        return $attributes;
    12221191    }
     1192
     1193    /**
     1194     * Transparent placeholder image for lazy loading, as a data URI
     1195     *
     1196     * Falls back to a 1x1 transparent GIF when the slideshow has no usable width
     1197     * or height setting, when the ratio is too large to draw, or when GD is missing -
     1198     * PHP 8 raises an Error, not an Exception, for a non-numeric or zero size, so it
     1199     * can't be caught below (#2488)
     1200     *
     1201     * @since 3.113.1
     1202     *
     1203     * @param mixed $width  Width setting, may be empty or non-numeric
     1204     * @param mixed $height Height setting, may be empty or non-numeric
     1205     *
     1206     * @return string
     1207     */
     1208    public function lazy_load_placeholder( $width, $height )
     1209    {
     1210        // 1x1 pixel backup - Note: might need some creative CSS to make this work given the dimensions
     1211        $fallback = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
     1212
     1213        // A placeholder only carries the aspect ratio, so a larger one is a runaway
     1214        // setting - and allocating it exhausts memory, which PHP cannot catch
     1215        $max_pixels = 1000000;
     1216
     1217        $width  = is_numeric( $width ) ? absint( $width ) : 0;
     1218        $height = is_numeric( $height ) ? absint( $height ) : 0;
     1219
     1220        if ( $width < 1 || $height < 1 || ! function_exists( 'imagecreatetruecolor' ) ) {
     1221            return $fallback;
     1222        }
     1223
     1224        // Draw at the lowest ratio the size reduces to
     1225        $divisor = $this->greatest_common_divisor( $width, $height );
     1226        $width   = intdiv( $width, $divisor );
     1227        $height  = intdiv( $height, $divisor );
     1228
     1229        if ( ( $width * $height ) > $max_pixels ) {
     1230            return $fallback;
     1231        }
     1232
     1233        // Discard a half-filled output buffer if capturing the image throws
     1234        $ob_level = ob_get_level();
     1235
     1236        try {
     1237            $image = imagecreatetruecolor( $width, $height );
     1238
     1239            // Make it transparent
     1240            imagesavealpha( $image, true );
     1241            imagealphablending( $image, false );
     1242            $white = imagecolorallocatealpha( $image, 255, 255, 255, 127 );
     1243            imagefill( $image, 0, 0, $white );
     1244
     1245            // Capture the image output
     1246            ob_start();
     1247                imagepng( $image );
     1248                $contents = base64_encode( ob_get_contents() );
     1249            ob_end_clean();
     1250
     1251            // Free up the memory
     1252            imagedestroy( $image );
     1253        } catch ( Throwable $e ) {
     1254            while ( ob_get_level() > $ob_level ) {
     1255                ob_end_clean();
     1256            }
     1257
     1258            return $fallback;
     1259        }
     1260
     1261        return 'data:image/png;base64,' . $contents;
     1262    }
     1263
     1264    /**
     1265     * Greatest common divisor of two positive integers, used to reduce a
     1266     * placeholder to the lowest ratio it can be drawn at
     1267     *
     1268     * @since 3.113.1
     1269     *
     1270     * @param int $a First integer
     1271     * @param int $b Second integer
     1272     *
     1273     * @return int
     1274     */
     1275    private function greatest_common_divisor( $a, $b )
     1276    {
     1277        while ( $b ) {
     1278            $remainder = $a % $b;
     1279            $a = $b;
     1280            $b = $remainder;
     1281        }
     1282
     1283        return $a;
     1284    }
    12231285}
  • ml-slider/trunk/ml-slider.php

    r3700496 r3721894  
    66 * Plugin URI:  https://www.metaslider.com
    77 * Description: MetaSlider gives you the power to create a beautiful slideshow, carousel, or gallery on your WordPress site.
    8  * Version:     3.113.0
     8 * Version:     3.113.1
    99 * Author:      MetaSlider
    1010 * Author URI:  https://www.metaslider.com
    … …  
    4545         * @var string
    4646         */
    47         public $version = '3.113.0';
     47        public $version = '3.113.1';
    4848
    4949        /**
    … …  
    176176                $assets_version = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? uniqid() : $this->version;
    177177
    178                 define('METASLIDER_VERSION', '3.113.0');
     178                define('METASLIDER_VERSION', '3.113.1'); // We need it defined as string due `composer build` doesn't detect $this->version
    179179                define('METASLIDER_ASSETS_VERSION', $assets_version);
    180180                define('METASLIDER_BASE_URL', plugin_dir_url(metaslider_plugin_is_installed('ml-slider')));
Note: See TracChangeset for help on using the changeset viewer.