Skip to content

Instantly share code, notes, and snippets.

@jasontucker
Created November 3, 2012 20:58
Show Gist options
  • Select an option

  • Save jasontucker/4008744 to your computer and use it in GitHub Desktop.

Select an option

Save jasontucker/4008744 to your computer and use it in GitHub Desktop.
Wordpress - Create new folder in /uploads directory on activation.
//Here’s a code snippet that allows your plugin to create a new folder in the /uploads directory on activation. Could be useful if your plugin needs to allow imports or uploads and you want them stored in a separate directory.
function myplugin_activate() {
$upload = wp_upload_dir();
$upload_dir = $upload['basedir'];
$upload_dir = $upload_dir . '/mypluginfiles';
if (! is_dir($upload_dir)) {
mkdir( $upload_dir, 0700 );
}
}
register_activation_hook( __FILE__, 'myplugin_activate' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment