钩子文档

views_{$this->screen->id}

💡 云策文档标注

概述

views_{$this->screen->id} 是一个 WordPress 过滤器钩子,用于过滤当前屏幕可用的列表视图数组。它允许开发者自定义或修改后台列表表格的视图选项。

关键要点

  • 钩子名称是动态的,基于当前屏幕的 ID,格式为 views_{$this->screen->id}。
  • 参数 $views 是一个字符串数组,表示可用的列表视图。
  • 通过 apply_filters 调用,开发者可以添加、移除或修改视图项。
  • 在 WP_List_Table 及其子类(如 WP_Media_List_Table 和 WP_Plugin_Install_List_Table)中使用,支持过滤栏显示。
  • 自 WordPress 3.1.0 版本引入。

📄 原文内容

Filters the list of available list table views.

Description

The dynamic portion of the hook name, $this->screen->id, refers to the ID of the current screen.

Parameters

$viewsstring[]
An array of available list table views.

Source

$views = apply_filters( "views_{$this->screen->id}", $views );

Changelog

Version Description
3.1.0 Introduced.