Created
July 26, 2023 17:33
-
-
Save patrickposner/7f24ccc244bb35ef31d2a81200026a06 to your computer and use it in GitHub Desktop.
InstaWP - Update temporary directory.
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 | |
add_action( 'admin_init', function() { | |
// Get Simply Static options. | |
$options = get_option('simply-static'); | |
// Check if directory exists, if not, create it. | |
$upload_dir = wp_upload_dir(); | |
$temp_dir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'simply-static' . DIRECTORY_SEPARATOR . 'temp-files'; | |
// Path correct, exit. | |
if( $options['temp_files_dir'] == $temp_dir ) { | |
return; | |
} | |
// Check if directory exists. | |
if ( ! is_dir( $temp_dir ) ) { | |
wp_mkdir_p( $temp_dir ); | |
} | |
// Update the path. | |
$options['temp_files_dir'] = $temp_dir; | |
update_option('simply-static', $options ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment