2025-12-21 04:56:50 +01:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Admin settings and configuration
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!defined('ABSPATH')) {
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
Release version 1.1.13 - Critical class redeclaration fixes
Fixed critical class redeclaration errors affecting all plugin functionality
in version 1.1.12. All plugin component classes now properly guarded.
**CRITICAL FIXES:**
- Plugin completely non-functional in v1.1.12 (no settings, no frontend, no backend)
- Fatal errors for WC_TPP_Admin, WC_TPP_Product_Meta, WC_TPP_Frontend, WC_TPP_Cart, WC_TPP_Settings classes
- All classes now wrapped in class_exists() checks
**Files Modified:**
- includes/class-wc-tpp-admin.php
- includes/class-wc-tpp-product-meta.php
- includes/class-wc-tpp-frontend.php
- includes/class-wc-tpp-cart.php
- includes/class-wc-tpp-settings.php
**Technical Details:**
- Completes comprehensive redeclaration protection started in v1.1.9-1.1.12
- All 2 functions, 4 constants, and 6 classes now protected
- Plugin activates successfully and all features functional
- Settings page, product meta boxes, frontend display, cart integration all working
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 19:02:18 +01:00
|
|
|
if (!class_exists('WC_TPP_Admin')) {
|
|
|
|
|
class WC_TPP_Admin {
|
2025-12-21 04:56:50 +01:00
|
|
|
|
2025-12-22 20:01:27 +01:00
|
|
|
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() {
|
2025-12-21 05:14:19 +01:00
|
|
|
add_filter('woocommerce_get_settings_pages', array($this, 'add_settings_page'));
|
2025-12-21 04:56:50 +01:00
|
|
|
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-21 05:14:19 +01:00
|
|
|
/**
|
|
|
|
|
* Add settings page to WooCommerce settings
|
|
|
|
|
*/
|
|
|
|
|
public function add_settings_page($settings) {
|
2025-12-22 20:01:27 +01:00
|
|
|
if (null === self::$settings_instance) {
|
|
|
|
|
self::$settings_instance = include WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-settings.php';
|
|
|
|
|
}
|
2025-12-22 23:05:11 +01:00
|
|
|
|
|
|
|
|
// Check if our settings page is already in the array to prevent duplicates
|
|
|
|
|
foreach ($settings as $settings_page) {
|
|
|
|
|
if ($settings_page === self::$settings_instance) {
|
|
|
|
|
return $settings;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-22 20:01:27 +01:00
|
|
|
$settings[] = self::$settings_instance;
|
2025-12-21 05:14:19 +01:00
|
|
|
return $settings;
|
2025-12-21 04:56:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function enqueue_admin_scripts($hook) {
|
2025-12-21 05:14:19 +01:00
|
|
|
if ('woocommerce_page_wc-settings' === $hook || 'post.php' === $hook || 'post-new.php' === $hook) {
|
2025-12-21 04:56:50 +01:00
|
|
|
wp_enqueue_style('wc-tpp-admin', WC_TPP_PLUGIN_URL . 'assets/css/admin.css', array(), WC_TPP_VERSION);
|
|
|
|
|
wp_enqueue_script('wc-tpp-admin', WC_TPP_PLUGIN_URL . 'assets/js/admin.js', array('jquery'), WC_TPP_VERSION, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-22 19:32:47 +01:00
|
|
|
|
2025-12-22 20:01:27 +01:00
|
|
|
WC_TPP_Admin::get_instance();
|
Release version 1.1.13 - Critical class redeclaration fixes
Fixed critical class redeclaration errors affecting all plugin functionality
in version 1.1.12. All plugin component classes now properly guarded.
**CRITICAL FIXES:**
- Plugin completely non-functional in v1.1.12 (no settings, no frontend, no backend)
- Fatal errors for WC_TPP_Admin, WC_TPP_Product_Meta, WC_TPP_Frontend, WC_TPP_Cart, WC_TPP_Settings classes
- All classes now wrapped in class_exists() checks
**Files Modified:**
- includes/class-wc-tpp-admin.php
- includes/class-wc-tpp-product-meta.php
- includes/class-wc-tpp-frontend.php
- includes/class-wc-tpp-cart.php
- includes/class-wc-tpp-settings.php
**Technical Details:**
- Completes comprehensive redeclaration protection started in v1.1.9-1.1.12
- All 2 functions, 4 constants, and 6 classes now protected
- Plugin activates successfully and all features functional
- Settings page, product meta boxes, frontend display, cart integration all working
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 19:02:18 +01:00
|
|
|
}
|