I am writing a plugin. I wrote this function to create a custom directory in the root.
function create_api_dir() {
$upload = wp_upload_dir();
//$upload_dir = $upload['basedir'];
$upload_dir = $_SERVER['DOCUMENT_ROOT'];
$upload_dir = $upload_dir . '/api';
if (! is_dir($upload_dir)) {
mkdir( $upload_dir, 0700 );
}
}
register_activation_hook( __FILE__, 'create_api_dir' );
This function is creating a folder named api
in the root server.
Now my plugin also consists of a folder with same name api with files inside this. I want to allow users to import the entire folder (unpacked) to that api
folder OR have them uploaded to the api folder on plugin activation.
How I can achieve this?
Thanks