Meta Box - Version 5.6.2

Version Description

  • 2022-04-01 =
  • Fix map not showing in block preview
  • Fix deleting images in cloneable groups
  • Fix PHP notice for file_upload field
  • Expose the uploader for file_upload/image_upload so developers can work on that. For example: disable the submit button when uploading files.
Download this release

Release Info

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

Code changes from version 5.6.1 to 5.6.2

inc/fields/file-input.php CHANGED
@@ -35,7 +35,8 @@ class RWMB_File_Input_Field extends RWMB_Input_Field {
35
  */
36
  public static function html( $meta, $field ) {
37
  $attributes = self::get_attributes( $field, $meta );
38
- $file_ext = strtolower( end( explode( '.', $meta ) ) );
 
39
  $extensions = [ 'jpeg', 'jpg', 'png', 'gif' ];
40
  return sprintf(
41
  '<div class="rwmb-file-input-image %s">
35
  */
36
  public static function html( $meta, $field ) {
37
  $attributes = self::get_attributes( $field, $meta );
38
+ $meta_array = explode( '.', $meta );
39
+ $file_ext = strtolower( end( $meta_array ) );
40
  $extensions = [ 'jpeg', 'jpg', 'png', 'gif' ];
41
  return sprintf(
42
  '<div class="rwmb-file-input-image %s">
inc/fields/file.php CHANGED
@@ -62,10 +62,8 @@ class RWMB_File_Field extends RWMB_Field {
62
  $object_type = (string) $request->filter_post( 'object_type' );
63
  $field = rwmb_get_field_settings( $field_id, array( 'object_type' => $object_type ), $object_id );
64
  $field_value = self::raw_meta( $object_id, $field );
65
- $field_value = $field['clone'] ? call_user_func_array( 'array_merge', $field_value ) : $field_value;
66
 
67
- if ( ( 'child' !== $type && ! in_array( $attachment, $field_value ) ) ||
68
- ( 'child' === $type && ! in_array( $attachment, self::get_sub_values( $field_value, $request->filter_post( 'field_id' ) ) ) ) ) {
69
  wp_send_json_error( __( 'Error: Invalid file', 'meta-box' ) );
70
  }
71
  // Delete the file.
@@ -83,23 +81,14 @@ class RWMB_File_Field extends RWMB_Field {
83
  }
84
 
85
  /**
86
- * Recursively get values for sub-fields and sub-groups.
87
  *
88
- * @param array $field_value List of parent fields value.
89
- * @param int $key_search Nub field name.
90
- * @return array
91
  */
92
- protected static function get_sub_values( $field_value, $key_search ) {
93
- if ( array_key_exists( $key_search, $field_value ) ) {
94
- return $field_value[ $key_search ];
95
- }
96
-
97
- foreach ( $field_value as $key => $element ) {
98
- if( !is_array( $element ) ) {
99
- continue;
100
- }
101
- if ( self::get_sub_values( $element, $key_search ) ) {
102
- return $element[ $key_search ];
103
  }
104
  }
105
  return false;
62
  $object_type = (string) $request->filter_post( 'object_type' );
63
  $field = rwmb_get_field_settings( $field_id, array( 'object_type' => $object_type ), $object_id );
64
  $field_value = self::raw_meta( $object_id, $field );
 
65
 
66
+ if ( ! self::in_array_r( $attachment, $field_value ) ) {
 
67
  wp_send_json_error( __( 'Error: Invalid file', 'meta-box' ) );
68
  }
69
  // Delete the file.
81
  }
82
 
83
  /**
84
+ * Recursively search needle in haystack
85
  *
86
+ * @return boolean
 
 
87
  */
88
+ protected static function in_array_r( $needle, $haystack, $strict = false ) {
89
+ foreach ( $haystack as $item ) {
90
+ if ( ( $strict ? $item === $needle : $item == $needle ) || ( is_array( $item ) && self::in_array_r( $needle, $item, $strict ) ) ) {
91
+ return true;
 
 
 
 
 
 
 
92
  }
93
  }
94
  return false;
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', '5.6.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', '5.6.2' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
js/file-upload.js CHANGED
@@ -32,7 +32,7 @@
32
  },
33
 
34
  // Initializes plupload using code from wp.Uploader (wp-includes/js/plupload/wp-plupload.js)
35
- initUploader: function () {
36
  var self = this,
37
  extensions = this.getExtensions().join( ',' ),
38
  maxFileSize = this.controller.get( 'maxFileSize' ),
@@ -59,6 +59,7 @@
59
  filters.mime_types = [{title: i18nRwmbMedia.select, extensions: extensions}];
60
  }
61
  this.uploader.uploader.setOption( 'filters', filters );
 
62
  },
63
 
64
  getExtensions: function () {
@@ -81,14 +82,13 @@
81
  if ( view ) {
82
  return;
83
  }
84
-
85
  view = new FileUploadField( { input: this } );
86
 
87
  $this.siblings( '.rwmb-media-view' ).remove();
88
  $this.after( view.el );
89
 
90
  // Init uploader after view is inserted to make wp.Uploader works.
91
- view.addButton.initUploader();
92
 
93
  $this.data( 'view', view );
94
  }
32
  },
33
 
34
  // Initializes plupload using code from wp.Uploader (wp-includes/js/plupload/wp-plupload.js)
35
+ initUploader: function ( $this ) {
36
  var self = this,
37
  extensions = this.getExtensions().join( ',' ),
38
  maxFileSize = this.controller.get( 'maxFileSize' ),
59
  filters.mime_types = [{title: i18nRwmbMedia.select, extensions: extensions}];
60
  }
61
  this.uploader.uploader.setOption( 'filters', filters );
62
+ $this.data( 'uploader', this.uploader );
63
  },
64
 
65
  getExtensions: function () {
82
  if ( view ) {
83
  return;
84
  }
 
85
  view = new FileUploadField( { input: this } );
86
 
87
  $this.siblings( '.rwmb-media-view' ).remove();
88
  $this.after( view.el );
89
 
90
  // Init uploader after view is inserted to make wp.Uploader works.
91
+ view.addButton.initUploader( $this );
92
 
93
  $this.data( 'view', view );
94
  }
js/map-frontend.js CHANGED
@@ -1,8 +1,8 @@
1
  /* global google, jQuery */
2
 
3
- jQuery( function ( $ ) {
4
  'use strict';
5
-
6
  /**
7
  * Callback function for Google Maps Lazy Load library to display map
8
  *
@@ -78,4 +78,10 @@ jQuery( function ( $ ) {
78
 
79
  // Loop through all map instances and display them
80
  $( '.rwmb-map-canvas' ).each( displayMap );
81
- } );
 
 
 
 
 
 
1
  /* global google, jQuery */
2
 
3
+ ( function( $, document ) {
4
  'use strict';
5
+
6
  /**
7
  * Callback function for Google Maps Lazy Load library to display map
8
  *
78
 
79
  // Loop through all map instances and display them
80
  $( '.rwmb-map-canvas' ).each( displayMap );
81
+
82
+ $( document ).on( 'mb_blocks_preview', function( e ) {
83
+ $( e.target )
84
+ .find( ".rwmb-map-canvas" )
85
+ .each( displayMap );
86
+ } );
87
+ } )( jQuery, document );
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: 5.6.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: 5.6.2
7
  * Author: MetaBox.io
8
  * Author URI: https://metabox.io
9
  * License: GPL2+
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://metabox.io/pricing/
4
  Tags: meta box, custom fields, custom post types, custom taxonomies, cpt, meta boxes, custom field, post type, taxonomy, meta, admin, advanced, custom, edit, field, file, image, magic fields, post types, more fields, post, repeater, simple fields, text, textarea, type, cms, fields post
5
  Requires at least: 4.3
6
  Requires PHP: 5.6
7
- Tested up to: 5.9.1
8
- Stable tag: 5.6.1
9
  License: GPLv2 or later
10
 
11
  Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for your custom post types in WordPress.
@@ -168,6 +168,12 @@ To getting started with the plugin, please read the [Quick Start Guide](https://
168
 
169
  == Changelog ==
170
 
 
 
 
 
 
 
171
  = 5.6.1 - 2022-03-08 =
172
  - Fix compatibility for PHP < 7.3
173
 
4
  Tags: meta box, custom fields, custom post types, custom taxonomies, cpt, meta boxes, custom field, post type, taxonomy, meta, admin, advanced, custom, edit, field, file, image, magic fields, post types, more fields, post, repeater, simple fields, text, textarea, type, cms, fields post
5
  Requires at least: 4.3
6
  Requires PHP: 5.6
7
+ Tested up to: 5.9.2
8
+ Stable tag: 5.6.2
9
  License: GPLv2 or later
10
 
11
  Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for your custom post types in WordPress.
168
 
169
  == Changelog ==
170
 
171
+ = 5.6.2 - 2022-04-01 =
172
+ - Fix map not showing in block preview
173
+ - Fix deleting images in cloneable groups
174
+ - Fix PHP notice for file_upload field
175
+ - Expose the uploader for file_upload/image_upload so developers can work on that. For example: disable the submit button when uploading files.
176
+
177
  = 5.6.1 - 2022-03-08 =
178
  - Fix compatibility for PHP < 7.3
179