Automattic\WooCommerce\Internal\Admin
WcPayWelcomePage::register_menu_and_page()
Registers the WooPayments welcome page.
Метод класса: WcPayWelcomePage{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$WcPayWelcomePage = new WcPayWelcomePage(); $WcPayWelcomePage->register_menu_and_page();
Код WcPayWelcomePage::register_menu_and_page() WcPayWelcomePage::register menu and page WC 9.5.1
public function register_menu_and_page() { global $menu; // The WooPayments plugin must not be active. if ( $this->is_wcpay_active() ) { return; } $menu_title = esc_html__( 'Payments', 'woocommerce' ); $menu_icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4NTIiIGhlaWdodD0iNjg0Ij48cGF0aCBmaWxsPSIjYTJhYWIyIiBkPSJNODIgODZ2NTEyaDY4NFY4NlptMCA1OThjLTQ4IDAtODQtMzgtODQtODZWODZDLTIgMzggMzQgMCA4MiAwaDY4NGM0OCAwIDg0IDM4IDg0IDg2djUxMmMwIDQ4LTM2IDg2LTg0IDg2em0zODQtNTU2djQ0aDg2djg0SDM4MnY0NGgxMjhjMjQgMCA0MiAxOCA0MiA0MnYxMjhjMCAyNC0xOCA0Mi00MiA0MmgtNDR2NDRoLTg0di00NGgtODZ2LTg0aDE3MHYtNDRIMzM4Yy0yNCAwLTQyLTE4LTQyLTQyVjIxNGMwLTI0IDE4LTQyIDQyLTQyaDQ0di00NHoiLz48L3N2Zz4='; // If an incentive is visible, we register the WooPayments welcome/incentives page. // Otherwise, we register a menu item that links to the Payments task page. if ( $this->is_incentive_visible() ) { $page_id = 'wc-calypso-bridge-payments-welcome-page'; $page_options = array( 'id' => $page_id, 'title' => $menu_title, 'capability' => 'manage_woocommerce', 'path' => '/wc-pay-welcome-page', 'position' => '56', 'icon' => $menu_icon, ); wc_admin_register_page( $page_options ); $menu_path = PageController::get_instance()->get_path_from_id( $page_id ); // Registering a top level menu via wc_admin_register_page doesn't work when the new // nav is enabled. The new nav disabled everything, except the 'WooCommerce' menu. // We need to register this menu via add_menu_page so that it doesn't become a child of // WooCommerce menu. if ( get_option( 'woocommerce_navigation_enabled', 'no' ) === 'yes' ) { $menu_path = 'admin.php?page=wc-admin&path=/wc-pay-welcome-page'; $menu_with_nav_data = array( $menu_title, $menu_title, 'manage_woocommerce', $menu_path, null, $menu_icon, 56, ); call_user_func_array( 'add_menu_page', $menu_with_nav_data ); } } else { // Default to linking to the Payments settings page. $menu_path = 'admin.php?page=wc-settings&tab=checkout'; // Determine the path to the active Payments task page, if any. $task_slug = $this->get_active_payments_task_slug(); if ( ! empty( $task_slug ) ) { $menu_path = 'admin.php?page=wc-admin&task=' . $task_slug; } add_menu_page( $menu_title, $menu_title, 'manage_woocommerce', $menu_path, null, $menu_icon, 56, ); } // Maybe add a badge to the menu. // If the main Payments task is not complete, we add a badge to the Payments menu item. // We use the complete logic of the main Payments task because it is the most general one. if ( ! empty( $this->get_payments_task() ) && ! $this->is_payments_task_complete() ) { $badge = ' <span class="wcpay-menu-badge awaiting-mod count-1"><span class="plugin-count">1</span></span>'; foreach ( $menu as $index => $menu_item ) { // Only add the badge markup if not already present and the menu item is the Payments menu item. if ( 0 === strpos( $menu_item[0], $menu_title ) && $menu_path === $menu_item[2] && false === strpos( $menu_item[0], $badge ) ) { $menu[ $index ][0] .= $badge; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited // One menu item with a badge is more than enough. break; } } } }