Description
Function bw_relocate
Usage
bw_relocate( $thisfile, $from, $to );Parameters
- $thisfile
- ( string ) required – FILE
- $from
- ( string ) required – relative path within the plugins directory of the file to relocate
- $to
- ( string ) required – relative path within the plugins directory of the new target file Processing depends on the presence of the $from and $to files The migration may require multiple steps – depending on what's active $to exists $from exists Processing ———— ———— ————– Y Y delete the original file Y N processing is complete N Y move the file from $from to $to N N ERROR
Returns
voidSource
File name: oik/admin/oik-relocate.incLines:
1 to 30 of 30
function bw_relocate( $thisfile, $from, $to ) { $plugindir = plugin_dir_path( $thisfile ); //echo "WP_PLUGIN_DIR: " . WP_PLUGIN_DIR . PHP_EOL; //echo "thisfile: " . $thisfile . PHP_EOL; //echo "plugindir: " . $plugindir . PHP_EOL; $plugindir = WP_PLUGIN_DIR . '/'; $fromfile = $plugindir . $from; $tofile = $plugindir . $to; $fromexists = file_exists( $fromfile ); $toexists = file_exists( $tofile ); if ( $toexists ) { if ( $fromexists ) { $success = bw_deletefile( $fromfile ); } else { $success = true; /* this is the situation we're hoping for */ } } else { if ( $fromexists ) { $success = bw_movefile( $fromfile, $tofile ); } else { bw_trace2( $from, "Source file does not exist for relocation" ); $success = false; } } bw_trace2( $success, "success" ); return( $success ); }View on GitHub View on Trac
Invoked by
Calls
1 to 3 of 3
