函数文档

register_column_headers()

💡 云策文档标注

概述

register_column_headers() 函数用于为特定屏幕注册列标题,通常与列表表相关。它通过创建 _WP_List_Table_Compat 对象来实现功能。

关键要点

  • 函数接受两个参数:$screen(屏幕句柄,通常来自 add_*_page() 函数返回的 hook 名)和 $columns(数组,键为列 ID,值为翻译后的列名)。
  • 内部调用 _WP_List_Table_Compat 类的构造函数来注册列标题。
  • 相关函数包括 get_column_headers()、print_column_headers() 和 get_hidden_columns(),用于获取、打印或管理隐藏列。
  • 自 WordPress 2.7.0 版本引入。

📄 原文内容

Register column headers for a particular screen.

Description

See also

Parameters

$screenstringrequired
The handle for the screen to register column headers for. This is usually the hook name returned by the add_*_page() functions.
$columnsstring[]required
An array of columns with column IDs as the keys and translated column names as the values.

Source

function register_column_headers( $screen, $columns ) {
	new _WP_List_Table_Compat( $screen, $columns );
}

Changelog

Version Description
2.7.0 Introduced.