Automattic\WooCommerce\Internal\Admin

Homescreen::update_link_structure()publicWC 1.0

Update the WooCommerce menu structure to make our main dashboard/handler the top level link for 'WooCommerce'.

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

Хуков нет.

Возвращает

null. Ничего.

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

$Homescreen = new Homescreen();
$Homescreen->update_link_structure();

Код Homescreen::update_link_structure() WC 6.5.1

public function update_link_structure() {
	global $submenu;
	// User does not have capabilites to see the submenu.
	if ( ! current_user_can( 'manage_woocommerce' ) || empty( $submenu['woocommerce'] ) ) {
		return;
	}

	$wc_admin_key = null;
	foreach ( $submenu['woocommerce'] as $submenu_key => $submenu_item ) {
		if ( self::MENU_SLUG === $submenu_item[2] ) {
			$wc_admin_key = $submenu_key;
			break;
		}
	}

	if ( ! $wc_admin_key ) {
		return;
	}

	$menu = $submenu['woocommerce'][ $wc_admin_key ];

	// Move menu item to top of array.
	unset( $submenu['woocommerce'][ $wc_admin_key ] );
	array_unshift( $submenu['woocommerce'], $menu );
}