Meta Box - Version 5.1.1

Version Description

  • 2019-08-23 =

Fixed

  • Fix sanitizing number always return 0 if it's blank
  • Fix sanitizing URL

Changed

  • Set default field 'type' to 'text', make it optional and help you write less code
  • File/image fields: do not show add new file link if max_file_uploads
Download this release

Release Info

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

Code changes from version 5.1.0 to 5.1.1

inc/field.php CHANGED
@@ -336,6 +336,7 @@ abstract class RWMB_Field {
336
  array(
337
  'id' => '',
338
  'name' => '',
 
339
  'label_description' => '',
340
  'multiple' => false,
341
  'std' => '',
336
  array(
337
  'id' => '',
338
  'name' => '',
339
+ 'type' => 'text',
340
  'label_description' => '',
341
  'multiple' => false,
342
  'std' => '',
inc/fields/file.php CHANGED
@@ -104,14 +104,18 @@ class RWMB_File_Field extends RWMB_Field {
104
  $attributes['required'] = false;
105
  }
106
 
 
107
  $html .= sprintf(
108
- '<div class="rwmb-file-new">
109
- <input %s>
110
- <a class="rwmb-file-add" href="#"><strong>%s</strong></a>
111
- </div>',
112
- self::render_attributes( $attributes ),
113
- $i18n_more
114
  );
 
 
 
 
 
 
 
115
 
116
  return $html;
117
  }
104
  $attributes['required'] = false;
105
  }
106
 
107
+ // Upload new files.
108
  $html .= sprintf(
109
+ '<div class="rwmb-file-new"><input %s>',
110
+ self::render_attributes( $attributes )
 
 
 
 
111
  );
112
+ if ( 1 !== $field['max_file_uploads'] ) {
113
+ $html .= sprintf(
114
+ '<a class="rwmb-file-add" href="#"><strong>%s</strong></a>',
115
+ $i18n_more
116
+ );
117
+ }
118
+ $html .= '</div>';
119
 
120
  return $html;
121
  }
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.1.0' );
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.1.1' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
inc/sanitizer.php CHANGED
@@ -24,7 +24,7 @@ class RWMB_Sanitizer {
24
  * @param mixed $old_value The old field value in the database.
25
  * @param int $object_id The object ID.
26
  */
27
- public function sanitize( $value, $field, $old_value, $object_id ) {
28
  // Allow developers to bypass the sanitization.
29
  if ( 'none' === $field['sanitize_callback'] ) {
30
  return $value;
@@ -60,7 +60,7 @@ class RWMB_Sanitizer {
60
  'fieldset_text' => array( $this, 'sanitize_text' ),
61
  'file' => array( $this, 'sanitize_file' ),
62
  'file_advanced' => array( $this, 'sanitize_object' ),
63
- 'file_input' => 'esc_url_raw',
64
  'file_upload' => array( $this, 'sanitize_object' ),
65
  'hidden' => 'sanitize_text_field',
66
  'image' => array( $this, 'sanitize_file' ),
@@ -70,7 +70,7 @@ class RWMB_Sanitizer {
70
  'key_value' => array( $this, 'sanitize_text' ),
71
  'map' => array( $this, 'sanitize_map' ),
72
  'number' => array( $this, 'sanitize_number' ),
73
- 'oembed' => 'esc_url_raw',
74
  'osm' => array( $this, 'sanitize_map' ),
75
  'password' => 'sanitize_text_field',
76
  'post' => array( $this, 'sanitize_object' ),
@@ -88,7 +88,7 @@ class RWMB_Sanitizer {
88
  'text_list' => array( $this, 'sanitize_text' ),
89
  'textarea' => 'wp_kses_post',
90
  'time' => 'sanitize_text_field',
91
- 'url' => 'esc_url_raw',
92
  'user' => array( $this, 'sanitize_object' ),
93
  'video' => array( $this, 'sanitize_object' ),
94
  'wysiwyg' => 'wp_kses_post',
@@ -114,11 +114,11 @@ class RWMB_Sanitizer {
114
  /**
115
  * Sanitize numeric value.
116
  *
117
- * @param int|float $value The number value.
118
- * @return int|float
119
  */
120
  private function sanitize_number( $value ) {
121
- return is_numeric( $value ) ? $value : 0;
122
  }
123
 
124
  /**
@@ -265,4 +265,14 @@ class RWMB_Sanitizer {
265
 
266
  return implode( ',', $value );
267
  }
 
 
 
 
 
 
 
 
 
 
268
  }
24
  * @param mixed $old_value The old field value in the database.
25
  * @param int $object_id The object ID.
26
  */
27
+ public function sanitize( $value, $field, $old_value = null, $object_id = null ) {
28
  // Allow developers to bypass the sanitization.
29
  if ( 'none' === $field['sanitize_callback'] ) {
30
  return $value;
60
  'fieldset_text' => array( $this, 'sanitize_text' ),
61
  'file' => array( $this, 'sanitize_file' ),
62
  'file_advanced' => array( $this, 'sanitize_object' ),
63
+ 'file_input' => array( $this, 'sanitize_url' ),
64
  'file_upload' => array( $this, 'sanitize_object' ),
65
  'hidden' => 'sanitize_text_field',
66
  'image' => array( $this, 'sanitize_file' ),
70
  'key_value' => array( $this, 'sanitize_text' ),
71
  'map' => array( $this, 'sanitize_map' ),
72
  'number' => array( $this, 'sanitize_number' ),
73
+ 'oembed' => array( $this, 'sanitize_url' ),
74
  'osm' => array( $this, 'sanitize_map' ),
75
  'password' => 'sanitize_text_field',
76
  'post' => array( $this, 'sanitize_object' ),
88
  'text_list' => array( $this, 'sanitize_text' ),
89
  'textarea' => 'wp_kses_post',
90
  'time' => 'sanitize_text_field',
91
+ 'url' => array( $this, 'sanitize_url' ),
92
  'user' => array( $this, 'sanitize_object' ),
93
  'video' => array( $this, 'sanitize_object' ),
94
  'wysiwyg' => 'wp_kses_post',
114
  /**
115
  * Sanitize numeric value.
116
  *
117
+ * @param string $value The number value.
118
+ * @return string
119
  */
120
  private function sanitize_number( $value ) {
121
+ return is_numeric( $value ) ? $value : '';
122
  }
123
 
124
  /**
265
 
266
  return implode( ',', $value );
267
  }
268
+
269
+ /**
270
+ * Sanitize URL field.
271
+ *
272
+ * @param string $value The submitted value.
273
+ * @return string
274
+ */
275
+ private function sanitize_url( $value ) {
276
+ return esc_url_raw( $value );
277
+ }
278
  }
inc/update/settings.php CHANGED
@@ -113,6 +113,7 @@ class RWMB_Update_Settings {
113
  'error' => __( 'Your license key is <b>invalid</b>. Please update your license key or <a href="%1$s" target="_blank">get a new one here</a>.', 'meta-box' ),
114
  // Translators: %2$s - URL to the My Account page.
115
  'expired' => __( 'Your license key is <b>expired</b>. Please <a href="%2$s" target="_blank">renew your license</a>.', 'meta-box' ),
 
116
  );
117
  $status = $this->checker->get_api_key() ? $this->option->get( 'status', 'active' ) : 'no_key';
118
  if ( isset( $messages[ $status ] ) ) {
113
  'error' => __( 'Your license key is <b>invalid</b>. Please update your license key or <a href="%1$s" target="_blank">get a new one here</a>.', 'meta-box' ),
114
  // Translators: %2$s - URL to the My Account page.
115
  'expired' => __( 'Your license key is <b>expired</b>. Please <a href="%2$s" target="_blank">renew your license</a>.', 'meta-box' ),
116
+ 'active' => __( 'Your license key is <b>active</b>.', 'meta-box' ),
117
  );
118
  $status = $this->checker->get_api_key() ? $this->option->get( 'status', 'active' ) : 'no_key';
119
  if ( isset( $messages[ $status ] ) ) {
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.1.0
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.1.1
7
  * Author: MetaBox.io
8
  * Author URI: https://metabox.io
9
  * License: GPL2+
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced,
5
  Requires at least: 4.3
6
  Requires PHP: 5.3
7
  Tested up to: 5.2.2
8
- Stable tag: 5.1.0
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 WordPress.
@@ -167,7 +167,19 @@ To getting started with the plugin, please read the [Quick Start Guide](https://
167
 
168
  == Changelog ==
169
 
170
- = 5.1.0 - 2019-08-19 =
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  **Fixed**
173
 
@@ -189,7 +201,7 @@ To getting started with the plugin, please read the [Quick Start Guide](https://
189
 
190
  - Fix license notification always show
191
 
192
- = 5.0.0 - 2019-07-24 =
193
 
194
  **IMPORTANT:** Since version 5.0.0, the plugin requires PHP >= 5.3. If you use an older PHP version, please ask your host to upgrade or use an older version of Meta Box.
195
 
5
  Requires at least: 4.3
6
  Requires PHP: 5.3
7
  Tested up to: 5.2.2
8
+ Stable tag: 5.1.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 WordPress.
167
 
168
  == Changelog ==
169
 
170
+ = 5.1.1 - 2019-08-23 =
171
+
172
+ **Fixed**
173
+
174
+ - Fix sanitizing number always return 0 if it's blank
175
+ - Fix sanitizing URL
176
+
177
+ **Changed**
178
+
179
+ - Set default field 'type' to 'text', make it optional and help you write less code
180
+ - File/image fields: do not show add new file link if max_file_uploads = 1
181
+
182
+ = [5.1.0 - 2019-08-19](https://metabox.io/meta-box-510/) =
183
 
184
  **Fixed**
185
 
201
 
202
  - Fix license notification always show
203
 
204
+ = [5.0.0 - 2019-07-24](https://metabox.io/meta-box-5-released/) =
205
 
206
  **IMPORTANT:** Since version 5.0.0, the plugin requires PHP >= 5.3. If you use an older PHP version, please ask your host to upgrade or use an older version of Meta Box.
207