fix: Remove addon-specific defaults - maintain zero dependencies
**Issue:** Core had default allowed meta fields for specific addons - OrdersController: _tracking_number, _tracking_provider, etc. - ProductsController: _custom_field **Problem:** This violates our core principle: ❌ WooNooW Core = Zero addon dependencies ❌ We do NOT support specific plugins in core ❌ We do NOT hardcode addon fields **Solution:** Empty defaults, plugins register via filters **Before:** ```php $allowed = apply_filters('woonoow/order_allowed_private_meta', [ '_tracking_number', // ❌ Addon-specific '_tracking_provider', // ❌ Addon-specific ], $order); ``` **After:** ```php // Core has ZERO defaults - plugins register via filter $allowed = apply_filters('woonoow/order_allowed_private_meta', [], $order); ``` **How Plugins Register:** ```php // Shipment Tracking plugin (or any plugin) add_filter('woonoow/order_allowed_private_meta', function($allowed) { $allowed[] = '_tracking_number'; $allowed[] = '_tracking_provider'; return $allowed; }); ``` **Principle Maintained:** ✅ Core has ZERO addon dependencies ✅ Core does NOT know about specific plugins ✅ Plugins register themselves via standard WP filters ✅ Community does the integration, not core **Changed:** - OrdersController: Empty defaults for allowed/updatable meta - ProductsController: Empty defaults for allowed/updatable meta - Added comments: 'Core has ZERO defaults - plugins register via filter' **Result:** - Public meta (no underscore): Always exposed automatically - Private meta (starts with _): Only if plugin registers via filter - Clean separation: Core provides mechanism, plugins use it
This commit is contained in:
@@ -2216,20 +2216,8 @@ class OrdersController {
|
||||
}
|
||||
|
||||
// Private meta (starts with _) - check if allowed
|
||||
$allowed_private = apply_filters( 'woonoow/order_allowed_private_meta', [
|
||||
// Common shipping tracking fields
|
||||
'_tracking_number',
|
||||
'_tracking_provider',
|
||||
'_tracking_url',
|
||||
'_shipment_tracking_items',
|
||||
'_wc_shipment_tracking_items',
|
||||
|
||||
// Payment gateway meta
|
||||
'_transaction_id',
|
||||
'_payment_method_title',
|
||||
|
||||
// Allow plugins to add their meta via filter
|
||||
], $order );
|
||||
// Core has ZERO defaults - plugins register via filter
|
||||
$allowed_private = apply_filters( 'woonoow/order_allowed_private_meta', [], $order );
|
||||
|
||||
if ( in_array( $key, $allowed_private, true ) ) {
|
||||
$meta_data[ $key ] = $value;
|
||||
@@ -2247,14 +2235,8 @@ class OrdersController {
|
||||
*/
|
||||
private static function update_order_meta_data( $order, $meta_updates ) {
|
||||
// Get allowed updatable meta keys
|
||||
$allowed = apply_filters( 'woonoow/order_updatable_meta', [
|
||||
// Common shipping tracking fields
|
||||
'_tracking_number',
|
||||
'_tracking_provider',
|
||||
'_tracking_url',
|
||||
|
||||
// Allow plugins to add their meta via filter
|
||||
], $order );
|
||||
// Core has ZERO defaults - plugins register via filter
|
||||
$allowed = apply_filters( 'woonoow/order_updatable_meta', [], $order );
|
||||
|
||||
foreach ( $meta_updates as $key => $value ) {
|
||||
// Skip internal WooCommerce meta
|
||||
|
||||
@@ -743,12 +743,8 @@ class ProductsController {
|
||||
}
|
||||
|
||||
// Private meta (starts with _) - check if allowed
|
||||
$allowed_private = apply_filters('woonoow/product_allowed_private_meta', [
|
||||
// Common custom fields
|
||||
'_custom_field',
|
||||
|
||||
// Allow plugins to add their meta via filter
|
||||
], $product);
|
||||
// Core has ZERO defaults - plugins register via filter
|
||||
$allowed_private = apply_filters('woonoow/product_allowed_private_meta', [], $product);
|
||||
|
||||
if (in_array($key, $allowed_private, true)) {
|
||||
$meta_data[$key] = $value;
|
||||
@@ -766,12 +762,8 @@ class ProductsController {
|
||||
*/
|
||||
private static function update_product_meta_data($product, $meta_updates) {
|
||||
// Get allowed updatable meta keys
|
||||
$allowed = apply_filters('woonoow/product_updatable_meta', [
|
||||
// Common custom fields
|
||||
'_custom_field',
|
||||
|
||||
// Allow plugins to add their meta via filter
|
||||
], $product);
|
||||
// Core has ZERO defaults - plugins register via filter
|
||||
$allowed = apply_filters('woonoow/product_updatable_meta', [], $product);
|
||||
|
||||
foreach ($meta_updates as $key => $value) {
|
||||
// Skip internal WooCommerce meta
|
||||
|
||||
Reference in New Issue
Block a user