You've already forked wc-tier-and-package-prices
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b7638a7e2 | |||
| db9ba2bacd | |||
| e46372da51 | |||
| 2b2c06794b |
85
CHANGELOG.md
85
CHANGELOG.md
@@ -5,6 +5,91 @@ 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/),
|
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [1.1.19] - 2025-12-22
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Settings page still appearing twice despite instance caching
|
||||||
|
- Duplicate detection using strict instance comparison failing for different object instances
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Enhanced duplicate detection to check by class type and ID instead of instance
|
||||||
|
- Added `instanceof WC_TPP_Settings` check
|
||||||
|
- Added ID-based duplicate detection via `get_id()` method and direct property access
|
||||||
|
- Multiple fallback checks to catch duplicates regardless of instance identity
|
||||||
|
|
||||||
|
### Technical Details
|
||||||
|
|
||||||
|
- Previous strict comparison (`===`) failed when different instances of same class existed
|
||||||
|
- New approach checks: instanceof, get_id() method, and id property
|
||||||
|
- Returns early if any settings page with ID 'tier_package_prices' found
|
||||||
|
- Prevents duplicates even if settings instance recreated or serialized
|
||||||
|
|
||||||
|
## [1.1.18] - 2025-12-22
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **ROOT CAUSE IDENTIFIED**: Settings page rendering twice due to automatic instantiation in settings file
|
||||||
|
- Settings file being included multiple times via Composer autoloader creating duplicate instances
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Removed `return new WC_TPP_Settings();` from bottom of settings file
|
||||||
|
- Changed admin class to explicitly instantiate settings with `new WC_TPP_Settings()`
|
||||||
|
- Changed from `include` to `require_once` for settings file to prevent multiple loads
|
||||||
|
|
||||||
|
### Technical Details
|
||||||
|
|
||||||
|
- Settings file (class-wc-tpp-settings.php) was creating instance automatically on include
|
||||||
|
- File is in Composer's classmap, so when autoloaded it executed instantiation again
|
||||||
|
- Each include/autoload created new instance even with singleton pattern in admin class
|
||||||
|
- Solution: Remove automatic instantiation, use `require_once` + explicit `new` in admin class
|
||||||
|
- Now settings instance only created once, explicitly, when needed by filter
|
||||||
|
- Composer autoload can load class definition without side effects
|
||||||
|
|
||||||
|
## [1.1.17] - 2025-12-22
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Settings page still rendering twice despite singleton pattern in v1.1.16
|
||||||
|
- Filter adding settings instance to array multiple times when called repeatedly
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Added duplicate detection in `add_settings_page()` filter method
|
||||||
|
- Filter now checks if settings instance already exists in array before adding
|
||||||
|
|
||||||
|
### Technical Details
|
||||||
|
|
||||||
|
- Added foreach loop to check existing settings pages in array
|
||||||
|
- Uses strict comparison (`===`) to detect if exact instance already present
|
||||||
|
- Returns early if settings instance found, preventing duplicate array entries
|
||||||
|
- Complements singleton pattern from v1.1.16 with array-level duplicate prevention
|
||||||
|
- Handles edge case where WooCommerce calls filter multiple times
|
||||||
|
|
||||||
|
## [1.1.16] - 2025-12-22
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Settings page still rendering twice in WooCommerce backend despite v1.1.15 fix
|
||||||
|
- Multiple instantiation of WC_TPP_Admin and WC_TPP_Settings classes
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Implemented singleton pattern for WC_TPP_Admin class with `get_instance()` method
|
||||||
|
- Made WC_TPP_Admin constructor private to prevent direct instantiation
|
||||||
|
- Added static caching of WC_TPP_Settings instance to prevent duplicate creation
|
||||||
|
- Changed class instantiation from `new WC_TPP_Admin()` to `WC_TPP_Admin::get_instance()`
|
||||||
|
|
||||||
|
### Technical Details
|
||||||
|
|
||||||
|
- Added `private static $instance` property to WC_TPP_Admin class
|
||||||
|
- Added `private static $settings_instance` property to cache settings page instance
|
||||||
|
- Modified `add_settings_page()` to check and reuse cached settings instance
|
||||||
|
- Ensures only one instance of each class exists throughout plugin lifecycle
|
||||||
|
- Prevents duplicate filter registrations even if called multiple times
|
||||||
|
|
||||||
## [1.1.15] - 2025-12-22
|
## [1.1.15] - 2025-12-22
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "magdev/wc-tier-package-prices",
|
"name": "magdev/wc-tier-package-prices",
|
||||||
"description": "WooCommerce plugin for tier pricing and package prices with Twig templates",
|
"description": "WooCommerce plugin for tier pricing and package prices with Twig templates",
|
||||||
"version": "1.1.15",
|
"version": "1.1.19",
|
||||||
"type": "wordpress-plugin",
|
"type": "wordpress-plugin",
|
||||||
"license": "GPL-2.0-or-later",
|
"license": "GPL-2.0-or-later",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|||||||
@@ -10,7 +10,17 @@ if (!defined('ABSPATH')) {
|
|||||||
if (!class_exists('WC_TPP_Admin')) {
|
if (!class_exists('WC_TPP_Admin')) {
|
||||||
class WC_TPP_Admin {
|
class WC_TPP_Admin {
|
||||||
|
|
||||||
public function __construct() {
|
private static $instance = null;
|
||||||
|
private static $settings_instance = null;
|
||||||
|
|
||||||
|
public static function get_instance() {
|
||||||
|
if (null === self::$instance) {
|
||||||
|
self::$instance = new self();
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function __construct() {
|
||||||
add_filter('woocommerce_get_settings_pages', array($this, 'add_settings_page'));
|
add_filter('woocommerce_get_settings_pages', array($this, 'add_settings_page'));
|
||||||
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
|
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
|
||||||
}
|
}
|
||||||
@@ -19,7 +29,32 @@ if (!class_exists('WC_TPP_Admin')) {
|
|||||||
* Add settings page to WooCommerce settings
|
* Add settings page to WooCommerce settings
|
||||||
*/
|
*/
|
||||||
public function add_settings_page($settings) {
|
public function add_settings_page($settings) {
|
||||||
$settings[] = include WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-settings.php';
|
if (null === self::$settings_instance) {
|
||||||
|
require_once WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-settings.php';
|
||||||
|
self::$settings_instance = new WC_TPP_Settings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if our settings page is already in the array to prevent duplicates
|
||||||
|
// Check by class type and ID instead of instance comparison
|
||||||
|
foreach ($settings as $settings_page) {
|
||||||
|
if ($settings_page instanceof WC_TPP_Settings) {
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
// Also check by ID property if it's a WC_Settings_Page
|
||||||
|
if (is_object($settings_page) &&
|
||||||
|
method_exists($settings_page, 'get_id') &&
|
||||||
|
$settings_page->get_id() === 'tier_package_prices') {
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
// Check id property directly
|
||||||
|
if (is_object($settings_page) &&
|
||||||
|
isset($settings_page->id) &&
|
||||||
|
$settings_page->id === 'tier_package_prices') {
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings[] = self::$settings_instance;
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,5 +66,5 @@ if (!class_exists('WC_TPP_Admin')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new WC_TPP_Admin();
|
WC_TPP_Admin::get_instance();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,5 +141,3 @@ if (!class_exists('WC_TPP_Settings')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WC_TPP_Settings();
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* Plugin Name: WooCommerce Tier and Package Prices
|
* Plugin Name: WooCommerce Tier and Package Prices
|
||||||
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wc-tier-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
|
* Description: Add tier pricing and package prices to WooCommerce products with configurable quantities at fixed prices
|
||||||
* Version: 1.1.15
|
* Version: 1.1.19
|
||||||
* Author: Marco Graetsch
|
* Author: Marco Graetsch
|
||||||
* Author URI: https://src.bundespruefstelle.ch/magdev
|
* Author URI: https://src.bundespruefstelle.ch/magdev
|
||||||
* Text Domain: wc-tier-package-prices
|
* Text Domain: wc-tier-package-prices
|
||||||
@@ -23,7 +23,7 @@ if (!defined('ABSPATH')) {
|
|||||||
|
|
||||||
// Define plugin constants
|
// Define plugin constants
|
||||||
if (!defined('WC_TPP_VERSION')) {
|
if (!defined('WC_TPP_VERSION')) {
|
||||||
define('WC_TPP_VERSION', '1.1.15');
|
define('WC_TPP_VERSION', '1.1.19');
|
||||||
}
|
}
|
||||||
if (!defined('WC_TPP_PLUGIN_DIR')) {
|
if (!defined('WC_TPP_PLUGIN_DIR')) {
|
||||||
define('WC_TPP_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
define('WC_TPP_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||||
|
|||||||
Reference in New Issue
Block a user