filters - How can I remove a WooCommerce Product Tab's sub section in wp-admin?

WooCommerce settings are located at wp-adminadmin.php?page=wc-settings and each of the Tabs for its settings is a conti

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 badges
Add a comment  | 

2 Answers 2

Reset to default 2

To 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信