Meta Box - Version 5.4.7

Version Description

  • 2021-09-16 =
  • Fix deleting files and images inside groups.
  • Fix maxlength and pattern not working if not set inside attributes
  • Fix not switching tabs for wysiwyg editors
  • Fix unit for checkbox width
  • Fix remove clone button on top of inputs
  • Fix style for checked checkboxes on desktops
  • Hide hidden field with custom class, not .hidden
Download this release

Release Info

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

Code changes from version 5.4.6 to 5.4.7

css/style.css CHANGED
@@ -35,7 +35,9 @@
35
  width: 100%;
36
  }
37
  .rwmb-input input[type="checkbox"],
38
- .rwmb-input input[type="radio"],
 
 
39
  .rwmb-input input[type="button"] {
40
  width: auto;
41
  }
@@ -47,6 +49,7 @@
47
  .rwmb-clone {
48
  min-height: 24px;
49
  margin-bottom: 12px;
 
50
  position: relative;
51
  clear: both;
52
  background: #fff;
@@ -118,7 +121,6 @@ select.rwmb-error {
118
 
119
  /* Styles for 'side' meta boxes
120
  -------------------------------------------------------------- */
121
-
122
  #side-sortables .rwmb-field {
123
  flex-direction: column;
124
  }
@@ -128,7 +130,7 @@ select.rwmb-error {
128
  }
129
 
130
  /* Mobile style */
131
- @media (max-width: 1023px) {
132
  .rwmb-field {
133
  flex-direction: column;
134
  }
@@ -136,11 +138,9 @@ select.rwmb-error {
136
  width: 100%;
137
  margin-bottom: 4px;
138
  }
139
- }
140
- @media (max-width: 782px) {
141
  .rwmb-input input[type="radio"],
142
  .rwmb-input input[type="checkbox"] {
143
- width: 1.5625em;
144
  }
145
  }
146
 
@@ -170,4 +170,7 @@ select.rwmb-error {
170
  .postarea {
171
  position: relative;
172
  z-index: 0;
 
 
 
173
  }
35
  width: 100%;
36
  }
37
  .rwmb-input input[type="checkbox"],
38
+ .rwmb-input input[type="radio"] {
39
+ width: 1em;
40
+ }
41
  .rwmb-input input[type="button"] {
42
  width: auto;
43
  }
49
  .rwmb-clone {
50
  min-height: 24px;
51
  margin-bottom: 12px;
52
+ padding-right: 24px;
53
  position: relative;
54
  clear: both;
55
  background: #fff;
121
 
122
  /* Styles for 'side' meta boxes
123
  -------------------------------------------------------------- */
 
124
  #side-sortables .rwmb-field {
125
  flex-direction: column;
126
  }
130
  }
131
 
132
  /* Mobile style */
133
+ @media (max-width: 782px) {
134
  .rwmb-field {
135
  flex-direction: column;
136
  }
138
  width: 100%;
139
  margin-bottom: 4px;
140
  }
 
 
141
  .rwmb-input input[type="radio"],
142
  .rwmb-input input[type="checkbox"] {
143
+ width: 1.5625rem;
144
  }
145
  }
146
 
170
  .postarea {
171
  position: relative;
172
  z-index: 0;
173
+ }
174
+ .rwmb-hidden-wrapper {
175
+ display: none;
176
  }
css/wysiwyg.css CHANGED
@@ -5,11 +5,6 @@
5
  padding-top: 20px;
6
  }
7
 
8
- /* Fix both tinymce & quick tags display together (somehow) */
9
- .html-active .mce-container {
10
- display: none;
11
- }
12
-
13
  /* Fix style for Gutenberg */
14
  .block-editor .wp-editor-wrap {
15
  box-sizing: content-box;
5
  padding-top: 20px;
6
  }
7
 
 
 
 
 
 
8
  /* Fix style for Gutenberg */
