Automattic\WooCommerce\Internal\Admin\Settings
PaymentsController::add_menu
Adds the Payments top-level menu item.
Метод класса: PaymentsController{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$PaymentsController = new PaymentsController(); $PaymentsController->add_menu();
Код PaymentsController::add_menu() PaymentsController::add menu WC 10.5.0
public function add_menu() {
global $menu;
// When the WooPayments account is onboarded, WooPayments will own the Payments menu item since it is the native Woo payments solution.
if ( $this->is_woopayments_account_onboarded() ) {
return;
} else {
// Otherwise, remove the Payments menu item linking to the Connect page to avoid Payments menu item duplication.
remove_menu_page( 'wc-admin&path=/payments/connect' );
}
$menu_title = esc_html__( 'Payments', 'woocommerce' );
$menu_icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4NTIiIGhlaWdodD0iNjg0Ij48cGF0aCBmaWxsPSIjYTJhYWIyIiBkPSJNODIgODZ2NTEyaDY4NFY4NlptMCA1OThjLTQ4IDAtODQtMzgtODQtODZWODZDLTIgMzggMzQgMCA4MiAwaDY4NGM0OCAwIDg0IDM4IDg0IDg2djUxMmMwIDQ4LTM2IDg2LTg0IDg2em0zODQtNTU2djQ0aDg2djg0SDM4MnY0NGgxMjhjMjQgMCA0MiAxOCA0MiA0MnYxMjhjMCAyNC0xOCA0Mi00MiA0MmgtNDR2NDRoLTg0di00NGgtODZ2LTg0aDE3MHYtNDRIMzM4Yy0yNCAwLTQyLTE4LTQyLTQyVjIxNGMwLTI0IDE4LTQyIDQyLTQyaDQ0di00NHoiLz48L3N2Zz4=';
// Link to the Payments settings page.
$menu_path = 'admin.php?page=wc-settings&tab=checkout&from=' . Payments::FROM_PAYMENTS_MENU_ITEM;
add_menu_page(
$menu_title,
$menu_title,
'manage_woocommerce', // Capability required to see the menu item.
$menu_path,
null,
$menu_icon,
56, // Position after WooCommerce Product menu item.
);
// If there are providers with an active incentive, add a notice badge to the Payments menu item.
if ( $this->store_has_providers_with_incentive() ) {
$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;
}
}
}
}