Meta Box - Version 4.16.2

Version Description

Download this release

Release Info

Developer rilwis
Plugin Icon 128x128 Meta Box
Version 4.16.2
Comparing to
See all releases

Code changes from version 4.16.1 to 4.16.2

inc/fields/file.php CHANGED
@@ -442,27 +442,28 @@ class RWMB_File_Field extends RWMB_Field {
442
  */
443
  public static function handle_upload_custom_dir( $file_id, $post_id, $field ) {
444
  // @codingStandardsIgnoreStart
445
- if ( ! isset( $_FILES[ $file_id ] ) ) {
446
  return;
447
  }
448
  $file = $_FILES[ $file_id ];
449
- if ( UPLOAD_ERR_OK !== $file['error'] || ! $file['tmp_name'] ) {
450
- return;
451
- }
452
  // @codingStandardsIgnoreEnd
453
 
454
- if ( ! file_exists( $field['upload_dir'] ) ) {
455
- wp_mkdir_p( $field['upload_dir'] );
456
- }
457
- if ( ! is_dir( $field['upload_dir'] ) || ! is_writable( $field['upload_dir'] ) ) {
458
- return;
459
- }
 
 
 
460
 
461
- $file_name = wp_unique_filename( $field['upload_dir'], basename( $file['name'] ) );
462
- $path = trailingslashit( $field['upload_dir'] ) . $file_name;
463
- move_uploaded_file( $file['tmp_name'], $path );
 
464
 
465
- return self::convert_path_to_url( $path );
466
  }
467
 
468
  /**
442
  */
443
  public static function handle_upload_custom_dir( $file_id, $post_id, $field ) {
444
  // @codingStandardsIgnoreStart
445
+ if ( empty( $_FILES[ $file_id ] ) ) {
446
  return;
447
  }
448
  $file = $_FILES[ $file_id ];
 
 
 
449
  // @codingStandardsIgnoreEnd
450
 
451
+ // Use a closure to filter upload directory. Requires PHP >= 5.3.0.
452
+ $filter_upload_dir = function( $uploads ) use ( $field ) {
453
+ $uploads['path'] = $field['upload_dir'];
454
+ $uploads['url'] = self::convert_path_to_url( $field['upload_dir'] );
455
+ $uploads['subdir'] = '';
456
+ $uploads['basedir'] = $field['upload_dir'];
457
+
458
+ return $uploads;
459
+ };
460
 
461
+ // Let WordPress handle upload to the custom directory.
462
+ add_filter( 'upload_dir', $filter_upload_dir );
463
+ $file_info = wp_handle_upload( $file, array( 'test_form' => false ) );
464
+ remove_filter( 'upload_dir', $filter_upload_dir );
465
 
466
+ return empty( $file_info['url'] ) ? null : $file_info['url'];
467
  }
468
 
469
  /**
inc/fields/taxonomy-advanced.php CHANGED
@@ -21,7 +21,7 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field {
21
  * @return string
22
  */
23
  public static function value( $new, $old, $post_id, $field ) {
24
- return implode( ',', array_unique( (array) $new ) );
25
  }
26
 
27
  /**
21
  * @return string
22
  */
23
  public static function value( $new, $old, $post_id, $field ) {
24
+ return implode( ',', array_filter( array_unique( (array) $new ) ) );
25
  }
26
 
27
  /**
inc/loader.php CHANGED
@@ -18,7 +18,7 @@ class RWMB_Loader {
18
  */
19
  protected function constants() {
20
  // Script version, used to add version for scripts and styles.
21
- define( 'RWMB_VER', '4.16.1' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
18
  */
19
  protected function constants() {
20
  // Script version, used to add version for scripts and styles.
21
+ define( 'RWMB_VER', '4.16.2' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
meta-box.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Meta Box
4
  * Plugin URI: https://metabox.io
5
  * Description: Create custom meta boxes and custom fields in WordPress.
6
- * Version: 4.16.1
7
  * Author: MetaBox.io
8
  * Author URI: https://metabox.io
9
  * License: GPL2+
3
  * Plugin Name: Meta Box
4
  * Plugin URI: https://metabox.io
5
  * Description: Create custom meta boxes and custom fields in WordPress.
6
+ * Version: 4.16.2
7
  * Author: MetaBox.io
8
  * Author URI: https://metabox.io
9
  * License: GPL2+
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://metabox.io/pricing/
4
  Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced, custom, edit, field, file, image, magic fields, matrix, more fields, Post, repeater, simple fields, text, textarea, type, cms, fields post
5
  Requires at least: 4.3
6
  Tested up to: 5.0.3
7
- Stable tag: 4.16.1
8
  License: GPLv2 or later
9
 
10
  Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for WordPress.
4
  Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced, custom, edit, field, file, image, magic fields, matrix, more fields, Post, repeater, simple fields, text, textarea, type, cms, fields post
5
  Requires at least: 4.3
6
  Tested up to: 5.0.3
7
+ Stable tag: 4.16.2
8
  License: GPLv2 or later
9
 
10
  Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for WordPress.