WP_Filesystem_Direct::copy( string $source, string $destination, bool $overwrite = false, int|false $mode = false ): bool
- Since
- 2.5.0
- Source
wp-admin/includes/class-wp-filesystem-direct.php:304
Copies a file.
Parameters
$sourcestring- Path to the source file.
$destinationstring- Path to the destination file.
$overwritebooloptional- Whether to overwrite the destination file if it exists. Default false.Default:
false $modeint|falseoptional- The permissions as octal number, usually 0644 for files, 0755 for dirs. Default false.Default:
false
Return
bool- True on success, false on failure.
Uses · 2
- WP_Filesystem_Direct::exists()Checks if a file or directory exists.
- WP_Filesystem_Direct::chmod()Changes filesystem permissions.
Used by · 1
- WP_Filesystem_Direct::move()Moves a file or directory.
Source
public function copy( $source, $destination, $overwrite = false, $mode = false ) { if ( ! $overwrite && $this->exists( $destination ) ) { return false; } $rtval = copy( $source, $destination ); if ( $mode ) { $this->chmod( $destination, $mode ); } return $rtval; }History
Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-admin/includes/class-wp-filesystem-direct.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.