WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Theme::translate_header() WP 3.4.0

Translate a theme header.

Это метод класса: WP_Theme

Хуков нет.

Возвращает

Строку. Translated value.

Использование

$WP_Theme = new WP_Theme();
$var = $WP_Theme->translate_header( $header, $value );
$header(строка) (обязательный)
Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
$value(строка) (обязательный)
Value to translate.

Заметки

  • Static. Массив. $tags_list

Список изменений

С версии 3.4.0 Введена.

Код WP Theme::translate header: wp-includes/class-wp-theme.php WP 5.2.2

<?php
private function translate_header( $header, $value ) {
	switch ( $header ) {
		case 'Name':
			// Cached for sorting reasons.
			if ( isset( $this->name_translated ) ) {
				return $this->name_translated;
			}
			// 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;
}