Automattic\WooCommerce\Internal\Admin\Notes
WooSubscriptionsNotes::admin_head()
Runs on admin_head Checks the connection and refreshes subscription notes on relevant pages.
Method of the class: WooSubscriptionsNotes{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WooSubscriptionsNotes = new WooSubscriptionsNotes(); $WooSubscriptionsNotes->admin_head();
WooSubscriptionsNotes::admin_head() WooSubscriptionsNotes::admin head code WC 9.3.3
public function admin_head() { if ( ! PageController::is_admin_or_embed_page() ) { // To avoid unnecessarily calling Helper API, we only want to refresh subscription notes, // if the request is initiated from the wc admin dashboard or a WC related page which includes // the Activity button in WC header. return; } $this->check_connection(); if ( $this->is_connected() ) { $refresh_notes = false; // Did the user just do something on the helper page?. if ( isset( $_GET['wc-helper-status'] ) ) { // @codingStandardsIgnoreLine. $refresh_notes = true; } // Has it been more than a day since we last checked? // Note: We do it this way and not wp_scheduled_task since WC_Helper_Options is not loaded for cron. $time_now_gmt = current_time( 'timestamp', 0 ); $last_refresh = intval( get_option( self::LAST_REFRESH_OPTION_KEY, 0 ) ); if ( $last_refresh + DAY_IN_SECONDS <= $time_now_gmt ) { update_option( self::LAST_REFRESH_OPTION_KEY, $time_now_gmt ); $refresh_notes = true; } if ( $refresh_notes ) { $this->refresh_subscription_notes(); } } }