WP_Upgrader::delete_temp_backup(): bool|WP_Error

In this article

Deletes a temporary backup.

Return

bool|WP_Error True on success, false on early exit, otherwise WP_Error.

Source

public function delete_temp_backup() {
	global $wp_filesystem;

	$errors = new WP_Error();

	foreach ( $this->temp_backups as $args ) {
		if ( empty( $args['slug'] ) || empty( $args['dir'] ) ) {
			return false;
		}

		if ( ! $wp_filesystem->wp_content_dir() ) {
			$errors->add( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
			return $errors;
		}

		$temp_backup_dir = $wp_filesystem->wp_content_dir() . "upgrade-temp-backup/{$args['dir']}/{$args['slug']}";

		if ( ! $wp_filesystem->delete( $temp_backup_dir, true ) ) {
			$errors->add(
				'temp_backup_delete_failed',
				sprintf( $this->strings['temp_backup_delete_failed'], $args['slug'] )
			);
			continue;
		}
	}

	return $errors->has_errors() ? $errors : true;
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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