函数文档

_admin_search_query()

💡 云策文档标注

概述

_admin_search_query() 是一个 WordPress 函数,用于显示 GET URI 中的“s”参数搜索查询,作为 the_search_query() 的替代方案。

关键要点

  • 函数功能:输出 $_REQUEST['s'] 参数的值,经过 wp_unslash() 和 esc_attr() 处理以确保安全。
  • 使用场景:当 the_search_query() 无法使用时,用于在管理界面显示搜索查询。
  • 相关函数:依赖 wp_unslash() 移除反斜杠和 esc_attr() 进行 HTML 属性转义。
  • 版本历史:自 WordPress 2.7.0 版本引入。

📄 原文内容

Displays the search query.

Description

A simple wrapper to display the “s” parameter in a GET URI. This function should only be used when the_search_query() cannot.

Source

function _admin_search_query() {
	echo isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
}

Changelog

Version Description
2.7.0 Introduced.