WC_Helper_Updater::get_cached_products
Extract the products from a cached update-check payload.
Used while backing off and when the update check fails. The server-side autoupdate decisions are kept only when the cache is fresh and was made for the current payload.
Метод класса: WC_Helper_Updater{}
Хуков нет.
Возвращает
array. The cached products, or an empty array when there are none.
Использование
$result = WC_Helper_Updater::get_cached_products( $data, $hash );
- $data(разное) (обязательный)
- The data retrieved from the transient, of any shape.
- $hash(строка) (обязательный)
- The hash of the current payload.
Код WC_Helper_Updater::get_cached_products() WC Helper Updater::get cached products WC 11.3.0
private static function get_cached_products( $data, string $hash ) {
if ( ! is_array( $data ) || ! isset( $data['products'] ) || ! is_array( $data['products'] ) ) {
return array();
}
$products = $data['products'];
if ( isset( $data['hash'] ) && is_string( $data['hash'] ) && hash_equals( $hash, $data['hash'] ) && self::is_fresh_update_data( $data ) ) {
return $products;
}
foreach ( $products as $product_id => $product ) {
if ( is_array( $product ) ) {
unset( $products[ $product_id ]['autoupdate'] );
}
}
return $products;
}