WP_Theme::translate_header

Advertisement

Private Access Private Access

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Summery Summery

Translate a theme header.

Syntax Syntax

WP_Theme::translate_header( string $header, string|array $value )

Parameters Parameters

$header

(Required) Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.

$value

(Required) Value to translate. An array for Tags header, string otherwise.

Return Return

(string|array) Translated value. An array for Tags header, string otherwise.

Source Source

File: wp-includes/class-wp-theme.php

				// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
				$this->name_translated = translate( $value, $this->get( 'TextDomain' ) );

				return $this->name_translated;
			case 'Tags':
				if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) ) {
					return $value;
				}

				static $tags_list;
				if ( ! isset( $tags_list ) ) {
					$tags_list = array(
						// As of 4.6, deprecated tags which are only used to provide translation for older themes.
						'black'             => __( 'Black' ),
						'blue'              => __( 'Blue' ),
						'brown'             => __( 'Brown' ),
						'gray'              => __( 'Gray' ),
						'green'             => __( 'Green' ),
						'orange'            => __( 'Orange' ),
						'pink'              => __( 'Pink' ),
						'purple'            => __( 'Purple' ),
						'red'               => __( 'Red' ),
						'silver'            => __( 'Silver' ),
						'tan'               => __( 'Tan' ),
						'white'             => __( 'White' ),
						'yellow'            => __( 'Yellow' ),
						'dark'              => __( 'Dark' ),
						'light'             => __( 'Light' ),
						'fixed-layout'      => __( 'Fixed Layout' ),
						'fluid-layout'      => __( 'Fluid Layout' ),
						'responsive-layout' => __( 'Responsive Layout' ),
						'blavatar'          => __( 'Blavatar' ),
						'photoblogging'     => __( 'Photoblogging' ),
						'seasonal'          => __( 'Seasonal' ),
					);

					$feature_list = get_theme_feature_list( false ); // No API.

					foreach ( $feature_list as $tags ) {
						$tags_list += $tags;
					}
				}

				foreach ( $value as &$tag ) {
					if ( isset( $tags_list[ $tag ] ) ) {
						$tag = $tags_list[ $tag ];
					} elseif ( isset( self::$tag_map[ $tag ] ) ) {
						$tag = $tags_list[ self::$tag_map[ $tag ] ];
					}
				}

				return $value;

			default:
				// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
				$value = translate( $value, $this->get( 'TextDomain' ) );
		}
		return $value;
	}

	/**
	 * The directory name of the theme's "stylesheet" files, inside the theme root.
	 *
	 * In the case of a child theme, this is directory name of the child theme.

Advertisement

Changelog Changelog

Changelog
Version Description
3.4.0 Introduced.

Advertisement

Leave a Reply