I am trying to copy directory using WP_Filesystem API
with the method copy_dir()
on plugin activation, but it is give me the following error message:
Plugin could not be activated because it triggered a fatal error.
Fatal error: Call to undefined method WP_Filesystem_Direct::copy_dir()
in D:\xampp\htdocs\wordpress\wp-content\plugins\xxxxxxxx\xxxxxx.php on line 98
Here is my codes:
function sstssfb_activation_hook_vcheck() {
delete_option(esc_attr("sstssfb_stop_showingvchecknotice"));
/* INITIALIZE WPFilesytem */
$access_type = get_filesystem_method();
if($access_type === 'direct') {
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$creds = request_filesystem_credentials($url, '', false, false, array());
// initialize the API
if ( ! WP_Filesystem($creds) ) {
// any problems and we exit
return;
}
global $wp_filesystem;
/* CREATE SSTSSFB_ASSETS DIRECTORY */
if(!$wp_filesystem->is_dir(SSTSSFB_ASSET_DIR))
{
$wp_filesystem->mkdir(SSTSSFB_ASSET_DIR);
}
/* MOVE ADDITIONAL assets TO THAT (sstssfb_assets) DIRECTORY */
// addons
if(file_exists(SSTSSFBDIR_ADDONS_ORI))
$wp_filesystem->copy_dir(SSTSSFBDIR_ADDONS_ORI, SSTSSFB_ASSET_DIR, true);
$wp_filesystem->delete(SSTSSFBDIR_ADDONS_ORI);
// themes
if(file_exists(SSTSSFB_THEMEDIR_ORI))
$wp_filesystem->copy_dir(SSTSSFB_THEMEDIR_ORI, SSTSSFB_ASSET_DIR, true);
$wp_filesystem->delete(SSTSSFBDIR_ADDONS_ORI);
}
}
register_activation_hook(__FILE__, "sstssfb_activation_hook_vcheck");
What would be the problem here?