1

有什么方法可以删除 wordpress 上的帮助标签?我希望删除这些选项卡而不是用 css 隐藏它们。

在 wp-admin/includes/screen.php 上有几行提到了这一点,但不知道如何创建一些东西来删除帮助选项卡。

有什么方法可以创建类似于:add_filter('screen_options_show_screen', '__return_false');但要删除帮助选项卡?

从 screen.php 文件中:

647      /**
 648       * Removes a help tab from the contextual help for the screen.
 649       *
 650       * @since 3.3.0
 651       *
 652       * @param string $id The help tab ID.
 653       */
 654    public function remove_help_tab( $id ) {
 655          unset( $this->_help_tabs[ $id ] );
 656      }
 657  
 658      /**
 659       * Removes all help tabs from the contextual help for the screen.
 660       *
 661       * @since 3.3.0
 662       */
 663    public function remove_help_tabs() {
 664          $this->_help_tabs = array();
 665      }
4

1 回答 1

2

您需要使用contextual_help帮助过滤器。

add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
function wpse50723_remove_help($old_help, $screen_id, $screen){
    $screen->remove_help_tabs();
    return $old_help;
}

过滤器用于旧的上下文帮助(3.3 之前)。(我不确定返回的内容是否重要......?)。

在任何情况下,过滤器都应该被延迟调用(因此为 999),因为插件可以将它们自己的帮助选项卡添加到页面中。这就是为什么admin_head不是一个理想的钩子的部分原因。

这也将起作用

add_action('admin_head', 'mytheme_remove_help_tabs');
function mytheme_remove_help_tabs() {
    $screen = get_current_screen();
    $screen->remove_help_tabs();
}

但第一个选择是安全的

于 2012-05-02T09:31:32.573 回答