WC_Admin_Marketplace_Promotions::init()public staticWC 1.0

On all admin pages, try go get Marketplace promotions every day. Shows notice and adds menu badge to WooCommerce Extensions item if the promotions API requests them.

WC_Admin calls this method when it is instantiated during is_admin requests.

Method of the class: WC_Admin_Marketplace_Promotions{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = WC_Admin_Marketplace_Promotions::init();

WC_Admin_Marketplace_Promotions::init() code WC 9.8.5

public static function init() {
	// A legacy hook that can be triggered by action scheduler.
	add_action( 'woocommerce_marketplace_fetch_promotions', array( __CLASS__, 'clear_deprecated_action' ) );
	add_action(
		'woocommerce_marketplace_fetch_promotions_clear',
		array(
			__CLASS__,
			'clear_deprecated_scheduled_event',
		)
	);

	// Fetch promotions from the API and store them in a transient.
	add_action( self::CRON_NAME, array( __CLASS__, 'update_promotions' ) );

	if (
		defined( 'DOING_AJAX' ) && DOING_AJAX
		|| defined( 'DOING_CRON' ) && DOING_CRON
		|| defined( 'WP_CLI' ) && WP_CLI
	) {
		return;
	}

	if ( ! is_admin() ) {
		return;
	}

	self::schedule_cron_event();

	register_deactivation_hook( WC_PLUGIN_FILE, array( __CLASS__, 'clear_cron_event' ) );

	self::$locale = ( self::$locale ?? get_user_locale() ) ?? 'en_US';
	self::maybe_show_bubble_promotions();
}