Plugin Directory

Changeset 2961119


Ignore:
Timestamp:
08/31/2023 11:29:07 AM (3 years ago)
Author:
EmranAhmed
Message:

Update to 2.0.25

Location:
woo-variation-swatches
Files:
61 added
12 edited

Legend:

Unmodified
Added
Removed
  • woo-variation-swatches/trunk/README.txt

    r2934413 r2961119  
    44Requires PHP: 7.0
    55Requires at least: 5.6
    6 Tested up to: 6.2
     6Tested up to: 6.3
    77WC requires at least: 5.6
    8 WC tested up to: 7.8
    9 Stable tag: 2.0.24
     8WC tested up to: 8.0
     9Stable tag: 2.0.25
    1010License: GPLv3
    1111License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    114114  [Live Demo & Documentation](http://j.mp/button-to-dropdown-readme)
    115115<hr />
    116 👉 Compatible With Eelementor Page Builder Plugin
     116👉 Compatible With Elementor Page Builder Plugin
    117117
    118118Elementor works well with all the themes and plugins which respect the coding. The WooCommerce Variation Swatches plugin is compatible with the Elementor page builder plugin.
     
    615615== Changelog ==
    616616
     617= 2.0.25 - 31-08-2023 =
     618
     619* Add: WordPress 6.3 compatibility
     620* Add: WooCommerce 8.0 compatibility
     621* Update: Color / Image data can update by API Request
     622
    617623= 2.0.24 - 05-07-2023 =
    618624
  • woo-variation-swatches/trunk/assets/css/admin.css

    r2934413 r2961119  
    33 *
    44 * Author: Emran Ahmed ( emran.bd.08@gmail.com )
    5  * Date: 7/5/2023, 4:48:58 PM
     5 * Date: 8/31/2023, 5:25:30 PM
    66 * Released under the GPLv3 license.
    77 */
  • woo-variation-swatches/trunk/assets/css/frontend.css

    r2934413 r2961119  
    33 *
    44 * Author: Emran Ahmed ( emran.bd.08@gmail.com )
    5  * Date: 7/5/2023, 4:48:58 PM
     5 * Date: 8/31/2023, 5:25:30 PM
    66 * Released under the GPLv3 license.
    77 */
  • woo-variation-swatches/trunk/assets/js/admin.js

    r2934413 r2961119  
    33 *
    44 * Author: Emran Ahmed ( emran.bd.08@gmail.com )
    5  * Date: 7/5/2023, 4:48:58 PM
     5 * Date: 8/31/2023, 5:25:30 PM
    66 * Released under the GPLv3 license.
    77 */
  • woo-variation-swatches/trunk/assets/js/frontend.js

    r2934413 r2961119  
    33 *
    44 * Author: Emran Ahmed ( emran.bd.08@gmail.com )
    5  * Date: 7/5/2023, 4:48:58 PM
     5 * Date: 8/31/2023, 5:25:30 PM
    66 * Released under the GPLv3 license.
    77 */
  • woo-variation-swatches/trunk/assets/js/wp-color-picker-alpha.js

    r2934413 r2961119  
    33 *
    44 * Author: Emran Ahmed ( emran.bd.08@gmail.com )
    5  * Date: 7/5/2023, 4:48:58 PM
     5 * Date: 8/31/2023, 5:25:30 PM
    66 * Released under the GPLv3 license.
    77 */
  • woo-variation-swatches/trunk/includes/class-woo-variation-swatches-backend.php

    r2920719 r2961119  
    175175               
    176176                wp_localize_script( 'woo-variation-swatches-admin', 'woo_variation_swatches_admin', array(
    177                     'media_title'   => esc_html__( 'Choose an Image', 'woo-variation-swatches' ),
    178                     'dialog_title'  => esc_html__( 'Add Attribute', 'woo-variation-swatches' ),
    179                     'dialog_save'   => esc_html__( 'Add', 'woo-variation-swatches' ),
    180                     'dialog_cancel' => esc_html__( 'Cancel', 'woo-variation-swatches' ),
    181                     'button_title'  => esc_html__( 'Use Image', 'woo-variation-swatches' ),
    182                     'add_media'     => esc_html__( 'Add Media', 'woo-variation-swatches' ),
    183                     'ajaxurl'       => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
    184                     'wc_ajax_url'   => WC_AJAX::get_endpoint( '%%endpoint%%' ),
    185                     'nonce'         => wp_create_nonce( 'woo_variation_swatches_admin' ),
    186                     'reset_notice'  => esc_html__( 'Are you sure you want to reset it to default setting?', 'woo-variation-swatches' ),
    187                     'nav_warning'   => esc_html__( 'Please save changed first.', 'woo-variation-swatches' ),
     177                    'media_title'    => esc_html__( 'Choose an Image', 'woo-variation-swatches' ),
     178                    'dialog_title'   => esc_html__( 'Add Attribute', 'woo-variation-swatches' ),
     179                    'dialog_save'    => esc_html__( 'Add', 'woo-variation-swatches' ),
     180                    'dialog_cancel'  => esc_html__( 'Cancel', 'woo-variation-swatches' ),
     181                    'button_title'   => esc_html__( 'Use Image', 'woo-variation-swatches' ),
     182                    'add_media'      => esc_html__( 'Add Media', 'woo-variation-swatches' ),
     183                    'ajaxurl'        => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
     184                    'wc_ajax_url'    => WC_AJAX::get_endpoint( '%%endpoint%%' ),
     185                    'settings_url'   => esc_url( $this->get_admin_menu()->get_settings_link( 'woo_variation_swatches' ) ),
     186                    'settings_title' => esc_html__( 'Variation Swatches Settings', 'woo-variation-swatches' ),
     187                    'nonce'          => wp_create_nonce( 'woo_variation_swatches_admin' ),
     188                    'reset_notice'   => esc_html__( 'Are you sure you want to reset it to default setting?', 'woo-variation-swatches' ),
     189                    'nav_warning'    => esc_html__( 'Please save changed first.', 'woo-variation-swatches' ),
    188190                ) );
    189191            }
  • woo-variation-swatches/trunk/includes/class-woo-variation-swatches-product-page.php

    r2934413 r2961119  
    204204                $this->add_inline_style();
    205205               
     206                $is_defer = is_wp_version_compatible( '6.3' ) ? array( 'strategy' => 'defer' ) : true;
     207               
    206208                wp_register_script( 'woo-variation-swatches', woo_variation_swatches()->assets_url( "/js/frontend{$suffix}.js" ), array(
    207209                    'jquery',
     
    213215                    'wp-polyfill',
    214216                    'wp-url'
    215                 ),                  woo_variation_swatches()->assets_version( "/js/frontend{$suffix}.js" ), true );
     217                ),                  woo_variation_swatches()->assets_version( "/js/frontend{$suffix}.js" ), $is_defer );
    216218               
    217219                $extra_params_for_rest_uri = apply_filters( 'woo_variation_swatches_rest_add_extra_params', array() );
  • woo-variation-swatches/trunk/includes/class-woo-variation-swatches-wc-api-response.php

    r2927482 r2961119  
    5050                $image_id = absint( get_term_meta( $term_id, 'product_attribute_image', true ) );
    5151               
    52                 $image_size       = sanitize_text_field( get_term_meta( $term_id, 'image_size', true ) );
     52                $image_size = sanitize_text_field( woo_variation_swatches()->get_option( 'attribute_image_size', 'variation_swatches_image_size' ) );
     53               
    5354                $show_tooltip     = sanitize_text_field( get_term_meta( $term_id, 'show_tooltip', true ) );
    5455                $tooltip_text     = sanitize_text_field( get_term_meta( $term_id, 'tooltip_text', true ) );
     
    8586            }
    8687           
    87             public function update_additional_response( $value, $object, $field_name ) {
     88           
     89            /**
     90             *
     91             * PUT Request: wp-json/wc/v3/products/attributes/<attribute_id>/terms/<id>
     92             *     DATA: JSON Object
     93             * {
     94             * "woo_variation_swatches": {
     95             *     "product_attribute_color": "" || "primary_color": ""
     96             *     "secondary_color": ""
     97             *     "is_dual_color": ""
     98             *     "product_attribute_image": "" || "image_id": ""
     99             * }
     100             * }
     101             */
     102           
     103            public function update_additional_response( $values, $WP_Term_object, $field_id ) {
     104               
     105                if ( empty( $values ) || ! is_array( $values ) || 'woo_variation_swatches' !== $field_id ) {
     106                    return;
     107                }
     108               
     109               
     110                $term_id = absint( $WP_Term_object->term_id );
     111               
     112               
     113                // Update Primary Color
     114                if ( array_key_exists( 'product_attribute_color', $values ) || array_key_exists( 'primary_color', $values ) ) {
     115                    $primary_color = ! empty( $values[ 'product_attribute_color' ] ) ? $values[ 'product_attribute_color' ] : $values[ 'primary_color' ];
     116                    update_term_meta( $term_id, 'product_attribute_color', sanitize_hex_color( $primary_color ) );
     117                }
     118               
     119                // Update Secondary Color
     120                if ( array_key_exists( 'secondary_color', $values ) ) {
     121                    $secondary_color = sanitize_hex_color( $values[ 'secondary_color' ] );
     122                    update_term_meta( $term_id, 'secondary_color', $secondary_color );
     123                }
     124               
     125                // Update Is Dual Color
     126                if ( array_key_exists( 'is_dual_color', $values ) ) {
     127                    $is_dual_color = wc_string_to_bool( $values[ 'is_dual_color' ] );
     128                    update_term_meta( $term_id, 'is_dual_color', $is_dual_color );
     129                }
     130               
     131                // Update Image ID
     132                if ( array_key_exists( 'product_attribute_image', $values ) || array_key_exists( 'image_id', $values ) ) {
     133                    $image_id = ! empty( $values[ 'product_attribute_image' ] ) ? $values[ 'product_attribute_image' ] : $values[ 'image_id' ];
     134                    update_term_meta( $term_id, 'product_attribute_image', absint( $image_id ) );
     135                }
     136               
     137               
     138                do_action( 'woo_variation_swatches_rest_attribute_term_additional_request', $values, $term_id, $WP_Term_object );
     139               
    88140                return null;
    89141            }
  • woo-variation-swatches/trunk/includes/class-woo-variation-swatches.php

    r2898048 r2961119  
    11<?php
    2 
    3 defined( 'ABSPATH' ) || exit;
    4 
    5 if ( ! class_exists( 'Woo_Variation_Swatches' ) ) {
    6 
    7     class Woo_Variation_Swatches {
    8 
    9         protected static $_instance = null;
    10 
    11         public function __construct() {
    12             $this->includes();
    13             $this->hooks();
    14             $this->init();
    15             do_action( 'woo_variation_swatches_loaded', $this );
    16         }
    17 
    18         public function version() {
    19             return esc_attr( WOO_VARIATION_SWATCHES_PLUGIN_VERSION );
    20         }
    21 
    22         protected function define( $name, $value ) {
    23             if ( ! defined( $name ) ) {
    24                 define( $name, $value );
    25             }
    26         }
    27 
    28         public static function instance() {
    29             if ( is_null( self::$_instance ) ) {
    30                 self::$_instance = new self();
    31             }
    32 
    33             return self::$_instance;
    34         }
    35 
    36         public function includes() {
    37 
    38             // Deprecated file: class-woo-variation-swatches-cache.php
    39             require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-cache.php';
    40             require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-manage-cache.php';
    41             require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-frontend.php';
    42             require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-backend.php';
    43             require_once dirname( __FILE__ ) . '/functions.php';
    44         }
    45 
    46         public function hooks() {
    47             // Register with hook
    48             add_action( 'init', array( $this, 'language' ), 1 );
    49             add_action( 'init', array( $this, 'add_image_sizes' ) );
    50             // [wvs_show_archive_variation product_id="ID"]
    51             add_shortcode( 'wvs_show_archive_variation', array( $this, 'show_archive_variation_shortcode' ) );
    52         }
    53 
    54         public function init() {
    55             $this->get_frontend();
    56             $this->get_backend();
    57             $this->get_cache();
    58         }
    59 
    60         public function get_frontend() {
    61             return Woo_Variation_Swatches_Frontend::instance();
    62         }
    63 
    64         public function get_backend() {
    65             return Woo_Variation_Swatches_Backend::instance();
    66         }
    67 
    68         public function show_archive_page_swatches() {
    69             return false;
    70         }
    71 
    72         public function show_archive_page_swatches_by_id( $product_id ) {
    73             return false;
    74         }
    75 
    76         public function show_archive_variation_shortcode( $raw_attributes = array() ) {
    77             return false;
    78         }
    79 
    80         public function add_image_sizes() {
    81             add_image_size( 'variation_swatches_image_size', 50, 50, 1 );
    82             add_image_size( 'variation_swatches_tooltip_size', 100, 100, 1 );
    83         }
    84 
    85         public function get_option( $option, $default = null ) {
    86 
    87             $cache_key   = $this->get_cache()->get_cache_key( 'global_settings' );
    88             $cache_group = 'woo_variation_swatches';
    89 
    90             if ( false === ( $options = wp_cache_get( $cache_key, $cache_group ) ) ) {
    91                 $options = GetWooPlugins_Admin_Settings::get_option( 'woo_variation_swatches' );
    92                 wp_cache_set( $cache_key, $options, $cache_group );
    93             }
    94 
    95             if ( current_theme_supports( 'woo_variation_swatches' ) ) {
    96                 $theme_support = get_theme_support( 'woo_variation_swatches' );
    97                 $default       = isset( $theme_support[0][ $option ] ) ? $theme_support[0][ $option ] : $default;
    98             }
    99 
    100             return isset( $options[ $option ] ) ? $options[ $option ] : $default;
    101         }
    102 
    103         public function get_options() {
    104             $options = GetWooPlugins_Admin_Settings::get_option( 'woo_variation_swatches' );
    105 
    106             return $options;
    107         }
    108 
    109         public function get_cache() {
    110             return Woo_Variation_Swatches_Manage_Cache::instance();
    111         }
    112 
    113         public function language() {
    114             load_plugin_textdomain( 'woo-variation-swatches', false, plugin_basename( dirname( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) ) . '/languages' );
    115         }
    116 
    117         public function basename() {
    118             return basename( dirname( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) );
    119         }
    120 
    121         public function plugin_basename() {
    122             return plugin_basename( WOO_VARIATION_SWATCHES_PLUGIN_FILE );
    123         }
    124 
    125         public function plugin_dirname() {
    126             return dirname( plugin_basename( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) );
    127         }
    128 
    129         public function plugin_path() {
    130             return untrailingslashit( plugin_dir_path( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) );
    131         }
    132 
    133         public function plugin_url() {
    134             return untrailingslashit( plugins_url( '/', WOO_VARIATION_SWATCHES_PLUGIN_FILE ) );
    135         }
    136 
    137         public function images_url( $file = '' ) {
    138             return untrailingslashit( plugin_dir_url( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) . 'images' ) . $file;
    139         }
    140 
    141         public function org_assets_url( $file = '' ) {
    142             return 'https://ps.w.org/woo-variation-swatches/assets' . $file . '?ver=' . $this->version();
    143         }
    144 
    145         public function assets_url( $file = '' ) {
    146             return untrailingslashit( plugin_dir_url( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) . 'assets' ) . $file;
    147         }
    148 
    149         public function assets_path( $file = '' ) {
    150             return $this->plugin_path() . '/assets' . $file;
    151         }
    152 
    153         public function assets_version( $file ) {
    154             return filemtime( $this->assets_path( $file ) );
    155         }
    156 
    157         public function include_path( $file = '' ) {
    158             return untrailingslashit( plugin_dir_path( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) . 'includes' ) . $file;
    159         }
    160 
    161         public function template_override_dir() {
    162             return apply_filters( 'woo_variation_swatches_override_dir', 'woo-variation-swatches' );
    163         }
    164 
    165         public function template_path() {
    166             return apply_filters( 'woo_variation_swatches_template_path', untrailingslashit( $this->plugin_path() ) . '/templates' );
    167         }
    168 
    169         public function template_url() {
    170             return apply_filters( 'woo_variation_swatches_template_url', untrailingslashit( $this->plugin_url() ) . '/templates' );
    171         }
    172 
    173         public function sanitize_name( $value ) {
    174             return wc_clean( rawurldecode( sanitize_title( wp_unslash( $value ) ) ) );
    175         }
    176 
    177         public function from_rgb_to_hex( $string ) {
    178             if ( strpos( $string, '#' ) === 0 ) {
    179                 return $string;
    180             }
    181 
    182             preg_match( '/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i', $string, $by_color );
    183 
    184             return sprintf( '#%02x%02x%02x', $by_color[1], $by_color[2], $by_color[3] );
    185         }
    186 
    187         public function locate_template( $template_name, $third_party_path = false ) {
    188 
    189             $template_name = ltrim( $template_name, '/' );
    190             $template_path = $this->template_override_dir();
    191             $default_path  = $this->template_path();
    192 
    193             if ( $third_party_path && is_string( $third_party_path ) ) {
    194                 $default_path = untrailingslashit( $third_party_path );
    195             }
    196 
    197             // Look within passed path within the theme - this is priority.
    198             $template = locate_template( array(
    199                 trailingslashit( $template_path ) . trim( $template_name ),
    200                 'wvs-template-' . trim( $template_name )
    201             ) );
    202 
    203             // Get default template/
    204             if ( empty( $template ) ) {
    205                 $template = trailingslashit( $default_path ) . trim( $template_name );
    206             }
    207 
    208             // Return what we found.
    209             return apply_filters( 'woo_variation_swatches_locate_template', $template, $template_name, $template_path );
    210         }
    211 
    212         public function get_template( $template_name, $template_args = array(), $third_party_path = false ) {
    213 
    214             $template_name = ltrim( $template_name, '/' );
    215 
    216             $located = apply_filters( 'woo_variation_swatches_get_template', $this->locate_template( $template_name, $third_party_path ) );
    217 
    218             do_action( 'woo_variation_swatches_before_get_template', $template_name, $template_args );
    219 
    220             extract( $template_args );
    221 
    222             if ( file_exists( $located ) ) {
    223                 include $located;
    224             } else {
    225                 trigger_error( sprintf( esc_html__( '"Variation Swatches for WooCommerce" Plugin try to load "%s" but template "%s" was not found.', 'woo-variation-swatches' ), $located, $template_name ), E_USER_WARNING );
    226             }
    227 
    228             do_action( 'woo_variation_swatches_after_get_template', $template_name, $template_args );
    229         }
    230 
    231         public function is_pro() {
    232             return false;
    233         }
    234 
    235         public function get_pro_product_id() {
    236             return 113;
    237         }
    238     }
    239 }
     2   
     3    defined( 'ABSPATH' ) || exit;
     4   
     5    if ( ! class_exists( 'Woo_Variation_Swatches' ) ) {
     6       
     7        class Woo_Variation_Swatches {
     8           
     9            protected static $_instance = null;
     10           
     11            public function __construct() {
     12                $this->includes();
     13                $this->hooks();
     14                $this->init();
     15                do_action( 'woo_variation_swatches_loaded', $this );
     16            }
     17           
     18            public function version() {
     19                return esc_attr( WOO_VARIATION_SWATCHES_PLUGIN_VERSION );
     20            }
     21           
     22            protected function define( $name, $value ) {
     23                if ( ! defined( $name ) ) {
     24                    define( $name, $value );
     25                }
     26            }
     27           
     28            public static function instance() {
     29                if ( is_null( self::$_instance ) ) {
     30                    self::$_instance = new self();
     31                }
     32               
     33                return self::$_instance;
     34            }
     35           
     36            public function includes() {
     37               
     38                // Deprecated file: class-woo-variation-swatches-cache.php
     39                require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-cache.php';
     40                require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-manage-cache.php';
     41                require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-frontend.php';
     42                require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-backend.php';
     43                require_once dirname( __FILE__ ) . '/class-woo-variation-swatches-blocks.php';
     44                require_once dirname( __FILE__ ) . '/functions.php';
     45            }
     46           
     47            public function hooks() {
     48                // Register with hook
     49                add_action( 'init', array( $this, 'language' ), 1 );
     50                add_action( 'init', array( $this, 'add_image_sizes' ) );
     51                // [wvs_show_archive_variation product_id="ID"]
     52                add_shortcode( 'wvs_show_archive_variation', array( $this, 'show_archive_variation_shortcode' ) );
     53            }
     54           
     55            public function init() {
     56                $this->get_frontend();
     57                $this->get_backend();
     58                $this->get_cache();
     59                $this->get_blocks();
     60            }
     61           
     62            public function get_frontend() {
     63                return Woo_Variation_Swatches_Frontend::instance();
     64            }
     65           
     66            public function get_backend() {
     67                return Woo_Variation_Swatches_Backend::instance();
     68            }
     69           
     70            public function get_blocks() {
     71                return Woo_Variation_Swatches_Blocks::instance();
     72            }
     73           
     74            public function show_archive_page_swatches() {
     75                return false;
     76            }
     77           
     78            public function show_archive_page_swatches_by_id( $product_id ) {
     79                return false;
     80            }
     81           
     82            public function show_archive_variation_shortcode( $raw_attributes = array() ) {
     83                return false;
     84            }
     85           
     86            public function add_image_sizes() {
     87                add_image_size( 'variation_swatches_image_size', 50, 50, 1 );
     88                add_image_size( 'variation_swatches_tooltip_size', 100, 100, 1 );
     89            }
     90           
     91            public function get_option( $option, $default = null ) {
     92               
     93                $cache_key   = $this->get_cache()->get_cache_key( 'global_settings' );
     94                $cache_group = 'woo_variation_swatches';
     95               
     96                if ( false === ( $options = wp_cache_get( $cache_key, $cache_group ) ) ) {
     97                    $options = GetWooPlugins_Admin_Settings::get_option( 'woo_variation_swatches' );
     98                    wp_cache_set( $cache_key, $options, $cache_group );
     99                }
     100               
     101                if ( current_theme_supports( 'woo_variation_swatches' ) ) {
     102                    $theme_support = get_theme_support( 'woo_variation_swatches' );
     103                    $default       = isset( $theme_support[ 0 ][ $option ] ) ? $theme_support[ 0 ][ $option ] : $default;
     104                }
     105               
     106                return isset( $options[ $option ] ) ? $options[ $option ] : $default;
     107            }
     108           
     109            public function get_options() {
     110                $options = GetWooPlugins_Admin_Settings::get_option( 'woo_variation_swatches' );
     111               
     112                return $options;
     113            }
     114           
     115            public function get_cache() {
     116                return Woo_Variation_Swatches_Manage_Cache::instance();
     117            }
     118           
     119            public function language() {
     120                load_plugin_textdomain( 'woo-variation-swatches', false, plugin_basename( dirname( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) ) . '/languages' );
     121            }
     122           
     123            public function basename() {
     124                return basename( dirname( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) );
     125            }
     126           
     127            public function plugin_basename() {
     128                return plugin_basename( WOO_VARIATION_SWATCHES_PLUGIN_FILE );
     129            }
     130           
     131            public function plugin_dirname() {
     132                return dirname( plugin_basename( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) );
     133            }
     134           
     135            public function plugin_path() {
     136                return untrailingslashit( plugin_dir_path( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) );
     137            }
     138           
     139            public function plugin_url() {
     140                return untrailingslashit( plugins_url( '/', WOO_VARIATION_SWATCHES_PLUGIN_FILE ) );
     141            }
     142           
     143            public function images_url( $file = '' ) {
     144                return untrailingslashit( plugin_dir_url( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) . 'images' ) . $file;
     145            }
     146           
     147            public function org_assets_url( $file = '' ) {
     148                return 'https://ps.w.org/woo-variation-swatches/assets' . $file . '?ver=' . $this->version();
     149            }
     150           
     151            public function assets_url( $file = '' ) {
     152                return untrailingslashit( plugin_dir_url( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) . 'assets' ) . $file;
     153            }
     154           
     155            public function assets_path( $file = '' ) {
     156                return $this->plugin_path() . '/assets' . $file;
     157            }
     158           
     159            public function assets_version( $file ) {
     160                return filemtime( $this->assets_path( $file ) );
     161            }
     162           
     163            public function include_path( $file = '' ) {
     164                return untrailingslashit( plugin_dir_path( WOO_VARIATION_SWATCHES_PLUGIN_FILE ) . 'includes' ) . $file;
     165            }
     166           
     167            public function template_override_dir() {
     168                return apply_filters( 'woo_variation_swatches_override_dir', 'woo-variation-swatches' );
     169            }
     170           
     171            public function template_path() {
     172                return apply_filters( 'woo_variation_swatches_template_path', untrailingslashit( $this->plugin_path() ) . '/templates' );
     173            }
     174           
     175            public function template_url() {
     176                return apply_filters( 'woo_variation_swatches_template_url', untrailingslashit( $this->plugin_url() ) . '/templates' );
     177            }
     178           
     179            public function sanitize_name( $value ) {
     180                return wc_clean( rawurldecode( sanitize_title( wp_unslash( $value ) ) ) );
     181            }
     182           
     183            public function from_rgb_to_hex( $string ) {
     184                if ( strpos( $string, '#' ) === 0 ) {
     185                    return $string;
     186                }
     187               
     188                preg_match( '/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i', $string, $by_color );
     189               
     190                return sprintf( '#%02x%02x%02x', $by_color[ 1 ], $by_color[ 2 ], $by_color[ 3 ] );
     191            }
     192           
     193            public function locate_template( $template_name, $third_party_path = false ) {
     194               
     195                $template_name = ltrim( $template_name, '/' );
     196                $template_path = $this->template_override_dir();
     197                $default_path  = $this->template_path();
     198               
     199                if ( $third_party_path && is_string( $third_party_path ) ) {
     200                    $default_path = untrailingslashit( $third_party_path );
     201                }
     202               
     203                // Look within passed path within the theme - this is priority.
     204                $template = locate_template( array(
     205                                                 trailingslashit( $template_path ) . trim( $template_name ),
     206                                                 'wvs-template-' . trim( $template_name )
     207                                             ) );
     208               
     209                // Get default template/
     210                if ( empty( $template ) ) {
     211                    $template = trailingslashit( $default_path ) . trim( $template_name );
     212                }
     213               
     214                // Return what we found.
     215                return apply_filters( 'woo_variation_swatches_locate_template', $template, $template_name, $template_path );
     216            }
     217           
     218            public function get_template( $template_name, $template_args = array(), $third_party_path = false ) {
     219               
     220                $template_name = ltrim( $template_name, '/' );
     221               
     222                $located = apply_filters( 'woo_variation_swatches_get_template', $this->locate_template( $template_name, $third_party_path ) );
     223               
     224                do_action( 'woo_variation_swatches_before_get_template', $template_name, $template_args );
     225               
     226                extract( $template_args );
     227               
     228                if ( file_exists( $located ) ) {
     229                    include $located;
     230                } else {
     231                    trigger_error( sprintf( esc_html__( '"Variation Swatches for WooCommerce" Plugin try to load "%s" but template "%s" was not found.', 'woo-variation-swatches' ), $located, $template_name ), E_USER_WARNING );
     232                }
     233               
     234                do_action( 'woo_variation_swatches_after_get_template', $template_name, $template_args );
     235            }
     236           
     237            public function is_pro() {
     238                return false;
     239            }
     240           
     241            public function get_pro_product_id() {
     242                return 113;
     243            }
     244        }
     245    }
  • woo-variation-swatches/trunk/languages/woo-variation-swatches.pot

    r2934413 r2961119  
    88"Content-Transfer-Encoding: 8bit\n"
    99"Language-Team: Emran Ahmed <emran.bd.08@gmail.com>\n"
    10 "POT-Creation-Date: 2023-07-05 10:48+0000\n"
     10"POT-Creation-Date: 2023-08-31 11:25+0000\n"
    1111"X-Poedit-Basepath: ..\n"
    1212"X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
     
    6060msgstr ""
    6161
    62 #: ../includes/class-woo-variation-swatches-backend.php:177, ../includes/class-woo-variation-swatches-backend.php:264
     62#: ../includes/class-woo-variation-swatches-backend.php:177, ../includes/class-woo-variation-swatches-backend.php:266
    6363msgid "Choose an Image"
    6464msgstr ""
     
    8585
    8686#: ../includes/class-woo-variation-swatches-backend.php:186
     87msgid "Variation Swatches Settings"
     88msgstr ""
     89
     90#: ../includes/class-woo-variation-swatches-backend.php:188
    8791msgid "Are you sure you want to reset it to default setting?"
    8892msgstr ""
    8993
    90 #: ../includes/class-woo-variation-swatches-backend.php:187
     94#: ../includes/class-woo-variation-swatches-backend.php:189
    9195msgid "Please save changed first."
    9296msgstr ""
    9397
    94 #: ../includes/class-woo-variation-swatches-backend.php:194
     98#: ../includes/class-woo-variation-swatches-backend.php:196
    9599msgid "Select"
    96100msgstr ""
    97101
    98 #: ../includes/class-woo-variation-swatches-backend.php:195, ../includes/class-woo-variation-swatches-backend.php:254
     102#: ../includes/class-woo-variation-swatches-backend.php:197, ../includes/class-woo-variation-swatches-backend.php:256
    99103msgid "Color"
    100104msgstr ""
    101105
    102 #: ../includes/class-woo-variation-swatches-backend.php:196, ../includes/class-woo-variation-swatches-backend.php:263
     106#: ../includes/class-woo-variation-swatches-backend.php:198, ../includes/class-woo-variation-swatches-backend.php:265
    103107msgid "Image"
    104108msgstr ""
    105109
    106 #: ../includes/class-woo-variation-swatches-backend.php:197
     110#: ../includes/class-woo-variation-swatches-backend.php:199
    107111msgid "Button"
    108112msgstr ""
    109113
    110 #: ../includes/class-woo-variation-swatches-backend.php:198
     114#: ../includes/class-woo-variation-swatches-backend.php:200
    111115msgid "Radio"
    112116msgstr ""
    113117
    114 #: ../includes/class-woo-variation-swatches-backend.php:206
     118#: ../includes/class-woo-variation-swatches-backend.php:208
    115119msgid "Mixed"
    116120msgstr ""
    117121
    118 #: ../includes/class-woo-variation-swatches-backend.php:255
     122#: ../includes/class-woo-variation-swatches-backend.php:257
    119123msgid "Choose a color"
    120124msgstr ""
     
    202206msgstr ""
    203207
    204 #: ../includes/class-woo-variation-swatches-product-page.php:804, ../includes/class-woo-variation-swatches-product-page.php:830
     208#: ../includes/class-woo-variation-swatches-product-page.php:806, ../includes/class-woo-variation-swatches-product-page.php:832
    205209msgid "Choose an option"
    206210msgstr ""
     
    710714msgstr ""
    711715
    712 #: ../includes/class-woo-variation-swatches.php:225
     716#: ../includes/class-woo-variation-swatches.php:231
    713717msgid "\"Variation Swatches for WooCommerce\" Plugin try to load \"%s\" but template \"%s\" was not found."
    714718msgstr ""
  • woo-variation-swatches/trunk/woo-variation-swatches.php

    r2934413 r2961119  
    55     * Description: Beautiful colors, images and buttons variation swatches for woocommerce product attributes. Requires WooCommerce 5.6+
    66     * Author: Emran Ahmed
    7      * Version: 2.0.24
     7     * Version: 2.0.25
    88     * Domain Path: /languages
    99     * Requires PHP: 7.0
    1010     * Requires at least: 5.6
    11      * Tested up to: 6.2
     11     * Tested up to: 6.3
    1212     * WC requires at least: 5.6
    13      * WC tested up to: 7.8
     13     * WC tested up to: 8.0
    1414     * Text Domain: woo-variation-swatches
    1515     * Author URI: https://getwooplugins.com/
     
    1919   
    2020    if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION' ) ) {
    21         define( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION', '2.0.24' );
     21        define( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION', '2.0.25' );
    2222    }
    2323   
Note: See TracChangeset for help on using the changeset viewer.