wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



move_dir › WordPress Function

Seit5.9.0
Veraltetn/v
move_dir ( $from, $to )
Parameter: (2)
  • (string) $from Source directory.
    Erforderlich: Ja
  • (string) $to Destination directory.
    Erforderlich: Ja
Gibt zurück:
  • (true|WP_Error) True on success, WP_Error on failure.
Definiert in:
Codex:

Moves a directory from one location to another via the rename() PHP function.

If the renaming failed, falls back to copy_dir(). Assumes that WP_Filesystem() has already been called and setup.


Quellcode

function move_dir( $from, $to ) {
	global $wp_filesystem;

	$wp_filesystem->rmdir( $to );
	if ( @rename( $from, $to ) ) {
		return true;
	}

	$wp_filesystem->mkdir( $to );
	$result = copy_dir( $from, $to );

	return $result;
}