WooCommerce settings are located at wp-admin/admin.php?page=wc-settings
and each of the Tabs for its settings is a continuation of the URL query string (ex: wp-admin/admin.php?page=wc-settings&tab=products
for Products).
I know how to use the woocommerce_settings_tabs_array
hook to manipulate the tab itself, but these Tabs also have sub links called "Sections."
For example, Products has General, Inventory, Downloadable Products and Product Vendors for me since I have a premium plugin.
How do I remove these sections from underneath the tab? Specifically, I want to remove the Product Vendors link that that premium extension added.
WooCommerce settings are located at wp-admin/admin.php?page=wc-settings
and each of the Tabs for its settings is a continuation of the URL query string (ex: wp-admin/admin.php?page=wc-settings&tab=products
for Products).
I know how to use the woocommerce_settings_tabs_array
hook to manipulate the tab itself, but these Tabs also have sub links called "Sections."
For example, Products has General, Inventory, Downloadable Products and Product Vendors for me since I have a premium plugin.
How do I remove these sections from underneath the tab? Specifically, I want to remove the Product Vendors link that that premium extension added.
Share Improve this question asked Jun 16, 2018 at 1:07 user658182user658182 6252 gold badges14 silver badges35 bronze badges2 Answers
Reset to default 2To change this "sub navigation" you could use the WooCommerce filter "woocommerce_get_sections_products".
The following example code will remove the sub navigation point "inventory":
function change_navi_function($sections)
{
// remove sub navigation point "inventory"
unset($sections['inventory']);
return $sections;
}
add_filter('woocommerce_get_sections_products', 'change_navi_function');
What you have to do now is either to hook your "change_navi_function" function after the function from the premium plugin and then remove the "Product Vendors" from the "$sections" array. Or you unhook the function from the premium plugin which use the "woocommerce_get_sections_products" filter.
you can find the file in
~/wp-content/plugins/woocommerce/includes/admin/views/html-admin-settings.php
foreach ( $tabs as $slug => $label ) {
echo '<a href="' . esc_html( admin_url( 'admin.php?page=wc-settings&tab=' . esc_attr( $slug ) ) ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
}
and edit html-admin-settings.php
add code
foreach ( $tabs as $slug => $label ) {
if( $slug != "Product"){
echo '<a href="' . esc_html( admin_url( 'admin.php?page=wc-settings&tab=' . esc_attr( $slug ) ) ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
}
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745131073a4612976.html
评论列表(0条)