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.
Метод класса: PushTokensDataStore{}
Хуков нет.
Возвращает
array.
Использование
// private - только в коде основоного (родительского) класса $result = $this->build_meta_array_from_database( $id ): array;
- $id(int) (обязательный)
- The push token ID.
Список изменений
| С версии 10.5.0 | Введена. |
Код PushTokensDataStore::build_meta_array_from_database() PushTokensDataStore::build meta array from database WC 11.2.2
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;
}