Plugin Directory

Changeset 3067351


Ignore:
Timestamp:
04/09/2024 07:43:26 AM (2 years ago)
Author:
sayful
Message:

Add new version 2.2.10 of Carousel Slider

Location:
carousel-slider/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • carousel-slider/trunk/carousel-slider.php

    r3066158 r3067351  
    44 * Plugin URI: https://sayfulislam.com/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash
    55 * Description: <strong>Carousel Slider</strong> allows you to create beautiful, touch enabled, responsive carousels and sliders. It let you create SEO friendly Image carousel from Media Library or from custom URL, Video carousel using Youtube and Vimeo video, Post carousel, Hero banner slider and various types of WooCommerce products carousels.
    6  * Version: 2.2.9
     6 * Version: 2.2.10
    77 * Author: Sayful Islam
    88 * Author URI: https://sayfulislam.com/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash
     
    5353         * @var string
    5454         */
    55         private $version = '2.2.9';
     55        private $version = '2.2.10';
    5656
    5757        /**
  • carousel-slider/trunk/includes/Supports/Sanitize.php

    r2994748 r3067351  
    1313     * Sanitize number options.
    1414     *
    15      * @param mixed $value The value to be sanitized.
     15     * @param  mixed  $value The value to be sanitized.
    1616     *
    1717     * @return int|float
     
    3232     * Sanitize float number
    3333     *
    34      * @param mixed $value The value to be sanitized.
     34     * @param  mixed  $value The value to be sanitized.
    3535     *
    3636     * @return float
     
    4747     * Sanitize integer number
    4848     *
    49      * @param mixed $value The value to be sanitized.
     49     * @param  mixed  $value The value to be sanitized.
    5050     *
    5151     * @return int
     
    6262     * Sanitize email
    6363     *
    64      * @param mixed $value The value to be sanitized.
     64     * @param  mixed  $value The value to be sanitized.
    6565     *
    6666     * @return string
     
    7373     * Sanitize url
    7474     *
    75      * @param mixed $value The value to be sanitized.
     75     * @param  mixed  $value The value to be sanitized.
    7676     *
    7777     * @return string
     
    9090     * - Strips octets
    9191     *
    92      * @param mixed $value The value to be sanitized.
     92     * @param  mixed  $value The value to be sanitized.
    9393     *
    9494     * @return string
     
    105105     * input in textarea elements.
    106106     *
    107      * @param mixed $value The value to be sanitized.
     107     * @param  mixed  $value The value to be sanitized.
    108108     *
    109109     * @return string
     
    118118     * This can be used for determining if an HTML checkbox has been checked.
    119119     *
    120      * @param mixed $value The value to be sanitized.
     120     * @param  mixed  $value The value to be sanitized.
    121121     *
    122122     * @return mixed|boolean|string
     
    132132     * Check if the given input is a valid date.
    133133     *
    134      * @param mixed $value The value to be sanitized.
     134     * @param  mixed  $value The value to be sanitized.
    135135     *
    136136     * @return boolean
     
    149149     * Sanitize short block html input
    150150     *
    151      * @param mixed $value The value to be sanitized.
     151     * @param  mixed  $value The value to be sanitized.
    152152     *
    153153     * @return string
     
    160160     * Sanitize colors.
    161161     *
    162      * @param mixed $value The color.
     162     * @param  mixed  $value The color.
    163163     *
    164164     * @return string
     
    174174
    175175        // This pattern will check and match 3/6/8-character hex, rgb, rgba, hsl, & hsla colors.
    176         $pattern  = '/^(\#[\da-f]{3}|\#[\da-f]{6}|\#[\da-f]{8}|';
     176        $pattern = '/^(\#[\da-f]{3}|\#[\da-f]{6}|\#[\da-f]{8}|';
    177177        $pattern .= 'rgba\(((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*,\s*){2}((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*)(,\s*(0\.\d+|1))\)|';
    178178        $pattern .= 'hsla\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|';
     
    193193     * Sanitize meta value
    194194     *
    195      * @param mixed $value The value to be sanitized.
     195     * @param  mixed  $value The value to be sanitized.
    196196     *
    197197     * @return mixed
     
    222222     * Sanitize array of integer
    223223     *
    224      * @param mixed $value The value to be sanitized.
     224     * @param  mixed  $value The value to be sanitized.
    225225     *
    226226     * @return array
     
    233233        return map_deep( $value, 'intval' );
    234234    }
     235
     236    /**
     237     * Sanitizes css dimensions.
     238     *
     239     * @param  mixed  $value  The value to be sanitized.
     240     *
     241     * @return string
     242     */
     243    public static function css_dimension( $value ): string {
     244        if ( ! ( is_string( $value ) || is_numeric( $value ) ) ) {
     245            return '';
     246        }
     247        // Trim it.
     248        $value = trim( $value );
     249
     250        // If the value is round, then return 50%.
     251        if ( 'round' === $value ) {
     252            $value = '50%';
     253        }
     254
     255        // If the value is empty, return empty.
     256        if ( '' === $value ) {
     257            return '';
     258        }
     259
     260        // If auto, inherit or initial, return the value.
     261        if ( 'auto' === $value || 'initial' === $value || 'inherit' === $value ) {
     262            return $value;
     263        }
     264
     265        // Return empty if there are no numbers in the value.
     266        if ( ! preg_match( '#[0-9]#', $value ) ) {
     267            return '';
     268        }
     269
     270        // The raw value without the units.
     271        $raw_value = filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
     272        $unit_used = '';
     273
     274        // An array of all valid CSS units. Their order was carefully chosen for this evaluation, don't mix it up!!!
     275        $units = array(
     276            'rem',
     277            'em',
     278            'ex',
     279            '%',
     280            'px',
     281            'cm',
     282            'mm',
     283            'in',
     284            'pt',
     285            'pc',
     286            'ch',
     287            'vh',
     288            'vw',
     289            'vmin',
     290            'vmax',
     291        );
     292        foreach ( $units as $unit ) {
     293            if ( false !== strpos( $value, $unit ) ) {
     294                $unit_used = $unit;
     295            }
     296        }
     297
     298        // Hack for rem values.
     299        if ( 'em' === $unit_used && false !== strpos( $value, 'rem' ) ) {
     300            $unit_used = 'rem';
     301        }
     302
     303        return $raw_value . $unit_used;
     304    }
    235305}
  • carousel-slider/trunk/modules/HeroCarousel/Admin.php

    r2994748 r3067351  
    842842                    'left'   => '1rem',
    843843                ],
     844                'input_attributes' => [
     845                    'value' => isset( $content_settings['slide_padding'] ) && is_array( $content_settings['slide_padding'] ) ?
     846                        $content_settings['slide_padding'] : [],
     847                ],
    844848            ]
    845849        );
  • carousel-slider/trunk/modules/HeroCarousel/Item.php

    r2994748 r3067351  
    8484     * Class constructor.
    8585     *
    86      * @param array $args Optional arguments.
    87      * @param array $slider_settings Slider settings.
     86     * @param  array  $args Optional arguments.
     87     * @param  array  $slider_settings Slider settings.
    8888     */
    8989    public function __construct( array $args = [], array $slider_settings = [] ) {
     
    104104     * Set setting
    105105     *
    106      * @param Setting|SliderSetting $setting The SliderSetting object.
     106     * @param  Setting|SliderSetting  $setting The SliderSetting object.
    107107     */
    108108    public function set_setting( Setting $setting ) {
     
    123123     * Get default value
    124124     *
    125      * @param string $key Props key.
    126      * @param mixed $default Default value.
     125     * @param  string  $key Props key.
     126     * @param  mixed  $default Default value.
    127127     *
    128128     * @return mixed|string
     
    135135     * Sanitize item data
    136136     *
    137      * @param array $data The data to be sanitized.
     137     * @param  array  $data The data to be sanitized.
    138138     *
    139139     * @return array
     
    262262            'left'   => '3rem',
    263263        ];
    264         $slide_padding = isset( $this->slider_settings['slide_padding'] ) && is_array( $this->slider_settings['slide_padding'] ) ?
    265             $this->slider_settings['slide_padding'] : [];
     264        $slide_padding = [];
     265        if ( isset( $this->slider_settings['slide_padding'] ) && is_array( $this->slider_settings['slide_padding'] ) ) {
     266            foreach ( $this->slider_settings['slide_padding'] as $position => $value ) {
     267                if ( array_key_exists( $position, $default ) ) {
     268                    $slide_padding[ $position ] = $value;
     269                }
     270            }
     271        }
    266272
    267273        return wp_parse_args( $slide_padding, $default );
     
    422428
    423429        $styles = [
    424             'padding-top'    => $slide_padding['top'],
    425             'padding-right'  => $slide_padding['right'],
    426             'padding-bottom' => $slide_padding['bottom'],
    427             'padding-left'   => $slide_padding['left'],
     430            'padding-top'    => esc_attr( $slide_padding['top'] ),
     431            'padding-right'  => esc_attr( $slide_padding['right'] ),
     432            'padding-bottom' => esc_attr( $slide_padding['bottom'] ),
     433            'padding-left'   => esc_attr( $slide_padding['left'] ),
    428434        ];
    429435
     
    571577        }
    572578
    573         return '<' . ( $is_full_link ? 'a' : 'div' ) . ' ' . join( ' ', Helper::array_to_attribute( $cell_attr ) ) . '>';
     579        return '<' . ( $is_full_link ? 'a' : 'div' ) . ' ' . join( ' ',
     580                Helper::array_to_attribute( $cell_attr ) ) . '>';
    574581    }
    575582
  • carousel-slider/trunk/modules/HeroCarousel/Module.php

    r2994748 r3067351  
    44
    55use CarouselSlider\Helper;
     6use CarouselSlider\Supports\Sanitize;
    67
    78defined( 'ABSPATH' ) || exit;
     
    4546     * Register view for hero carousel
    4647     *
    47      * @param array $views List of views.
     48     * @param  array  $views List of views.
    4849     *
    4950     * @return array
     
    5859     * Save slider content and settings
    5960     *
    60      * @param int $slider_id The slider id.
    61      * @param array $data User submitted data.
     61     * @param  int  $slider_id The slider id.
     62     * @param  array  $data User submitted data.
    6263     */
    6364    public function save_slider( int $slider_id, array $data ) {
     
    7677        }
    7778
    78         if ( isset( $data['content_settings'] ) ) {
    79             $this->update_content_settings( $slider_id );
     79        if ( isset( $data['content_settings'] ) && is_array( $data['content_settings'] ) ) {
     80            $this->update_content_settings( $slider_id, $data['content_settings'] );
    8081        }
    8182    }
     
    8485     * Update hero carousel settings
    8586     *
    86      * @param int $post_id post id.
     87     * @param  int  $post_id post id.
    8788     */
    88     private function update_content_settings( int $post_id ) {
    89         // phpcs:ignore WordPress.Security.NonceVerification.Missing
    90         $setting   = $_POST['content_settings'] ?? [];
     89    private function update_content_settings( int $post_id, array $setting ) {
    9190        $_settings = [
    92             'slide_height'      => sanitize_text_field( $setting['slide_height'] ),
    93             'content_width'     => sanitize_text_field( $setting['content_width'] ),
     91            'slide_height'      => Sanitize::css_dimension( $setting['slide_height'] ),
     92            'content_width'     => Sanitize::css_dimension( $setting['content_width'] ),
    9493            'content_animation' => sanitize_text_field( $setting['content_animation'] ),
    9594            'slide_padding'     => [
    96                 'top'    => sanitize_text_field( $setting['slide_padding']['top'] ),
    97                 'right'  => sanitize_text_field( $setting['slide_padding']['right'] ),
    98                 'bottom' => sanitize_text_field( $setting['slide_padding']['bottom'] ),
    99                 'left'   => sanitize_text_field( $setting['slide_padding']['left'] ),
     95                'top'    => Sanitize::css_dimension( $setting['slide_padding']['top'] ),
     96                'right'  => Sanitize::css_dimension( $setting['slide_padding']['right'] ),
     97                'bottom' => Sanitize::css_dimension( $setting['slide_padding']['bottom'] ),
     98                'left'   => Sanitize::css_dimension( $setting['slide_padding']['left'] ),
    10099            ],
    101100        ];
  • carousel-slider/trunk/readme.txt

    r3066158 r3067351  
    44Tags: carousel, carousel slider, image carousel, product carousel, slider
    55Requires at least: 5.6
    6 Tested up to: 6.4
     6Tested up to: 6.5
    77Requires PHP: 7.0
    8 Stable tag: 2.2.8
     8Stable tag: 2.2.10
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.txt
     
    9797== Changelog ==
    9898
     99= version 2.2.10 - 2024-04-09 =
     100* Fix - Fix XSS security vulnerability from slide edit page.
     101
    99102= version 2.2.9 - 2024-04-07 =
    100103* Dev - Update compatibility with WooCommerce High-Performance Order Storage.
Note: See TracChangeset for help on using the changeset viewer.