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:
dwindown
2025-11-20 12:27:53 +07:00
parent e53b8320e4
commit 9f731bfe0a
2 changed files with 8 additions and 34 deletions

View File

@@ -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