# _get_plugin_data_markup_translate()

URL: https://chugunov.pro/api-wordpress/functions/_get_plugin_data_markup_translate/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.7.0.

## Сигнатура

```php
_get_plugin_data_markup_translate( string $plugin_file, array $plugin_data, bool $markup = true, bool $translate = true ): array
```

## Описание

См. alsoget_plugin_data()

## Параметры

- `$plugin_file` `string` — обязательный. Путь к главному файлу плагина.
- `$plugin_data` `array` — обязательный. Массив данных плагина. См. get_plugin_data() .
- `$markup` `bool` — необязательный, по умолчанию `true`. Нужно ли применять HTML-разметку к возвращаемым данным.
- `$translate` `bool` — необязательный, по умолчанию `true`. Нужно ли переводить возвращаемые данные.

## Возвращаемое значение

`array` — get_plugin_data()

## Исходный код

Файл: `wp-admin/includes/plugin.php:140`

```php
function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) {

	// Sanitize the plugin filename to a WP_PLUGIN_DIR relative path.
	$plugin_file = plugin_basename( $plugin_file );

	// Translate fields.
	if ( $translate ) {
		$textdomain = $plugin_data['TextDomain'];
		if ( $textdomain ) {
			if ( ! is_textdomain_loaded( $textdomain ) ) {
				if ( $plugin_data['DomainPath'] ) {
					load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] );
				} else {
					load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) );
				}
			}
		} elseif ( 'hello.php' === basename( $plugin_file ) ) {
			$textdomain = 'default';
		}
		if ( $textdomain ) {
			foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
				if ( ! empty( $plugin_data[ $field ] ) ) {
					// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
					$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
				}
			}
		}
	}

	// Sanitize fields.
	$allowed_tags_in_links = array(
		'abbr'    => array( 'title' => true ),
		'acronym' => array( 'title' => true ),
		'code'    => true,
		'em'      => true,
		'strong'  => true,
	);

	$allowed_tags      = $allowed_tags_in_links;
	$allowed_tags['a'] = array(
		'href'  => true,
		'title' => true,
	);

	/*
	 * Name is marked up inside <a> tags. Don't allow these.
	 * Author is too, but some plugins have used <a> here (omitting Author URI).
	 */
	$plugin_data['Name']   = wp_kses( $plugin_data['Name'], $allowed_tags_in_links );
	$plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags );

	$plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags );
	$plugin_data['Version']     = wp_kses( $plugin_data['Version'], $allowed_tags );

	$plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] );
	$plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] );

	$plugin_data['Title']      = $plugin_data['Name'];
	$plugin_data['AuthorName'] = $plugin_data['Author'];

	// Apply markup.
	if ( $markup ) {
		if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) {
			$plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>';
		}

		if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) {
			$plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
		}

		$plugin_data['Description'] = wptexturize( $plugin_data['Description'] );

		if ( $plugin_data['Author'] ) {
			$plugin_data['Description'] .= sprintf(
				/* translators: %s: Plugin author. */
				' <cite>' . __( 'By %s.' ) . '</cite>',
				$plugin_data['Author']
			);
		}
	}

	return $plugin_data;
}
```

## История изменений

- 2.7.0 — Introduced.

## Связанные

Использует: [`is_textdomain_loaded`](https://chugunov.pro/api-wordpress/functions/is_textdomain_loaded/), [`load_plugin_textdomain`](https://chugunov.pro/api-wordpress/functions/load_plugin_textdomain/), [`translate`](https://chugunov.pro/api-wordpress/functions/translate/), [`wptexturize`](https://chugunov.pro/api-wordpress/functions/wptexturize/), [`wp_kses`](https://chugunov.pro/api-wordpress/functions/wp_kses/), [`plugin_basename`](https://chugunov.pro/api-wordpress/functions/plugin_basename/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`esc_url`](https://chugunov.pro/api-wordpress/functions/esc_url/).
Используется в: `WP_REST_Plugins_Controller::prepare_item_for_response`, `WP_Plugins_List_Table::prepare_items`, [`get_plugin_data`](https://chugunov.pro/api-wordpress/functions/get_plugin_data/), [`list_plugin_updates`](https://chugunov.pro/api-wordpress/functions/list_plugin_updates/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/_get_plugin_data_markup_translate/
