Skip to content

Instantly share code, notes, and snippets.

@patrickposner
Created July 26, 2023 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickposner/7f24ccc244bb35ef31d2a81200026a06 to your computer and use it in GitHub Desktop.
Save patrickposner/7f24ccc244bb35ef31d2a81200026a06 to your computer and use it in GitHub Desktop.
InstaWP - Update temporary directory.
<?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