Automattic\WooCommerce\Internal\ComingSoon

ComingSoonAdminBarBadge::site_visibility_badge()publicWC 1.0

Add site visibility cache badge to WP admin bar.

Метод класса: ComingSoonAdminBarBadge{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$ComingSoonAdminBarBadge = new ComingSoonAdminBarBadge();
$ComingSoonAdminBarBadge->site_visibility_badge( $wp_admin_bar );
$wp_admin_bar(WP_Admin_Bar) (обязательный)
The WP_Admin_Bar instance.

Код ComingSoonAdminBarBadge::site_visibility_badge() WC 9.3.3

public function site_visibility_badge( $wp_admin_bar ) {
	$labels = array(
		'coming-soon'       => __( 'Coming soon', 'woocommerce' ),
		'store-coming-soon' => __( 'Store coming soon', 'woocommerce' ),
		'live'              => __( 'Live', 'woocommerce' ),
	);

	if ( get_option( 'woocommerce_coming_soon' ) === 'yes' ) {
		if ( get_option( 'woocommerce_store_pages_only' ) === 'yes' ) {
			$key = 'store-coming-soon';
		} else {
			$key = 'coming-soon';
		}
	} else {
		$key = 'live';
	}

	$args = array(
		'id'    => 'woocommerce-site-visibility-badge',
		'title' => $labels[ $key ],
		'href'  => admin_url( 'admin.php?page=wc-settings&tab=site-visibility' ),
		'meta'  => array(
			'class' => 'woocommerce-site-status-badge-' . $key,
		),
	);
	$wp_admin_bar->add_node( $args );
}