Skip to content

Commit

Permalink
Fixes 'headers already sent' error for out of date WC
Browse files Browse the repository at this point in the history
closes #18
  • Loading branch information
bekarice committed Jun 7, 2016
1 parent d9e850f commit 9e93ddd
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 38 deletions.
35 changes: 21 additions & 14 deletions i18n/languages/woocommerce-customizer.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is distributed under the GNU General Public License v3.0.
msgid ""
msgstr ""
"Project-Id-Version: WooCommerce Customizer 2.3.0\n"
"Project-Id-Version: WooCommerce Customizer 2.3.1\n"
"Report-Msgid-Bugs-To: "
"https://github.com/skyverge/woocommerce-customizer/issues\n"
"POT-Creation-Date: 2014-09-05 23:18:53+00:00\n"
Expand Down Expand Up @@ -241,33 +241,40 @@ msgstr ""
msgid "Change the default placeholder image by setting this to a valid image URL"
msgstr ""

#: woocommerce-customizer.php:121
#: woocommerce-customizer.php:50
#. translators: %1$s and %2$s are <strong> tags. %3$s and %4$s are <a> tags
msgid ""
"%1$sWooCommerce Customizer is inactive.%2$s This version requires "
"WooCommerce 2.4.13 or newer. Please %3$supdate WooCommerce to version "
"2.4.13 or newer%4$s"
msgstr ""

#: woocommerce-customizer.php:70
#. translators: %1$s and %2$s are <strong> tags. %3$s and %4$s are <a> tags
msgid ""
"%1$sWooCommerce Customizer is inactive%2$s as it requires WooCommerce. "
"Please %3$sactivate WooCommerce version 2.4.13 or newer%4$s"
msgstr ""

#: woocommerce-customizer.php:163
#. translators: Placeholders: %s - plugin name
msgid "You cannot clone instances of %s."
msgstr ""

#: woocommerce-customizer.php:133
#: woocommerce-customizer.php:175
#. translators: Placeholders: %s - plugin name
msgid "You cannot unserialize instances of %s."
msgstr ""

#: woocommerce-customizer.php:226
#. translators: %1$s and %2$s are <strong> tags. %3$s and %4$s are <a> tags
msgid ""
"%1$sWooCommerce Customizer is inactive.%2$s This version requires "
"WooCommerce 2.4.13 or newer. Please %3$supdate WooCommerce to version "
"2.4.13 or newer%4$s"
msgstr ""

#: woocommerce-customizer.php:333
#: woocommerce-customizer.php:355
msgid "Configure"
msgstr ""

#: woocommerce-customizer.php:334
#: woocommerce-customizer.php:356
msgid "FAQ"
msgstr ""

#: woocommerce-customizer.php:335
#: woocommerce-customizer.php:357
msgid "Support"
msgstr ""

Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Requires at least: 4.1
Tested up to: 4.5.2
Requires WooCommerce at least: 2.4.13
Tested WooCommerce up to: 2.6.0
Stable tag: 2.3.0
Stable tag: 2.3.1
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -74,6 +74,9 @@ Yes! Fork the plugin on [GitHub](https://github.com/skyverge/woocommerce-customi

== Changelog ==

= 2.3.1 =
* Fix - Fixes "headers already sent" error if WooCommerce is out of date

= 2.3.0 =
* Misc - Added support for WooCommerce 2.6
* Misc - Removed support for WooCommerce 2.3
Expand Down
68 changes: 45 additions & 23 deletions woocommerce-customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.0
* Version: 2.3.1
* Text Domain: woocommerce-customizer
* Domain Path: /i18n/languages/
*
Expand All @@ -25,17 +25,59 @@

// Check if WooCommerce is active
if ( ! WC_Customizer::is_woocommerce_active() ) {

add_action( 'admin_notices', 'wc_customizer_render_wc_inactive_notice' );
return;
}

// WC version check
if ( version_compare( get_option( 'woocommerce_db_version' ), '2.4.13', '<' ) ) {

add_action( 'admin_notices', WC_Customizer::render_outdated_wc_version_notice() );
add_action( 'admin_notices', '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 <strong> tags. %3$s and %4$s are <a> tags */
__( '%1$sWooCommerce Customizer is inactive.%2$s This version requires WooCommerce 2.4.13 or newer. Please %3$supdate WooCommerce to version 2.4.13 or newer%4$s', 'woocommerce-customizer' ),
'<strong>',
'</strong>',
'<a href="' . admin_url( 'plugins.php' ) . '">',
'&nbsp;&raquo;</a>'
);

printf( '<div class="error"><p>%s</p></div>', $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 <strong> tags. %3$s and %4$s are <a> tags */
__( '%1$sWooCommerce Customizer is inactive%2$s as it requires WooCommerce. Please %3$sactivate WooCommerce version 2.4.13 or newer%4$s', 'woocommerce-customizer' ),
'<strong>',
'</strong>',
'<a href="' . admin_url( 'plugins.php' ) . '">',
'&nbsp;&raquo;</a>'
);

printf( '<div class="error"><p>%s</p></div>', $message );
}


/**
* # WooCommerce Customizer Main Plugin Class
*
Expand Down Expand Up @@ -71,7 +113,7 @@ class WC_Customizer {


/** plugin version number */
const VERSION = '2.3.0';
const VERSION = '2.3.1';

/** @var \WC_Customizer single instance of this plugin */
protected static $instance;
Expand Down Expand Up @@ -214,26 +256,6 @@ public static function is_woocommerce_active() {
}


/**
* Renders a notice when WooCommerce version is outdated
*
* @since 2.3.0
*/
public static function render_outdated_wc_version_notice() {

$message = sprintf(
/* translators: %1$s and %2$s are <strong> tags. %3$s and %4$s are <a> tags */
__( '%1$sWooCommerce Customizer is inactive.%2$s This version requires WooCommerce 2.4.13 or newer. Please %3$supdate WooCommerce to version 2.4.13 or newer%4$s', 'woocommerce-customizer' ),
'<strong>',
'</strong>',
'<a href="' . admin_url( 'plugins.php' ) . '">',
'&nbsp;&raquo;</a>'
);

printf( '<div class="error"><p>%s</p></div>', $message );
}


/** Frontend methods ******************************************************/


Expand Down

0 comments on commit 9e93ddd

Please sign in to comment.