From 01b1322c47779d4d87077d8faff27cdbad2f6d57 Mon Sep 17 00:00:00 2001 From: Beka Rice Date: Thu, 13 Jul 2017 13:39:06 -0400 Subject: [PATCH 1/4] Update grunt wp_deploy --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fae10dd..4ae8a77 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "grunt-contrib-copy": "~0.5.0", "grunt-newer": "~0.7.0", "grunt-notify": "~0.3.0", - "grunt-wp-deploy": "~1.1.0", + "grunt-wp-deploy": "~1.2.1", "grunt-wp-i18n": "~0.4.5", "load-grunt-tasks": "~0.6.0", "time-grunt": "~0.4.0", From 9b5deda42f71e7fbc8af70facfa1088cb3396c20 Mon Sep 17 00:00:00 2001 From: Beka Rice Date: Thu, 13 Jul 2017 13:40:06 -0400 Subject: [PATCH 2/4] Clean up customize_woocommerce_sale_flash() method duplication --- woocommerce-customizer.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/woocommerce-customizer.php b/woocommerce-customizer.php index f7f605e..8ca3c3b 100644 --- a/woocommerce-customizer.php +++ b/woocommerce-customizer.php @@ -359,36 +359,26 @@ public function customize_add_to_cart_text( $text, $product ) { */ public function customize_woocommerce_sale_flash( $html, $_, $product ) { + $text = ''; + if ( is_product() && isset( $this->filters['single_sale_flash_text'] ) ) { $text = $this->filters['single_sale_flash_text']; - // only get sales percentages when we should be replacing text - // check "false" specifically since the position could be 0 - if ( false !== strpos( $text, '{percent}' ) ) { - - $percent = $this->get_sale_percentage( $product ); - $text = str_replace( '{percent}', "{$percent}%", $text ); - } - - $html = "{$text}"; - } elseif ( ! is_product() && isset( $this->filters['loop_sale_flash_text'] ) ) { $text = $this->filters['loop_sale_flash_text']; + } - // only check for sales percentages when we should be replacing text - // check "false" specifically since the position could be 0 - if ( false !== strpos( $text, '{percent}' ) ) { - - $percent = $this->get_sale_percentage( $product ); - $text = str_replace( '{percent}', "{$percent}%", $text ); - } + // only get sales percentages when we should be replacing text + // check "false" specifically since the position could be 0 + if ( false !== strpos( $text, '{percent}' ) ) { - $html = "{$text}"; + $percent = $this->get_sale_percentage( $product ); + $text = str_replace( '{percent}', "{$percent}%", $text ); } - return $html; + return ! empty( $text ) ? "{$text}" : $html; } From b5c76a7bf1ca7fce1e4e7877e3a8f01395876493 Mon Sep 17 00:00:00 2001 From: Beka Rice Date: Thu, 13 Jul 2017 13:40:59 -0400 Subject: [PATCH 3/4] [#26] Change customization priorities to be hooked in later Closes #26 --- package.json | 2 +- readme.txt | 9 ++++++--- woocommerce-customizer.php | 12 ++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 4ae8a77..68821a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "woocommerce-customizer", - "version": "2.4.0", + "version": "2.5.1-dev", "author": "SkyVerge", "homepage": "http://www.skyverge.com", "repository": { diff --git a/readme.txt b/readme.txt index f009663..beed875 100644 --- a/readme.txt +++ b/readme.txt @@ -3,10 +3,10 @@ Contributors: SkyVerge, maxrice, tamarazuk, chasewiseman, nekojira, beka.rice Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@skyverge.com&item_name=Donation+for+WooCommerce+Customizer Tags: woocommerce, woocommerce shop, woocommerce filters, woocommerce text Requires at least: 4.1 -Tested up to: 4.7.4 +Tested up to: 4.8 WC requires at least: 2.5.5 -WC tested up to: 3.0.7 -Stable tag: 2.5.0 +WC tested up to: 3.1.1 +Stable tag: 2.5.1-dev License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -73,6 +73,9 @@ Of course! Please fork the [GitHub](https://github.com/skyverge/woocommerce-cust == Changelog == += 2.5.1-dev = +* Tweak - Hook customizations later to be more aggressive about using WC Customizer values rather than filters from other plugins or themes + = 2.5.0 = * Feature - Added sales badge text customization diff --git a/woocommerce-customizer.php b/woocommerce-customizer.php index 8ca3c3b..51e1d6e 100644 --- a/woocommerce-customizer.php +++ b/woocommerce-customizer.php @@ -5,7 +5,7 @@ * Description: Customize WooCommerce without code! Easily change add to cart button text and more. * Author: SkyVerge * Author URI: http://www.skyverge.com - * Version: 2.5.0 + * Version: 2.5.1-dev * Text Domain: woocommerce-customizer * Domain Path: /i18n/languages/ * @@ -111,7 +111,7 @@ class WC_Customizer { /** plugin version number */ - const VERSION = '2.5.0'; + const VERSION = '2.5.1-dev'; /** @var \WC_Customizer single instance of this plugin */ protected static $instance; @@ -208,18 +208,18 @@ public function load_customizations() { if ( $filter_name == 'single_add_to_cart_text' ) { - add_filter( 'woocommerce_product_single_add_to_cart_text', array( $this, 'customize_single_add_to_cart_text' ) ); + add_filter( 'woocommerce_product_single_add_to_cart_text', array( $this, 'customize_single_add_to_cart_text' ), 50 ); } else { - add_filter( 'woocommerce_product_add_to_cart_text', array( $this, 'customize_add_to_cart_text' ), 10, 2 ); + add_filter( 'woocommerce_product_add_to_cart_text', array( $this, 'customize_add_to_cart_text' ), 50, 2 ); } } elseif ( 'woocommerce_placeholder_img_src' === $filter_name ) { // only filter placeholder images on the frontend if ( ! is_admin() ) { - add_filter( $filter_name, array( $this, 'customize' ) ); + add_filter( $filter_name, array( $this, 'customize' ), 50 ); } } elseif ( 'loop_sale_flash_text' === $filter_name || 'single_sale_flash_text' === $filter_name ) { @@ -228,7 +228,7 @@ public function load_customizations() { } else { - add_filter( $filter_name, array( $this, 'customize' ) ); + add_filter( $filter_name, array( $this, 'customize' ), 50 ); } } } From 6c00ee951bd155e8a67f9b4efa0a573a3619752a Mon Sep 17 00:00:00 2001 From: Beka Rice Date: Sat, 22 Jul 2017 12:24:01 -0400 Subject: [PATCH 4/4] Update WC outdated notice to prompt for db updater --- woocommerce-customizer.php | 85 +++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/woocommerce-customizer.php b/woocommerce-customizer.php index 51e1d6e..92eda8b 100644 --- a/woocommerce-customizer.php +++ b/woocommerce-customizer.php @@ -25,57 +25,17 @@ // Check if WooCommerce is active if ( ! WC_Customizer::is_woocommerce_active() ) { - add_action( 'admin_notices', 'wc_customizer_render_wc_inactive_notice' ); + add_action( 'admin_notices', array( 'WC_Customizer', 'render_wc_inactive_notice' ) ); return; } // WC version check if ( version_compare( get_option( 'woocommerce_db_version' ), '2.5.5', '<' ) ) { - add_action( 'admin_notices', 'wc_customizer_render_outdated_wc_version_notice' ); + add_action( 'admin_notices', array( 'WC_Customizer', 'render_outdated_wc_version_notice' ) ); return; } -/** - * Renders a notice when WooCommerce version is outdated - * - * @since 2.3.1 - */ -function wc_customizer_render_outdated_wc_version_notice() { - - $message = sprintf( - /* translators: %1$s and %2$s are tags. %3$s and %4$s are tags */ - __( '%1$sWooCommerce Customizer is inactive.%2$s This version requires WooCommerce 2.5.5 or newer. Please %3$supdate WooCommerce to version 2.5.5 or newer%4$s', 'woocommerce-customizer' ), - '', - '', - '', - ' »' - ); - - printf( '

%s

', $message ); -} - - -/** - * Renders a notice when WooCommerce version is outdated - * - * @since 2.3.1 - */ -function wc_customizer_render_wc_inactive_notice() { - - $message = sprintf( - /* translators: %1$s and %2$s are tags. %3$s and %4$s are tags */ - __( '%1$sWooCommerce Customizer is inactive%2$s as it requires WooCommerce. Please %3$sactivate WooCommerce version 2.5.5 or newer%4$s', 'woocommerce-customizer' ), - '', - '', - '', - ' »' - ); - - printf( '

%s

', $message ); -} - - /** * # WooCommerce Customizer Main Plugin Class * @@ -265,6 +225,47 @@ public static function is_woocommerce_active() { } + /** + * Renders a notice when WooCommerce version is outdated + * + * @since 2.3.1 + */ + public static function render_wc_inactive_notice() { + + $message = sprintf( + /* translators: %1$s and %2$s are tags. %3$s and %4$s are tags */ + __( '%1$sWooCommerce Customizer is inactive%2$s as it requires WooCommerce. Please %3$sactivate WooCommerce version 2.5.5 or newer%4$s', 'woocommerce-customizer' ), + '', + '', + '', + ' »' + ); + + printf( '

%s

', $message ); + } + + + /** + * Renders a notice when WooCommerce version is outdated + * + * @since 2.3.1 + */ + public static function render_outdated_wc_version_notice() { + + $message = sprintf( + /* translators: Placeholders: %1$s , %2$s - , %3$s and %5$s - tags, %4$s - */ + __( '%1$sWooCommerce Customizer is inactive.%2$s This plugin requires WooCommerce 2.5.5 or newer. Please %3$supdate WooCommerce%4$s or %5$srun the WooCommerce database upgrade%4$s.', 'woocommerce-customizer' ), + '', + '', + '', + '', + '' + ); + + printf( '

%s

', $message ); + } + + /** Frontend methods ******************************************************/