Automattic\WooCommerce\Internal\Admin\Notes
ExtensionsWithoutSubscription::may_fetch
Whether this page load may fetch the subscription list from WooCommerce.com.
The fetch blocks the page, so only a connected store without a cached list fetches: once a day, or right after it connects.
Метод класса: ExtensionsWithoutSubscription{}
Хуков нет.
Возвращает
bool.
Использование
$result = ExtensionsWithoutSubscription::may_fetch(): bool;
Код ExtensionsWithoutSubscription::may_fetch() ExtensionsWithoutSubscription::may fetch WC 11.3.0
private static function may_fetch(): bool {
if ( ! class_exists( 'WC_Helper' ) ) {
return false;
}
// Nothing to fetch: a store that isn't connected has no list, and a cached one is already in use.
if ( ! \WC_Helper::is_site_connected() || \WC_Helper::has_cached_subscriptions() ) {
return false;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read only, the same signal WooSubscriptionsNotes uses.
if ( isset( $_GET['wc-helper-status'] ) ) {
return true;
}
$now = time();
if ( (int) get_option( self::LAST_FETCH_OPTION_KEY, 0 ) + DAY_IN_SECONDS > $now ) {
return false;
}
update_option( self::LAST_FETCH_OPTION_KEY, $now, false );
return true;
}