Automattic\WooCommerce\Internal\Admin

WcPaySubscriptionsPage::register_subscriptions_page()publicWC 1.0

Registers the WooCommerce → Subscriptions admin page.

{} Это метод класса: WcPaySubscriptionsPage{}

Хуков нет.

Возвращает

null. Ничего.

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

$WcPaySubscriptionsPage = new WcPaySubscriptionsPage();
$WcPaySubscriptionsPage->register_subscriptions_page();

Код WcPaySubscriptionsPage::register_subscriptions_page() WC 6.6.1

public function register_subscriptions_page() {
	global $submenu;

	if ( 'yes' === get_option( $this->user_dismissed_option, 'no' ) ) {
		return;
	}

	if ( 'yes' !== get_option( 'woocommerce_allow_tracking', 'no' ) ) {
		return;
	}

	if ( ! $this->is_store_experiment_eligible() ) {
		return;
	}

	$menu_data = array(
		'id'         => $this->page_id,
		'title'      => _x( 'Subscriptions', 'Admin menu name', 'woocommerce' ),
		'parent'     => 'woocommerce',
		'path'       => '/subscriptions',
		'capability' => 'manage_options',
	);

	wc_admin_register_page( $menu_data );

	if ( ! isset( $submenu['woocommerce'] ) || 'yes' === get_option( $this->user_viewed_option, 'no' ) ) {
		return;
	}

	// translators: Admin menu item badge. It is used alongside the "Subscriptions" menu item to grab attention and let merchants know that this is a new offering.
	$new_badge_text = __( 'new', 'woocommerce' );

	// Add the "new" badge.
	foreach ( $submenu['woocommerce'] as $key => $menu_item ) {
		if ( self::SUBSCRIPTION_MENU_ITEM_SLUG === $menu_item[2] ) {
			$submenu['woocommerce'][ $key ][0] .= sprintf( ' <span class="wcpay-subscriptions-menu-badge awaiting-mod count-1"><span class="plugin-count">%s</span></span>', esc_html( $new_badge_text ) ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
			break;
		}
	}
}