9
  .block-editor .wp-editor-wrap {
10
  box-sizing: content-box;
inc/field.php CHANGED
@@ -56,9 +56,6 @@ abstract class RWMB_Field {
56
 
57
  // Display label and input in DIV and allow user-defined classes to be appended.
58
  $classes = "rwmb-field rwmb-{$field['type']}-wrapper " . $field['class'];
59
- if ( 'hidden' === $field['type'] ) {
60
- $classes .= ' hidden';
61
- }
62
  if ( ! empty( $field['required'] ) ) {
63
  $classes .= ' required';
64
  }
56
 
57
  // Display label and input in DIV and allow user-defined classes to be appended.
58
  $classes = "rwmb-field rwmb-{$field['type']}-wrapper " . $field['class'];
 
 
 
59
  if ( ! empty( $field['required'] ) ) {
60
  $classes .= ' required';
61
  }
inc/fields/file.php CHANGED
@@ -48,21 +48,26 @@ class RWMB_File_Field extends RWMB_Field {
48
  */
49
  public static function ajax_delete_file() {
50
  $request = rwmb_request();
51
-
52
  $field_id = $request->filter_post( 'field_id', FILTER_SANITIZE_STRING );
 
53
  check_ajax_referer( "rwmb-delete-file_{$field_id}" );
54
 
 
 
 
 
55
  // Make sure the file to delete is in the custom field.
56
  $attachment = $request->post( 'attachment_id' );
57
  $object_id = $request->filter_post( 'object_id', FILTER_SANITIZE_STRING );
58
  $object_type = $request->filter_post( 'object_type', FILTER_SANITIZE_STRING );
59
- $field = rwmb_get_field_settings( $field_id, array( 'object_type' => $object_type ), $object_id );
60
  $field_value = self::raw_meta( $object_id, $field );
61
  $field_value = $field['clone'] ? call_user_func_array( 'array_merge', $field_value ) : $field_value;
62
- if ( ! in_array( $attachment, $field_value ) ) {
 
 
63
  wp_send_json_error( __( 'Error: Invalid file', 'meta-box' ) );
64
  }
65
-
66
  // Delete the file.
67
  if ( is_numeric( $attachment ) ) {
68
  $result = wp_delete_attachment( $attachment );
@@ -77,6 +82,29 @@ class RWMB_File_Field extends RWMB_Field {
77
  wp_send_json_error( __( 'Error: Cannot delete file', 'meta-box' ) );
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  /**
81
  * Get field HTML.
82
  *
@@ -147,8 +175,9 @@ class RWMB_File_Field extends RWMB_Field {
147
  }
148
 
149
  return sprintf(
150
- '<ul class="rwmb-files" data-field_id="%s" data-delete_nonce="%s" data-force_delete="%s" data-max_file_uploads="%s" data-mime_type="%s">%s</ul>',
151
  $field['id'],
 
152
  $delete_nonce,
153
  $field['force_delete'] ? 1 : 0,
154
  $field['max_file_uploads'],
48
  */
49
  public static function ajax_delete_file() {
50
  $request = rwmb_request();
 
51
  $field_id = $request->filter_post( 'field_id', FILTER_SANITIZE_STRING );
52
+ $type = false !== strpos( $request->filter_post( 'field_name', FILTER_SANITIZE_STRING ), '[' ) ? 'child' : 'top';
53
  check_ajax_referer( "rwmb-delete-file_{$field_id}" );
54
 
55
+ if ( 'child' === $type ) {
56
+ $field_group = explode( '[', $request->filter_post( 'field_name', FILTER_SANITIZE_STRING ) );
57
+ $field_id = $field_group[0]; //this is top parent field_id
58
+ }
59
  // Make sure the file to delete is in the custom field.
60
  $attachment = $request->post( 'attachment_id' );
61
  $object_id = $request->filter_post( 'object_id', FILTER_SANITIZE_STRING );
62
  $object_type = $request->filter_post( 'object_type', FILTER_SANITIZE_STRING );
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', FILTER_SANITIZE_STRING ) ) ) ) ) {
69
  wp_send_json_error( __( 'Error: Invalid file', 'meta-box' ) );
70
  }
 
71
  // Delete the file.
72
  if ( is_numeric( $attachment ) ) {
73
  $result = wp_delete_attachment( $attachment );
82
  wp_send_json_error( __( 'Error: Cannot delete file', 'meta-box' ) );
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;
106
+ }
107
+
108
  /**
109
  * Get field HTML.
110
  *
175
  }
176
 
177
  return sprintf(
178
+ '<ul class="rwmb-files" data-field_id="%s" data-field_name="%s" data-delete_nonce="%s" data-force_delete="%s" data-max_file_uploads="%s" data-mime_type="%s">%s</ul>',
179
  $field['id'],
180
+ $field['field_name'],
181
  $delete_nonce,
182
  $field['force_delete'] ? 1 : 0,
183
  $field['max_file_uploads'],
inc/fields/input.php CHANGED
@@ -95,6 +95,8 @@ abstract class RWMB_Input_Field extends RWMB_Field {
95
  'autocomplete' => $field['autocomplete'],
96
  'list' => $field['datalist'] ? $field['datalist']['id'] : false,
97
  'readonly' => $field['readonly'],
 
 
98
  'value' => $value,
99
  'placeholder' => $field['placeholder'],
100
  'type' => $field['type'],
95
  'autocomplete' => $field['autocomplete'],
96
  'list' => $field['datalist'] ? $field['datalist']['id'] : false,
97
  'readonly' => $field['readonly'],
98
+ 'maxlength' => $field['maxlength'],
99
+ 'pattern' => $field['pattern'],
100
  'value' => $value,
101
  'placeholder' => $field['placeholder'],
102
  'type' => $field['type'],
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.4.6' );
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.4.7' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
js/file.js CHANGED
@@ -49,6 +49,7 @@
49
  action: 'rwmb_delete_file',
50
  _ajax_nonce: $uploaded.data( 'delete_nonce' ),
51
  field_id: $uploaded.data( 'field_id' ),
 
52
  object_type: $metaBox.data( 'object-type' ),
53
  object_id: $metaBox.data( 'object-id' ),
54
  attachment_id: $this.data( 'attachment_id' )
49
  action: 'rwmb_delete_file',
50
  _ajax_nonce: $uploaded.data( 'delete_nonce' ),
51
  field_id: $uploaded.data( 'field_id' ),
52
+ field_name: $uploaded.data( 'field_name' ),
53
  object_type: $metaBox.data( 'object-type' ),
54
  object_id: $metaBox.data( 'object-id' ),
55
  attachment_id: $this.data( 'attachment_id' )
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.4.6
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.4.7
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.7.2
8
- Stable tag: 5.4.6
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,15 @@ To getting started with the plugin, please read the [Quick Start Guide](https://
168
 
169
  == Changelog ==
170
 
 
 
 
 
 
 
 
 
 
171
  = 5.4.6 - 2021-07-08 =
172
  - Remove debug code
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.8.1
8
+ Stable tag: 5.4.7
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.4.7 - 2021-09-16 =
172
+ - Fix deleting files and images inside groups.
173
+ - Fix maxlength and pattern not working if not set inside attributes
174
+ - Fix not switching tabs for wysiwyg editors
175
+ - Fix unit for checkbox width
176
+ - Fix remove clone button on top of inputs
177
+ - Fix style for checked checkboxes on desktops
178
+ - Hide hidden field with custom class, not .hidden
179
+
180
  = 5.4.6 - 2021-07-08 =
181
  - Remove debug code
182