diff --git a/includes/core/class-files.php b/includes/core/class-files.php index c8e6a1af..ef95ee4b 100644 --- a/includes/core/class-files.php +++ b/includes/core/class-files.php @@ -773,129 +773,6 @@ if ( ! class_exists( 'um\core\Files' ) ) { return $array; - - - } - - - /** - * Check image upload and handle errors - * - * @param $file - * @param $field - * - * @return null|string|void - */ - function check_image_upload( $file, $field, $stream_photo = false ) { - $error = null; - - $fileinfo = $this->get_image_data( $file ); - $data = UM()->fields()->get_field( $field ); - - if ( $data == null ) { - /** - * UM hook - * - * @type filter - * @title um_custom_image_handle_{$field} - * @description Custom image handle - * @input_vars - * [{"var":"$data","type":"array","desc":"Image Data"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_custom_image_handle_{$field}', 'function_name', 10, 1 ); - * @example - * - */ - $data = apply_filters( "um_custom_image_handle_{$field}", array() ); - if ( ! $data ) { - $error = __( 'This media type is not recognized.', 'ultimate-member' ); - } - } - - /** - * UM hook - * - * @type filter - * @title um_image_handle_global__option - * @description Custom image global handle - * @input_vars - * [{"var":"$data","type":"array","desc":"Image Data"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_image_handle_global__option', 'function_name', 10, 1 ); - * @example - * - */ - $data = apply_filters("um_image_handle_global__option", $data ); - /** - * UM hook - * - * @type filter - * @title um_image_handle_{$field}__option - * @description Custom image handle for each $field - * @input_vars - * [{"var":"$data","type":"array","desc":"Image Data"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_image_handle_{$field}__option', 'function_name', 10, 1 ); - * @example - * - */ - $data = apply_filters( "um_image_handle_{$field}__option", $data ); - - if ( $fileinfo['invalid_image'] == true ) { - $error = sprintf(__('Your image is invalid or too large!','ultimate-member') ); - } elseif ( isset($data['min_size']) && ( $fileinfo['size'] < $data['min_size'] ) ) { - $error = $data['min_size_error']; - } elseif ( isset($data['min_width']) && ( $fileinfo['width'] < $data['min_width'] ) ) { - $error = sprintf(__('Your photo is too small. It must be at least %spx wide.','ultimate-member'), $data['min_width']); - } elseif ( isset($data['min_height']) && ( $fileinfo['height'] < $data['min_height'] ) ) { - $error = sprintf(__('Your photo is too small. It must be at least %spx wide.','ultimate-member'), $data['min_height']); - } - - return $error; - } - - - /** - * Check file upload and handle errors - * - * @param $file - * @param $extension - * @param $field - * - * @return null|string - */ - function check_file_upload( $file, $extension, $field ) { - $error = null; - - $fileinfo = $this->get_file_data( $file ); - $data = UM()->fields()->get_field( $field ); - - if ( isset($data['min_size']) && ( $fileinfo['size'] < $data['min_size'] ) ) { - $error = $data['min_size_error']; - } - - return $error; } @@ -907,7 +784,7 @@ if ( ! class_exists( 'um\core\Files' ) ) { * * @return bool */ - function in_array( $value, $array ){ + function in_array( $value, $array ) { if ( in_array( $value, explode(',', $array ) ) ){ return true; diff --git a/includes/core/class-members.php b/includes/core/class-members.php index 3c3e0f7a..3fd7a55b 100644 --- a/includes/core/class-members.php +++ b/includes/core/class-members.php @@ -262,7 +262,7 @@ if ( ! class_exists( 'um\core\Members' ) ) { ?> - + diff --git a/includes/core/class-uploader.php b/includes/core/class-uploader.php index 7ad0ea96..9f794c4f 100644 --- a/includes/core/class-uploader.php +++ b/includes/core/class-uploader.php @@ -213,17 +213,17 @@ if ( ! class_exists( 'um\core\Uploader' ) ) { public function validate_upload( $file ){ - if( 'image' == $this->upload_type ){ + if ( 'image' == $this->upload_type ) { $error = $this->validate_image_data( $file['tmp_name'], $this->field_key ); - }else if( 'file' == $this->upload_type ){ + } elseif( 'file' == $this->upload_type ) { $error = $this->validate_file_data( $file['tmp_name'], $this->field_key ); } - if( $error ){ + if ( $error ) { $file['error'] = $error; } @@ -610,18 +610,18 @@ if ( ! class_exists( 'um\core\Uploader' ) ) { $response['handle_upload'] = $movefile; return $response; - } + /** * Check image upload and handle errors * * @param $file * @param $field * - * @return null|string|void + * @return null|string */ - public function validate_image_data( $file, $field_key ){ + public function validate_image_data( $file, $field_key ) { $error = null; if ( ! function_exists( 'wp_get_image_editor' ) ) { @@ -729,9 +729,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) { return $error; - } + /** * Check file upload and handle errors * @@ -740,7 +740,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) { * * @return null|string */ - public function validate_file_data( $file, $field_key ){ + public function validate_file_data( $file, $field_key ) { $error = null; if ( ! function_exists( 'wp_get_image_editor' ) ) {