Meta Box - Version 4.15.7

Version Description

Download this release

Release Info

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

Code changes from version 4.15.6 to 4.15.7

inc/fields/taxonomy-advanced.php CHANGED
@@ -9,28 +9,6 @@
9
  * The taxonomy advanced field class.
10
  */
11
  class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field {
12
- /**
13
- * Normalize the field parameters.
14
- *
15
- * @param array $field Field parameters.
16
- *
17
- * @return array
18
- */
19
- public static function normalize( $field ) {
20
- $field = wp_parse_args(
21
- $field,
22
- array(
23
- 'clone' => false,
24
- )
25
- );
26
-
27
- $clone = $field['clone'];
28
- $field = parent::normalize( $field );
29
- $field['clone'] = $clone;
30
-
31
- return $field;
32
- }
33
-
34
  /**
35
  * Get meta values to save.
36
  * Save terms in custom field in form of comma-separated IDs, no more by setting post terms.
@@ -60,10 +38,20 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field {
60
  }
61
  $storage = $field['storage'];
62
 
63
- if ( $new ) {
64
- $storage->update( $post_id, $field['id'], $new );
65
- } else {
66
  $storage->delete( $post_id, $field['id'] );
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
  }
69
 
@@ -83,7 +71,9 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field {
83
  if ( empty( $meta ) ) {
84
  return $field['multiple'] ? array() : '';
85
  }
 
86
  $meta = is_array( $meta ) ? array_map( 'wp_parse_id_list', $meta ) : wp_parse_id_list( $meta );
 
87
  $meta = array_filter( $meta );
88
 
89
  return $meta;
9
  * The taxonomy advanced field class.
10
  */
11
  class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * Get meta values to save.
14
  * Save terms in custom field in form of comma-separated IDs, no more by setting post terms.
38
  }
39
  $storage = $field['storage'];
40
 
41
+ if ( ! $new ) {
 
 
42
  $storage->delete( $post_id, $field['id'] );
43
+ return;
44
+ }
45
+
46
+ if ( ! $field['clone'] || ! $field['clone_as_multiple'] ) {
47
+ $storage->update( $post_id, $field['id'], $new );
48
+ return;
49
+ }
50
+
51
+ // clone and clone_as_multiple.
52
+ $storage->delete( $post_id, $field['id'] );
53
+ foreach ( $new as $value ) {
54
+ $storage->add( $post_id, $field['id'], $value );
55
  }
56
  }
57
 
71
  if ( empty( $meta ) ) {
72
  return $field['multiple'] ? array() : '';
73
  }
74
+
75
  $meta = is_array( $meta ) ? array_map( 'wp_parse_id_list', $meta ) : wp_parse_id_list( $meta );
76
+
77
  $meta = array_filter( $meta );
78
 
79
  return $meta;
inc/fields/taxonomy.php CHANGED
@@ -68,8 +68,10 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
68
  )
69
  );
70
 
71
- // Prevent cloning for taxonomy field.
72
- $field['clone'] = false;
 
 
73
 
74
  $field = parent::normalize( $field );
75
 
68
  )
69
  );
70
 
71
+ // Prevent cloning for taxonomy field, not for child fields (taxonomy_advanced).
72
+ if ( 'taxonomy' == $field['type'] ) {
73
+ $field['clone'] = false;
74
+ }
75
 
76
  $field = parent::normalize( $field );
77
 
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.15.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', '4.15.7' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
inc/meta-box.php CHANGED
@@ -413,18 +413,10 @@ class RW_Meta_Box {
413
  continue;
414
  }
415
 
416
- if ( method_exists( $field['storage'], 'exists' ) ) {
417
- if ( $field['storage']->exists( $this->object_id, $field['id'] ) ) {
418
- return true;
419
- }
420
- continue;
421
- }
422
-
423
  $value = RWMB_Field::call( $field, 'raw_meta', $this->object_id );
424
  if ( false === $value ) {
425
  continue;
426
  }
427
-
428
  if (
429
  ( ! $field['multiple'] && '' !== $value )
430
  || ( $field['multiple'] && is_array( $value ) && array() !== $value )
413
  continue;
414
  }
415
 
 
 
 
 
 
 
 
416
  $value = RWMB_Field::call( $field, 'raw_meta', $this->object_id );
417
  if ( false === $value ) {
418
  continue;
419
  }
 
420
  if (
421
  ( ! $field['multiple'] && '' !== $value )
422
  || ( $field['multiple'] && is_array( $value ) && array() !== $value )
inc/storages/base.php CHANGED
@@ -41,19 +41,6 @@ class RWMB_Base_Storage implements RWMB_Storage_Interface {
41
  return get_metadata( $this->object_type, $object_id, $meta_key, $single );
42
  }
43
 
44
- /**
45
- * Determine if a meta key is set for a given object
46
- *
47
- * @param int $object_id ID of the object metadata is for.
48
- * @param string $meta_key Metadata key.
49
- * @return bool True if exists.
50
- *
51
- * @see metadata_exists()
52
- */
53
- public function exists( $object_id, $meta_key ) {
54
- return metadata_exists( $this->object_type, $object_id, $meta_key );
55
- }
56
-
57
  /**
58
  * Add metadata
59
  *
41
  return get_metadata( $this->object_type, $object_id, $meta_key, $single );
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  /**
45
  * Add metadata
46
  *
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.15.6
7
  * Author: MetaBox.io
8
  * Author URI: https://metabox.io
9
  * License: GPL2+
@@ -15,6 +15,6 @@
15
 
16
  if ( defined( 'ABSPATH' ) && ! defined( 'RWMB_VER' ) ) {
17
  require_once dirname( __FILE__ ) . '/inc/loader.php';
18
- $loader = new RWMB_Loader();
19
- $loader->init();
20
  }
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.15.7
7
  * Author: MetaBox.io
8
  * Author URI: https://metabox.io
9
  * License: GPL2+
15
 
16
  if ( defined( 'ABSPATH' ) && ! defined( 'RWMB_VER' ) ) {
17
  require_once dirname( __FILE__ ) . '/inc/loader.php';
18
+ $rwmb_loader = new RWMB_Loader();
19
+ $rwmb_loader->init();
20
  }
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: 4.9.8
7
- Stable tag: 4.15.6
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: 4.9.8
7
+ Stable tag: 4.15.7
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.