wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_get_l10n_php_file_data › WordPress Function

Od6.6.0
Przestarzałyn/a
› wp_get_l10n_php_file_data ( $php_file )
Parametry:
  • (string) $php_file Path to a `.l10n.php` file.
    Wymagane: Tak
Powrót:
  • (array<string,string>) Array of file header values keyed by header name.
Zdefiniowane na:
Codex:

Extracts headers from a PHP translation file.



Źródło

function wp_get_l10n_php_file_data( $php_file ) {
	$data = (array) include $php_file;

	unset( $data['messages'] );

	// The revision date field has a different name depending on the source, support both.
	$headers = array(
		'POT-Creation-Date'  => array( 'pot-creation-date' ),
		'PO-Revision-Date'   => array( 'translation-revision-date', 'po-revision-date' ),
		'Project-Id-Version' => array( 'project-id-version' ),
		'X-Generator'        => array( 'x-generator' ),
	);

	$result = array(
		'POT-Creation-Date'  => '',
		'PO-Revision-Date'   => '',
		'Project-Id-Version' => '',
		'X-Generator'        => '',
	);

	foreach ( $headers as $po_header => $php_headers ) {
		foreach ( $php_headers as $php_header ) {
			if ( isset( $data[ $php_header ] ) && is_string( $data[ $php_header ] ) ) {
				$result[ $po_header ] = $data[ $php_header ];
				break;
			}
		}
	}

	return $result;
}