WC_Helper_Updater::_update_check()private staticWC 1.0

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 6.4.1

private static function _update_check( $payload ) {
	ksort( $payload );
	$hash = md5( wp_json_encode( $payload ) );

	$cache_key = '_woocommerce_helper_updates';
	$data      = get_transient( $cache_key );
	if ( false !== $data ) {
		if ( hash_equals( $hash, $data['hash'] ) ) {
			return $data['products'];
		}
	}

	$data = array(
		'hash'     => $hash,
		'updated'  => time(),
		'products' => array(),
		'errors'   => array(),
	);

	$request = WC_Helper_API::post(
		'update-check',
		array(
			'body'          => wp_json_encode( array( 'products' => $payload ) ),
			'authenticated' => true,
		)
	);

	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'];
}