Docs: Clarify that `WP_Theme::get()`, `::display()`, and several related methods treat the `Tags` theme header as an array.

Props david.binda.
Fixes #48005.

git-svn-id: https://develop.svn.wordpress.org/trunk@46751 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-11-20 08:29:36 +00:00
parent 944502a094
commit 2d097fd6b8
1 changed files with 15 additions and 12 deletions

View File

@ -734,7 +734,7 @@ final class WP_Theme implements ArrayAccess {
* @since 3.4.0
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @return string|false String on success, false on failure.
* @return string|array|false String or array (for Tags header) on success, false on failure.
*/
public function get( $header ) {
if ( ! isset( $this->headers[ $header ] ) ) {
@ -773,7 +773,8 @@ final class WP_Theme implements ArrayAccess {
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param bool $markup Optional. Whether to mark up the header. Defaults to true.
* @param bool $translate Optional. Whether to translate the header. Defaults to true.
* @return string|false Processed header, false on failure.
* @return string|array|false Processed header. An array for Tags if `$markup` is false, string otherwise.
* False on failure.
*/
public function display( $header, $markup = true, $translate = true ) {
$value = $this->get( $header );
@ -806,7 +807,7 @@ final class WP_Theme implements ArrayAccess {
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param string $value Value to sanitize.
* @return mixed
* @return string|array An array for Tags header, string otherwise.
*/
private function sanitize_header( $header, $value ) {
switch ( $header ) {
@ -824,6 +825,7 @@ final class WP_Theme implements ArrayAccess {
'em' => true,
'strong' => true,
);
$value = wp_kses( $value, $header_tags );
break;
case 'Author':
@ -840,6 +842,7 @@ final class WP_Theme implements ArrayAccess {
'em' => true,
'strong' => true,
);
$value = wp_kses( $value, $header_tags_with_a );
break;
case 'ThemeURI':
@ -865,7 +868,7 @@ final class WP_Theme implements ArrayAccess {
* @staticvar string $comma
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param string $value Value to mark up.
* @param string|array $value Value to mark up. An array for Tags header, string otherwise.
* @param string $translate Whether the header has been translated.
* @return string Value, marked up.
*/
@ -911,8 +914,8 @@ final class WP_Theme implements ArrayAccess {
* @staticvar array $tags_list
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param string $value Value to translate.
* @return string Translated value.
* @param string|array $value Value to translate. An array for Tags header, string otherwise.
* @return string|array Translated value. An array for Tags header, string otherwise.
*/
private function translate_header( $header, $value ) {
switch ( $header ) {