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. Use get_plugin_data() instead.

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

Sanitizes plugin data, optionally adds markup, optionally translates.


Description

See also


Parameters

$plugin_file

(Required) Path to the main plugin file.

$plugin_data

(Required) An array of plugin data. See get_plugin_data().

$markup

(Optional) If the returned data should have HTML markup applied.<br>

Default value: true

$translate

(Optional) If the returned data should be translated.

Default value: true


Return

(array) Plugin data. Values will be empty if not supplied by the plugin.<br> See get_plugin_data() for the list of possible values.


Source

File: wp-admin/includes/plugin.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 ) {
		if ( $textdomain = $plugin_data['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 ) );
				}
			}
		}
		if ( $textdomain ) {
			foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field )
				$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
		}
	}

	// Sanitize fields
	$allowed_tags = $allowed_tags_in_links = array(
		'abbr'    => array( 'title' => true ),
		'acronym' => array( 'title' => true ),
		'code'    => true,
		'em'      => true,
		'strong'  => true,
	);
	$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'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>';
	}

	return $plugin_data;
}


Changelog

Changelog
Version Description
2.7.0 Introduced.