WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта
функция не описана

Language_Pack_Upgrader::check_package() public WP 3.7.0

Checks that the package source contains .mo and .po files.

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

{} Это метод класса: Language_Pack_Upgrader{}

Хуков нет.

Возвращает

Строку|WP_Error. The source as passed, or a WP_Error object on failure.

Использование

$Language_Pack_Upgrader = new Language_Pack_Upgrader();
$Language_Pack_Upgrader->check_package( $source, $remote_source );
$source(строка|WP_Error) (обязательный)
The path to the downloaded package source.
$remote_source(строка) (обязательный)
Remote file source location.

Заметки

  • Global. WP_Filesystem_Base. $wp_filesystem WordPress filesystem subclass.

Список изменений

С версии 3.7.0 Введена.

Код Language_Pack_Upgrader::check_package() WP 5.8

<?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 = false;
	$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'],
			sprintf(
				/* translators: 1: .po, 2: .mo */
				__( 'The language pack is missing either the %1$s or %2$s files.' ),
				'<code>.po</code>',
				'<code>.mo</code>'
			)
		);
	}

	return $source;
}