Skip to content

Commit

Permalink
Clean up refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Fusco <[email protected]>
  • Loading branch information
josephfusco committed Nov 16, 2023
1 parent fba8da2 commit de8b873
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plugins/faustwp/includes/blocks/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function handle_uploaded_blockset( $file ) {
}

$dirs = define_directories();
$error = ensure_directories_exist( $wp_filesystem, $dirs );
$error = ensure_directories_exist( $dirs );
if ( is_wp_error( $error ) ) {
return $error;
}
Expand Down Expand Up @@ -98,13 +98,12 @@ function define_directories() {
/**
* Ensures that the necessary directories exist.
*
* @param WP_Filesystem_Base $wp_filesystem Filesystem object.
* @param array $dirs Directories array.
* @param array $dirs Directories array.
* @return WP_Error|true
*/
function ensure_directories_exist( $wp_filesystem, $dirs ) {
function ensure_directories_exist( $dirs ) {
foreach ( $dirs as $dir ) {
if ( ! $wp_filesystem->is_dir( $dir ) && ! $wp_filesystem->mkdir( $dir, FS_CHMOD_DIR ) ) {
if ( ! wp_mkdir_p( $dir ) ) {
/* translators: %s: directory path */
return new WP_Error( 'mkdir_error', sprintf( esc_html__( 'Could not create directory: %s', 'faustwp' ), $dir ) );
}
Expand All @@ -113,6 +112,8 @@ function ensure_directories_exist( $wp_filesystem, $dirs ) {
return true;
}



/**
* Moves the uploaded file to the target directory.
*
Expand Down

0 comments on commit de8b873

Please sign in to comment.