Language_Pack_Upgrader::check_package( string|WP_Error $source, string $remote_source )

Check the package source to make sure there are .mo and .po files.


Description Description

Hooked to the ‘upgrader_source_selection’ filter by Language_Pack_Upgrader::bulk_upgrade().


Parameters Parameters

$source

(string|WP_Error) (Required)

$remote_source

(string) (Required)


Top ↑

Source Source

File: wp-admin/includes/class-language-pack-upgrader.php

	public function check_package( $source, $remote_source ) {
		global $wp_filesystem;

		if ( is_wp_error( $source ) )
			return $source;

		// Check that the folder contains a valid language.
		$files = $wp_filesystem->dirlist( $remote_source );

		// Check to see if a .po and .mo exist in the folder.
		$po = $mo = false;
		foreach ( (array) $files as $file => $filedata ) {
			if ( '.po' == substr( $file, -3 ) )
				$po = true;
			elseif ( '.mo' == substr( $file, -3 ) )
				$mo = true;
		}

		if ( ! $mo || ! $po ) {
			return new WP_Error( 'incompatible_archive_pomo', $this->strings['incompatible_archive'],
				/* translators: 1: .po 2: .mo */
				sprintf( __( 'The language pack is missing either the %1$s or %2$s files.' ),
					'<code>.po</code>',
					'<code>.mo</code>'
				)
			);
		}

		return $source;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.7.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.