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

WP_Upgrader::clear_destination() public WP 4.3.0

Clears the directory where this item is going to be installed into.

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

Хуков нет.

Возвращает

true/false/WP_Error. True upon success, WP_Error on failure.

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

$WP_Upgrader = new WP_Upgrader();
$WP_Upgrader->clear_destination( $remote_destination );
$remote_destination(строка) (обязательный)
The location on the remote filesystem to be cleared

Заметки

  • Global. WP_Filesystem_Base. $wp_filesystem WordPress filesystem subclass.

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

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

Код WP_Upgrader::clear_destination() WP 5.5.1

wp-admin/includes/class-wp-upgrader.php
<?php
public function clear_destination( $remote_destination ) {
	global $wp_filesystem;

	$files = $wp_filesystem->dirlist( $remote_destination, true, true );

	// False indicates that the $remote_destination doesn't exist.
	if ( false === $files ) {
		return true;
	}

	// Flatten the file list to iterate over.
	$files = $this->flatten_dirlist( $files );

	// Check all files are writable before attempting to clear the destination.
	$unwritable_files = array();

	// Check writability.
	foreach ( $files as $filename => $file_details ) {
		if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
			// Attempt to alter permissions to allow writes and try again.
			$wp_filesystem->chmod( $remote_destination . $filename, ( 'd' === $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) );
			if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
				$unwritable_files[] = $filename;
			}
		}
	}

	if ( ! empty( $unwritable_files ) ) {
		return new WP_Error( 'files_not_writable', $this->strings['files_not_writable'], implode( ', ', $unwritable_files ) );
	}

	if ( ! $wp_filesystem->delete( $remote_destination, true ) ) {
		return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] );
	}

	return true;
}