Last active
August 13, 2018 14:19
-
-
Save kgoedecke/abe4ded0fcb31c5e13e02454f64b9514 to your computer and use it in GitHub Desktop.
Create subdirectory in WordPress uploads directory using plugin
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
<?php | |
class SomePlugin { | |
const CUSTOM_DIR = '/custom_dir'; | |
static function install() { | |
$uploads_dir = wp_upload_dir(); | |
$custom_uploads_dir = $uploads_dir['basedir'] . self::CUSTOM_DIR; | |
if( ! file_exists($custom_uploads_dir) ) { | |
wp_mkdir_p($custom_uploads_dir); | |
} | |
} | |
} | |
register_activation_hook( __FILE__, array( 'SomePlugin', 'install' ) ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment