wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_get_pomo_file_data › WordPress Function

Da3.7.0
Deprecaton/a
› wp_get_pomo_file_data ( $po_file )
Parametri:
  • (string) $po_file Path to PO file.
    Richiesto: Sì
Ritorna:
  • (array<string,string>) Array of PO file header values keyed by header name.
Definito a:
Codex:

Extracts headers from a PO file.



Sorgenti

function wp_get_pomo_file_data( $po_file ) {
	$headers = get_file_data(
		$po_file,
		array(
			'POT-Creation-Date'  => '"POT-Creation-Date',
			'PO-Revision-Date'   => '"PO-Revision-Date',
			'Project-Id-Version' => '"Project-Id-Version',
			'X-Generator'        => '"X-Generator',
		)
	);

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

	foreach ( array_keys( $result ) as $header ) {
		$value = $headers[ $header ];

		// Remove possible closing double quote and the contextual '\n' preceding it.
		if ( str_ends_with( $value, '"' ) ) {
			$value = substr( $value, 0, -1 );
			if ( str_ends_with( $value, '\n' ) ) {
				$value = substr( $value, 0, -2 );
			}
		}

		$result[ $header ] = $value;
	}

	return $result;
}