Refactor to PSR-4: rename files and switch namespace

- Rename files to PascalCase: Product_Type → ProductType, Cart_Handler →
  CartHandler, Product_Selector → ProductSelector, Stock_Manager →
  StockManager, Admin/Product_Data → Admin/ProductData
- Switch namespace from WC_Composable_Product to Magdev\WcComposableProduct
- Update all cross-references in PHP, CSS, JS, translations, and docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 12:35:02 +01:00
parent dd5965ae4c
commit ea2261d8d7
21 changed files with 281 additions and 281 deletions

View File

@@ -2,17 +2,17 @@
/**
* Product Data Tab
*
* @package WC_Composable_Product
* @package Magdev\WcComposableProduct
*/
namespace WC_Composable_Product\Admin;
namespace Magdev\WcComposableProduct\Admin;
defined('ABSPATH') || exit;
/**
* Product Data Tab Class
*/
class Product_Data {
class ProductData {
/**
* Constructor
*/

View File

@@ -2,10 +2,10 @@
/**
* Admin Settings
*
* @package WC_Composable_Product
* @package Magdev\WcComposableProduct
*/
namespace WC_Composable_Product\Admin;
namespace Magdev\WcComposableProduct\Admin;
defined('ABSPATH') || exit;

View File

@@ -2,10 +2,10 @@
/**
* Cart Handler
*
* @package WC_Composable_Product
* @package Magdev\WcComposableProduct
*/
namespace WC_Composable_Product;
namespace Magdev\WcComposableProduct;
defined('ABSPATH') || exit;
@@ -14,11 +14,11 @@ defined('ABSPATH') || exit;
*
* Handles adding composable products to cart and calculating prices
*/
class Cart_Handler {
class CartHandler {
/**
* Stock manager instance
*
* @var Stock_Manager
* @var StockManager
*/
private $stock_manager;
@@ -26,7 +26,7 @@ class Cart_Handler {
* Constructor
*/
public function __construct() {
$this->stock_manager = new Stock_Manager();
$this->stock_manager = new StockManager();
add_filter('woocommerce_add_to_cart_validation', [$this, 'validate_add_to_cart'], 10, 3);
add_filter('woocommerce_add_cart_item_data', [$this, 'add_cart_item_data'], 10, 2);
@@ -59,7 +59,7 @@ class Cart_Handler {
global $product;
if ($product && $product->get_type() === 'composable') {
Product_Selector::render($product);
ProductSelector::render($product);
}
}

View File

@@ -2,10 +2,10 @@
/**
* Main Plugin Class
*
* @package WC_Composable_Product
* @package Magdev\WcComposableProduct
*/
namespace WC_Composable_Product;
namespace Magdev\WcComposableProduct;
defined('ABSPATH') || exit;
@@ -98,15 +98,15 @@ class Plugin {
private function includes() {
// Note: Settings.php is NOT included here because it extends WC_Settings_Page
// which isn't loaded until later. It's included in add_settings_page() instead.
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/Product_Data.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Product_Type.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Stock_Manager.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Cart_Handler.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Product_Selector.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/ProductData.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/ProductType.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/StockManager.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/CartHandler.php';
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/ProductSelector.php';
// Initialize components
new Admin\Product_Data();
new Cart_Handler();
new Admin\ProductData();
new CartHandler();
}
/**
@@ -129,7 +129,7 @@ class Plugin {
*/
public function product_class($classname, $product_type) {
if ($product_type === 'composable') {
$classname = 'WC_Composable_Product\Product_Type';
$classname = 'Magdev\WcComposableProduct\ProductType';
}
return $classname;
}

View File

@@ -2,10 +2,10 @@
/**
* Product Selector
*
* @package WC_Composable_Product
* @package Magdev\WcComposableProduct
*/
namespace WC_Composable_Product;
namespace Magdev\WcComposableProduct;
defined('ABSPATH') || exit;
@@ -14,11 +14,11 @@ defined('ABSPATH') || exit;
*
* Handles rendering the product selection interface
*/
class Product_Selector {
class ProductSelector {
/**
* Render product selector
*
* @param Product_Type $product Composable product
* @param ProductType $product Composable product
*/
public static function render($product) {
if (!$product || $product->get_type() !== 'composable') {
@@ -34,7 +34,7 @@ class Product_Selector {
$show_total = get_option('wc_composable_show_total', 'yes') === 'yes';
// Get stock manager for stock information
$stock_manager = new Stock_Manager();
$stock_manager = new StockManager();
// Prepare product data for template
$products_data = [];

View File

@@ -2,17 +2,17 @@
/**
* Composable Product Type
*
* @package WC_Composable_Product
* @package Magdev\WcComposableProduct
*/
namespace WC_Composable_Product;
namespace Magdev\WcComposableProduct;
defined('ABSPATH') || exit;
/**
* Composable Product Type Class
*/
class Product_Type extends \WC_Product {
class ProductType extends \WC_Product {
/**
* Product type
*

View File

@@ -2,10 +2,10 @@
/**
* Stock Manager
*
* @package WC_Composable_Product
* @package Magdev\WcComposableProduct
*/
namespace WC_Composable_Product;
namespace Magdev\WcComposableProduct;
defined('ABSPATH') || exit;
@@ -14,7 +14,7 @@ defined('ABSPATH') || exit;
*
* Handles stock management for composable products
*/
class Stock_Manager {
class StockManager {
/**
* Constructor
*/