简体   繁体   English

向 WooCommerce 管理状态窗口添加自定义选项卡

[英]Add a custom tab to WooCommerce Admin Status window

In the backend under "Woocommerce" > "Status" window, WooCommerce provides three tabs:在“Woocommerce”>“状态”窗口下的后端,WooCommerce 提供了三个选项卡:

  • "System status", "系统状态",
  • "Tools", "工具",
  • "Log' in the". “登录”。

Is there a filter available to add a new tab to this window?是否有过滤器可用于向此窗口添加新选项卡?

Yes this is completely possible, with the 2 hooked functions below.是的,这完全有可能,使用下面的 2 个挂钩函数。

// Add a custom tab to WooCommerce Status section
add_filter('woocommerce_admin_status_tabs','add_custom_admin_status_tabs', 10, 1);
function add_custom_admin_status_tabs( $tabs ){
    $tabs['custom_slug'] = __( 'Custom Title', 'woocommerce' );
    return $tabs;
}

// Add the content of the custom tab to WooCommerce Status section
// ( HERE the hook is made of 'woocommerce_admin_status_content_' + the slug of this tab )
add_action( 'woocommerce_admin_status_content_custom_slug', 'add_custom_admin_status_content_custom_slug' );
function add_custom_admin_status_content_custom_slug(){
    $key_slug = 'custom_slug';
    ?>
    <table class="wc_status_table wc_status_table--<?php echo $key_slug; ?> widefat" cellspacing="0">
        <tbody class="<?php echo $key_slug; ?>">
            <tr class="section-name-1" >
                <th valign="top"  width="20%">
                    <p><strong class="name"><?php _e( 'Section name 1', 'woocommerce' ); ?></strong></p>
                </th>
                <td valign="top" class="content-section-1">
                    <p><?php _e( 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper.', 'woocommerce' ); ?></p>
                </td>
            </tr>
        </tbody>
    </table>
    <?php
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.代码位于活动子主题(或主题)的 function.php 文件或任何插件文件中。

Tested and works.测试和工作。 You will get:你会得到:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM