Automattic\WooCommerce\Internal\PushNotifications\DataStores
PushTokensDataStore::build_meta_array_from_database
Returns an associative array of post meta as key => value pairs for the keys defined in SUPPORTED_META; missing keys return null. Use update_meta_cache with get_post_meta to allow reading the meta as single values which automatically unserialize when requires, rather than nested arrays that don't.
Method of the class: PushTokensDataStore{}
No Hooks.
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->build_meta_array_from_database( $id ): array;
- $id(int) (required)
- The push token ID.
Changelog
| Since 10.5.0 | Introduced. |
PushTokensDataStore::build_meta_array_from_database() PushTokensDataStore::build meta array from database code WC 10.8.1
private function build_meta_array_from_database( int $id ): array {
$meta_by_key = array_fill_keys( static::SUPPORTED_META, null );
foreach ( static::SUPPORTED_META as $key ) {
$meta = get_post_meta( $id, $key, true );
if ( '' !== $meta ) {
$meta_by_key[ $key ] = $meta;
}
}
return $meta_by_key;
}