WP_Translation_File_PHP::parse_file()protectedWP 6.5.0

Parses the file.

Method of the class: WP_Translation_File_PHP{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->parse_file();

Changelog

Since 6.5.0 Introduced.

WP_Translation_File_PHP::parse_file() code WP 6.7.1

protected function parse_file() {
	$this->parsed = true;

	$result = include $this->file;
	if ( ! $result || ! is_array( $result ) ) {
		$this->error = 'Invalid data';
		return;
	}

	if ( isset( $result['messages'] ) && is_array( $result['messages'] ) ) {
		foreach ( $result['messages'] as $original => $translation ) {
			$this->entries[ (string) $original ] = $translation;
		}
		unset( $result['messages'] );
	}

	$this->headers = array_change_key_case( $result );
}