diff --git a/CHANGELOG.md b/CHANGELOG.md index a1823ad..c35e69f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ All notable changes to WooCommerce Tier and Package Prices will be documented in The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.12] - 2025-12-22 + +### Fixed + +- **CRITICAL:** Class redeclaration error for `WC_Tier_Package_Prices` affecting version 1.1.11 +- Fatal error "Cannot redeclare class WC_Tier_Package_Prices" when plugin file loaded multiple times +- Plugin activation failures caused by class redeclaration + +### Technical Details + +- Wrapped `WC_Tier_Package_Prices` class declaration in `class_exists()` check +- Completes comprehensive redeclaration protection for all plugin components +- Prevents fatal errors during WordPress plugin activation/deactivation cycles +- All functions, constants, and classes now safely guarded against redeclaration + ## [1.1.11] - 2025-12-22 ### Fixed diff --git a/composer.json b/composer.json index 3207f3a..d2c4d7a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "magdev/wc-tier-package-prices", "description": "WooCommerce plugin for tier pricing and package prices with Twig templates", - "version": "1.1.11", + "version": "1.1.12", "type": "wordpress-plugin", "license": "GPL-2.0-or-later", "authors": [ diff --git a/releases/wc-tier-and-package-prices-1.1.12.zip b/releases/wc-tier-and-package-prices-1.1.12.zip new file mode 100644 index 0000000..7f4d2d8 Binary files /dev/null and b/releases/wc-tier-and-package-prices-1.1.12.zip differ diff --git a/releases/wc-tier-and-package-prices-1.1.12.zip.md5 b/releases/wc-tier-and-package-prices-1.1.12.zip.md5 new file mode 100644 index 0000000..5540201 --- /dev/null +++ b/releases/wc-tier-and-package-prices-1.1.12.zip.md5 @@ -0,0 +1 @@ +c1c0b5880636686227246be2c37dc42a releases/wc-tier-and-package-prices-1.1.12.zip diff --git a/releases/wc-tier-and-package-prices-1.1.12.zip.sha256 b/releases/wc-tier-and-package-prices-1.1.12.zip.sha256 new file mode 100644 index 0000000..803e033 --- /dev/null +++ b/releases/wc-tier-and-package-prices-1.1.12.zip.sha256 @@ -0,0 +1 @@ +05b32356d46803dbb7fa17c13a2d8da96f77126746e2895e2f5c6dd0e7b490ff releases/wc-tier-and-package-prices-1.1.12.zip diff --git a/wc-tier-and-package-prices.php b/wc-tier-and-package-prices.php index 121cc1e..2eaf14e 100644 --- a/wc-tier-and-package-prices.php +++ b/wc-tier-and-package-prices.php @@ -4,7 +4,7 @@ * Plugin Name: WooCommerce Tier and Package Prices * Plugin URI: https://src.bundespruefstelle.ch/magdev/wc-tier-package-prices * Description: Add tier pricing and package prices to WooCommerce products with configurable quantities at fixed prices - * Version: 1.1.11 + * Version: 1.1.12 * Author: Marco Graetsch * Author URI: https://src.bundespruefstelle.ch/magdev * Text Domain: wc-tier-package-prices @@ -23,7 +23,7 @@ if (!defined('ABSPATH')) { // Define plugin constants if (!defined('WC_TPP_VERSION')) { - define('WC_TPP_VERSION', '1.1.11'); + define('WC_TPP_VERSION', '1.1.12'); } if (!defined('WC_TPP_PLUGIN_DIR')) { define('WC_TPP_PLUGIN_DIR', plugin_dir_path(__FILE__)); @@ -62,67 +62,69 @@ if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get /** * Main plugin class */ -class WC_Tier_Package_Prices { +if (!class_exists('WC_Tier_Package_Prices')) { + class WC_Tier_Package_Prices { - private static $instance = null; + private static $instance = null; - public static function get_instance() { - if (null === self::$instance) { - self::$instance = new self(); + public static function get_instance() { + if (null === self::$instance) { + self::$instance = new self(); + } + return self::$instance; } - return self::$instance; - } - private function __construct() { - $this->init_hooks(); - $this->includes(); - } - - private function init_hooks() { - add_action('plugins_loaded', array($this, 'load_textdomain')); - add_action('before_woocommerce_init', array($this, 'declare_hpos_compatibility')); - register_activation_hook(__FILE__, array($this, 'activate')); - register_deactivation_hook(__FILE__, array($this, 'deactivate')); - } - - private function includes() { - require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-template-loader.php'; - require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-admin.php'; - require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-product-meta.php'; - require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-frontend.php'; - require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-cart.php'; - - // Instantiate classes after WooCommerce is loaded - add_action('woocommerce_loaded', array($this, 'init_classes')); - } - - public function init_classes() { - new WC_TPP_Admin(); - new WC_TPP_Product_Meta(); - new WC_TPP_Frontend(); - new WC_TPP_Cart(); - } - - public function declare_hpos_compatibility() { - if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) { - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); + private function __construct() { + $this->init_hooks(); + $this->includes(); } - } - public function load_textdomain() { - load_plugin_textdomain('wc-tier-package-prices', false, dirname(WC_TPP_PLUGIN_BASENAME) . '/languages'); - } + private function init_hooks() { + add_action('plugins_loaded', array($this, 'load_textdomain')); + add_action('before_woocommerce_init', array($this, 'declare_hpos_compatibility')); + register_activation_hook(__FILE__, array($this, 'activate')); + register_deactivation_hook(__FILE__, array($this, 'deactivate')); + } - public function activate() { - // Add default options - add_option('wc_tpp_enable_tier_pricing', 'yes'); - add_option('wc_tpp_enable_package_pricing', 'yes'); - add_option('wc_tpp_display_table', 'yes'); - flush_rewrite_rules(); - } + private function includes() { + require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-template-loader.php'; + require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-admin.php'; + require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-product-meta.php'; + require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-frontend.php'; + require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-cart.php'; - public function deactivate() { - flush_rewrite_rules(); + // Instantiate classes after WooCommerce is loaded + add_action('woocommerce_loaded', array($this, 'init_classes')); + } + + public function init_classes() { + new WC_TPP_Admin(); + new WC_TPP_Product_Meta(); + new WC_TPP_Frontend(); + new WC_TPP_Cart(); + } + + public function declare_hpos_compatibility() { + if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) { + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); + } + } + + public function load_textdomain() { + load_plugin_textdomain('wc-tier-package-prices', false, dirname(WC_TPP_PLUGIN_BASENAME) . '/languages'); + } + + public function activate() { + // Add default options + add_option('wc_tpp_enable_tier_pricing', 'yes'); + add_option('wc_tpp_enable_package_pricing', 'yes'); + add_option('wc_tpp_display_table', 'yes'); + flush_rewrite_rules(); + } + + public function deactivate() { + flush_rewrite_rules(); + } } }