Changeset 2961119
- Timestamp:
- 08/31/2023 11:29:07 AM (3 years ago)
- Location:
- woo-variation-swatches
- Files:
-
- 61 added
- 12 edited
-
tags/2.0.25 (added)
-
tags/2.0.25/README.txt (added)
-
tags/2.0.25/assets (added)
-
tags/2.0.25/assets/css (added)
-
tags/2.0.25/assets/css/admin.css (added)
-
tags/2.0.25/assets/css/admin.min.css (added)
-
tags/2.0.25/assets/css/frontend.css (added)
-
tags/2.0.25/assets/css/frontend.min.css (added)
-
tags/2.0.25/assets/js (added)
-
tags/2.0.25/assets/js/admin.js (added)
-
tags/2.0.25/assets/js/admin.min.js (added)
-
tags/2.0.25/assets/js/frontend.js (added)
-
tags/2.0.25/assets/js/frontend.min.js (added)
-
tags/2.0.25/assets/js/jquery.serializejson.js (added)
-
tags/2.0.25/assets/js/jquery.serializejson.min.js (added)
-
tags/2.0.25/assets/js/wp-color-picker-alpha.js (added)
-
tags/2.0.25/assets/js/wp-color-picker-alpha.min.js (added)
-
tags/2.0.25/images (added)
-
tags/2.0.25/images/placeholder.png (added)
-
tags/2.0.25/includes (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-backend.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-blocks.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-cache.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-compatibility.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-deactivate-feedback.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-export-import.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-frontend.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-manage-cache.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-product-edit-panel.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-product-page.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-settings.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-term-meta.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches-wc-api-response.php (added)
-
tags/2.0.25/includes/class-woo-variation-swatches.php (added)
-
tags/2.0.25/includes/functions.php (added)
-
tags/2.0.25/includes/getwooplugins (added)
-
tags/2.0.25/includes/getwooplugins/class-getwooplugins-admin-menus.php (added)
-
tags/2.0.25/includes/getwooplugins/class-getwooplugins-admin-settings.php (added)
-
tags/2.0.25/includes/getwooplugins/class-getwooplugins-plugin-deactivate-feedback.php (added)
-
tags/2.0.25/includes/getwooplugins/class-getwooplugins-settings-page.php (added)
-
tags/2.0.25/includes/getwooplugins/css (added)
-
tags/2.0.25/includes/getwooplugins/css/getwooplugins-settings.css (added)
-
tags/2.0.25/includes/getwooplugins/html (added)
-
tags/2.0.25/includes/getwooplugins/html/deactive-feedback-dialog.php (added)
-
tags/2.0.25/includes/getwooplugins/html/dialog.php (added)
-
tags/2.0.25/includes/getwooplugins/html/settings-page.php (added)
-
tags/2.0.25/includes/getwooplugins/js (added)
-
tags/2.0.25/includes/getwooplugins/js/getwooplugins-form-field-dependency.js (added)
-
tags/2.0.25/includes/getwooplugins/js/getwooplugins-settings.js (added)
-
tags/2.0.25/includes/getwooplugins/js/jquery.tipTip.js (added)
-
tags/2.0.25/includes/getwooplugins/js/wp-color-picker-alpha.js (added)
-
tags/2.0.25/includes/html-product-settings-panel.php (added)
-
tags/2.0.25/includes/html-settings-group.php (added)
-
tags/2.0.25/includes/html-settings-sidebar.php (added)
-
tags/2.0.25/includes/html-settings-tutorial.php (added)
-
tags/2.0.25/includes/themes-support.php (added)
-
tags/2.0.25/languages (added)
-
tags/2.0.25/languages/woo-variation-swatches.pot (added)
-
tags/2.0.25/uninstall.php (added)
-
tags/2.0.25/woo-variation-swatches.php (added)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/assets/css/admin.css (modified) (1 diff)
-
trunk/assets/css/frontend.css (modified) (1 diff)
-
trunk/assets/js/admin.js (modified) (1 diff)
-
trunk/assets/js/frontend.js (modified) (1 diff)
-
trunk/assets/js/wp-color-picker-alpha.js (modified) (1 diff)
-
trunk/includes/class-woo-variation-swatches-backend.php (modified) (1 diff)
-
trunk/includes/class-woo-variation-swatches-blocks.php (added)
-
trunk/includes/class-woo-variation-swatches-product-page.php (modified) (2 diffs)
-
trunk/includes/class-woo-variation-swatches-wc-api-response.php (modified) (2 diffs)
-
trunk/includes/class-woo-variation-swatches.php (modified) (1 diff)
-
trunk/languages/woo-variation-swatches.pot (modified) (5 diffs)
-
trunk/woo-variation-swatches.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-variation-swatches/trunk/README.txt
r2934413 r2961119 4 4 Requires PHP: 7.0 5 5 Requires at least: 5.6 6 Tested up to: 6. 26 Tested up to: 6.3 7 7 WC requires at least: 5.6 8 WC tested up to: 7.89 Stable tag: 2.0.2 48 WC tested up to: 8.0 9 Stable tag: 2.0.25 10 10 License: GPLv3 11 11 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 114 114 [Live Demo & Documentation](http://j.mp/button-to-dropdown-readme) 115 115 <hr /> 116 👉 Compatible With E elementor Page Builder Plugin116 👉 Compatible With Elementor Page Builder Plugin 117 117 118 118 Elementor 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. … … 615 615 == Changelog == 616 616 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 617 623 = 2.0.24 - 05-07-2023 = 618 624 -
woo-variation-swatches/trunk/assets/css/admin.css
r2934413 r2961119 3 3 * 4 4 * Author: Emran Ahmed ( emran.bd.08@gmail.com ) 5 * Date: 7/5/2023, 4:48:58PM5 * Date: 8/31/2023, 5:25:30 PM 6 6 * Released under the GPLv3 license. 7 7 */ -
woo-variation-swatches/trunk/assets/css/frontend.css
r2934413 r2961119 3 3 * 4 4 * Author: Emran Ahmed ( emran.bd.08@gmail.com ) 5 * Date: 7/5/2023, 4:48:58PM5 * Date: 8/31/2023, 5:25:30 PM 6 6 * Released under the GPLv3 license. 7 7 */ -
woo-variation-swatches/trunk/assets/js/admin.js
r2934413 r2961119 3 3 * 4 4 * Author: Emran Ahmed ( emran.bd.08@gmail.com ) 5 * Date: 7/5/2023, 4:48:58PM5 * Date: 8/31/2023, 5:25:30 PM 6 6 * Released under the GPLv3 license. 7 7 */ -
woo-variation-swatches/trunk/assets/js/frontend.js
r2934413 r2961119 3 3 * 4 4 * Author: Emran Ahmed ( emran.bd.08@gmail.com ) 5 * Date: 7/5/2023, 4:48:58PM5 * Date: 8/31/2023, 5:25:30 PM 6 6 * Released under the GPLv3 license. 7 7 */ -
woo-variation-swatches/trunk/assets/js/wp-color-picker-alpha.js
r2934413 r2961119 3 3 * 4 4 * Author: Emran Ahmed ( emran.bd.08@gmail.com ) 5 * Date: 7/5/2023, 4:48:58PM5 * Date: 8/31/2023, 5:25:30 PM 6 6 * Released under the GPLv3 license. 7 7 */ -
woo-variation-swatches/trunk/includes/class-woo-variation-swatches-backend.php
r2920719 r2961119 175 175 176 176 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' ), 188 190 ) ); 189 191 } -
woo-variation-swatches/trunk/includes/class-woo-variation-swatches-product-page.php
r2934413 r2961119 204 204 $this->add_inline_style(); 205 205 206 $is_defer = is_wp_version_compatible( '6.3' ) ? array( 'strategy' => 'defer' ) : true; 207 206 208 wp_register_script( 'woo-variation-swatches', woo_variation_swatches()->assets_url( "/js/frontend{$suffix}.js" ), array( 207 209 'jquery', … … 213 215 'wp-polyfill', 214 216 '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 ); 216 218 217 219 $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 50 50 $image_id = absint( get_term_meta( $term_id, 'product_attribute_image', true ) ); 51 51 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 53 54 $show_tooltip = sanitize_text_field( get_term_meta( $term_id, 'show_tooltip', true ) ); 54 55 $tooltip_text = sanitize_text_field( get_term_meta( $term_id, 'tooltip_text', true ) ); … … 85 86 } 86 87 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 88 140 return null; 89 141 } -
woo-variation-swatches/trunk/includes/class-woo-variation-swatches.php
r2898048 r2961119 1 1 <?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 8 8 "Content-Transfer-Encoding: 8bit\n" 9 9 "Language-Team: Emran Ahmed <emran.bd.08@gmail.com>\n" 10 "POT-Creation-Date: 2023-0 7-05 10:48+0000\n"10 "POT-Creation-Date: 2023-08-31 11:25+0000\n" 11 11 "X-Poedit-Basepath: ..\n" 12 12 "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" … … 60 60 msgstr "" 61 61 62 #: ../includes/class-woo-variation-swatches-backend.php:177, ../includes/class-woo-variation-swatches-backend.php:26 462 #: ../includes/class-woo-variation-swatches-backend.php:177, ../includes/class-woo-variation-swatches-backend.php:266 63 63 msgid "Choose an Image" 64 64 msgstr "" … … 85 85 86 86 #: ../includes/class-woo-variation-swatches-backend.php:186 87 msgid "Variation Swatches Settings" 88 msgstr "" 89 90 #: ../includes/class-woo-variation-swatches-backend.php:188 87 91 msgid "Are you sure you want to reset it to default setting?" 88 92 msgstr "" 89 93 90 #: ../includes/class-woo-variation-swatches-backend.php:18 794 #: ../includes/class-woo-variation-swatches-backend.php:189 91 95 msgid "Please save changed first." 92 96 msgstr "" 93 97 94 #: ../includes/class-woo-variation-swatches-backend.php:19 498 #: ../includes/class-woo-variation-swatches-backend.php:196 95 99 msgid "Select" 96 100 msgstr "" 97 101 98 #: ../includes/class-woo-variation-swatches-backend.php:19 5, ../includes/class-woo-variation-swatches-backend.php:254102 #: ../includes/class-woo-variation-swatches-backend.php:197, ../includes/class-woo-variation-swatches-backend.php:256 99 103 msgid "Color" 100 104 msgstr "" 101 105 102 #: ../includes/class-woo-variation-swatches-backend.php:19 6, ../includes/class-woo-variation-swatches-backend.php:263106 #: ../includes/class-woo-variation-swatches-backend.php:198, ../includes/class-woo-variation-swatches-backend.php:265 103 107 msgid "Image" 104 108 msgstr "" 105 109 106 #: ../includes/class-woo-variation-swatches-backend.php:19 7110 #: ../includes/class-woo-variation-swatches-backend.php:199 107 111 msgid "Button" 108 112 msgstr "" 109 113 110 #: ../includes/class-woo-variation-swatches-backend.php: 198114 #: ../includes/class-woo-variation-swatches-backend.php:200 111 115 msgid "Radio" 112 116 msgstr "" 113 117 114 #: ../includes/class-woo-variation-swatches-backend.php:20 6118 #: ../includes/class-woo-variation-swatches-backend.php:208 115 119 msgid "Mixed" 116 120 msgstr "" 117 121 118 #: ../includes/class-woo-variation-swatches-backend.php:25 5122 #: ../includes/class-woo-variation-swatches-backend.php:257 119 123 msgid "Choose a color" 120 124 msgstr "" … … 202 206 msgstr "" 203 207 204 #: ../includes/class-woo-variation-swatches-product-page.php:80 4, ../includes/class-woo-variation-swatches-product-page.php:830208 #: ../includes/class-woo-variation-swatches-product-page.php:806, ../includes/class-woo-variation-swatches-product-page.php:832 205 209 msgid "Choose an option" 206 210 msgstr "" … … 710 714 msgstr "" 711 715 712 #: ../includes/class-woo-variation-swatches.php:2 25716 #: ../includes/class-woo-variation-swatches.php:231 713 717 msgid "\"Variation Swatches for WooCommerce\" Plugin try to load \"%s\" but template \"%s\" was not found." 714 718 msgstr "" -
woo-variation-swatches/trunk/woo-variation-swatches.php
r2934413 r2961119 5 5 * Description: Beautiful colors, images and buttons variation swatches for woocommerce product attributes. Requires WooCommerce 5.6+ 6 6 * Author: Emran Ahmed 7 * Version: 2.0.2 47 * Version: 2.0.25 8 8 * Domain Path: /languages 9 9 * Requires PHP: 7.0 10 10 * Requires at least: 5.6 11 * Tested up to: 6. 211 * Tested up to: 6.3 12 12 * WC requires at least: 5.6 13 * WC tested up to: 7.813 * WC tested up to: 8.0 14 14 * Text Domain: woo-variation-swatches 15 15 * Author URI: https://getwooplugins.com/ … … 19 19 20 20 if ( ! defined( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION' ) ) { 21 define( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION', '2.0.2 4' );21 define( 'WOO_VARIATION_SWATCHES_PLUGIN_VERSION', '2.0.25' ); 22 22 } 23 23
Note: See TracChangeset
for help on using the changeset viewer.