Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Fusco <[email protected]>
  • Loading branch information
josephfusco committed Nov 17, 2023
1 parent 10c1415 commit 7352acc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plugins/faustwp/includes/blocks/functions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Block support functions for FaustWP.
* Functions related to block support.
*
* @package FaustWP
*/
Expand All @@ -9,10 +9,15 @@

use WP_Error;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

require_once ABSPATH . 'wp-admin/includes/file.php';

/**
* Handles the uploaded blockset file and unzips it.
* Handle the uploaded blockset file and unzips it.
* Returns true upon success.
*
* @param array $file The uploaded file details.
* @return WP_Error|bool
Expand Down Expand Up @@ -70,11 +75,11 @@ function process_and_replace_blocks( $wp_filesystem, $file, $dirs ) {
*/
function validate_uploaded_file( $wp_filesystem, $file ) {
if ( 'application/zip' !== $file['type'] ) {
return new WP_Error( 'wrong_type', esc_html__( 'Not a zip file', 'faustwp' ) );
return new WP_Error( 'wrong_type', __( 'Not a zip file', 'faustwp' ) );
}

if ( ! $wp_filesystem->is_readable( $file['tmp_name'] ) ) {
return new WP_Error( 'file_read_error', esc_html__( 'Uploaded file is not readable', 'faustwp' ) );
return new WP_Error( 'file_read_error', __( 'Uploaded file is not readable', 'faustwp' ) );
}

return true;
Expand Down Expand Up @@ -105,7 +110,7 @@ function ensure_directories_exist( $dirs ) {
foreach ( $dirs as $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 ) );
return new WP_Error( 'mkdir_error', sprintf( __( 'Could not create directory: %s', 'faustwp' ), $dir ) );
}
}

Expand All @@ -124,7 +129,7 @@ function ensure_directories_exist( $dirs ) {
*/
function move_uploaded_file( $wp_filesystem, $file, $target_file ) {
if ( ! $wp_filesystem->move( $file['tmp_name'], $target_file, true ) ) {
return new WP_Error( 'move_error', esc_html__( 'Could not move uploaded file', 'faustwp' ) );
return new WP_Error( 'move_error', __( 'Could not move uploaded file', 'faustwp' ) );
}
return true;
}
Expand Down

0 comments on commit 7352acc

Please sign in to comment.