[英]Add submenu entry to WooCommerce "Products" admin menu
I would like to add a submenu entry under the WooCommerce "Products" admin menu.我想在 WooCommerce“产品”管理菜单下添加一个子菜单条目。 Does anybody know what the $parent_slug for this menu is?
有人知道这个菜单的 $parent_slug 是什么吗?
I can add a submenu item to the "WooCommerce" menu using add_submenu_page
and 'woocommerce' for $parent_slug
(via the admin_menu
hook), but can't seem to figure out what the $parent_slug
for the Products menu is...我可以使用
add_submenu_page
和 'woocommerce' 为$parent_slug
添加一个子菜单项到“WooCommerce”菜单(通过admin_menu
挂钩),但似乎无法弄清楚 Products 菜单的$parent_slug
是什么......
if ( is_admin() ) {
add_action( 'admin_menu', 'add_products_menu_entry', 100 );
}
function add_products_menu_entry() {
add_submenu_page(
'woocommerce-product', // This is what I can't figure out
__( 'Product Grabber' ),
__( 'Grab New' ),
'manage_woocommerce', // Required user capability
'ddg-product',
'generate_grab_product_page'
);
}
function generate_grab_product_page() {
// Page generation code will go here
}
WooCommerce Products Admin Menu WooCommerce 产品管理菜单
Got it, it was edit.php?post_type=product
明白了,是
edit.php?post_type=product
if ( is_admin() ) {
add_action( 'admin_menu', 'add_products_menu_entry', 100 );
}
function add_products_menu_entry() {
add_submenu_page(
'edit.php?post_type=product',
__( 'Product Grabber' ),
__( 'Grab New' ),
'manage_woocommerce', // Required user capability
'ddg-product',
'generate_grab_product_page'
);
}
function generate_grab_product_page() {
echo "<h2>Hello, it worked! :-)</h2>";
}
Thank-you to Derick Rethans / XDebug!感谢 Derick Rethans / XDebug!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.