Created
November 3, 2012 20:58
-
-
Save jasontucker/4008744 to your computer and use it in GitHub Desktop.
Wordpress - Create new folder in /uploads directory on activation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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