WC_Helper_Updater::_update_check
Run an update check API call.
The call is cached based on the payload (product ids, file ids). If the payload changes, the cache is going to miss.
Метод класса: WC_Helper_Updater{}
Хуков нет.
Возвращает
Массив. Update data for each requested product.
Использование
$result = WC_Helper_Updater::_update_check( $payload );
- $payload(массив) (обязательный)
- Information about the plugin to update.
Код WC_Helper_Updater::_update_check() WC Helper Updater:: update check WC 10.4.3
private static function _update_check( $payload ) {
if ( empty( $payload ) ) {
return array();
}
ksort( $payload );
$hash = md5( wp_json_encode( $payload ) );
$cache_key = '_woocommerce_helper_updates';
$data = get_transient( $cache_key );
if ( self::should_use_cached_update_data( $data, $hash ) ) {
return $data['products'];
}
$data = array(
'hash' => $hash,
'updated' => time(),
'products' => array(),
'errors' => array(),
);
if ( WC_Helper::is_site_connected() ) {
$request = WC_Helper_API::post(
'update-check',
array(
'body' => wp_json_encode( array( 'products' => $payload ) ),
'authenticated' => true,
)
);
} else {
$request = WC_Helper_API::post(
'update-check-public',
array(
'body' => wp_json_encode( array( 'products' => $payload ) ),
)
);
}
if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
$data['errors'][] = 'http-error';
} else {
$data['products'] = json_decode( wp_remote_retrieve_body( $request ), true );
}
set_transient( $cache_key, $data, 12 * HOUR_IN_SECONDS );
return $data['products'];
}