Automattic\WooCommerce\Internal\Admin\Notes

WooSubscriptionsNotes::admin_init()publicWC 1.0

Method of the class: WooSubscriptionsNotes{}

No Hooks.

Return

null. Nothing (null).

Usage

$WooSubscriptionsNotes = new WooSubscriptionsNotes();
$WooSubscriptionsNotes->*/;

WooSubscriptionsNotes::admin_init() code WC 8.7.0

*/
	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 );