Meta Box - Version 4.14.1

Version Description

Download this release

Release Info

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

Code changes from version 4.14.0 to 4.14.1

inc/fields/taxonomy-advanced.php CHANGED
@@ -80,7 +80,7 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field {
80
  $meta = is_array( $meta ) ? array_map( 'wp_parse_id_list', $meta ) : wp_parse_id_list( $meta );
81
  $meta = array_filter( $meta );
82
 
83
- return $field['multiple'] ? $meta : reset( $meta );
84
  }
85
 
86
  /**
@@ -94,28 +94,37 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field {
94
  * @return array List of post term objects.
95
  */
96
  public static function get_value( $field, $args = array(), $post_id = null ) {
97
- if ( ! $post_id ) {
98
- $post_id = get_the_ID();
 
 
 
 
 
 
 
99
  }
100
 
101
- // Get raw meta value in the database, no escape.
102
- $value = self::call( $field, 'raw_meta', $post_id, $args );
103
- if ( empty( $value ) ) {
104
- return null;
105
- }
106
 
107
- // Allow to pass more arguments to "get_terms".
108
- $args = wp_parse_args( array(
109
- 'include' => $value,
 
 
 
 
 
 
 
 
 
110
  'hide_empty' => false,
111
  ), $args );
112
- $value = get_terms( $field['taxonomy'], $args );
113
 
114
- // Get single value if necessary.
115
- if ( ! $field['clone'] && ! $field['multiple'] ) {
116
- $value = reset( $value );
117
- }
118
-
119
- return $value;
120
  }
121
  }
80
  $meta = is_array( $meta ) ? array_map( 'wp_parse_id_list', $meta ) : wp_parse_id_list( $meta );
81
  $meta = array_filter( $meta );
82
 
83
+ return $meta;
84
  }
85
 
86
  /**
94
  * @return array List of post term objects.
95
  */
96
  public static function get_value( $field, $args = array(), $post_id = null ) {
97
+ $value = RWMB_Field::get_value( $field, $args, $post_id );
98
+ if ( ! $field['clone'] ) {
99
+ $value = self::call( 'terms_info', $field, $value, $args );
100
+ } else {
101
+ $return = array();
102
+ foreach ( $value as $subvalue ) {
103
+ $return[] = self::call( 'terms_info', $field, $subvalue, $args );
104
+ }
105
+ $value = $return;
106
  }
107
 
108
+ return $value;
109
+ }
 
 
 
110
 
111
+ /**
112
+ * Get terms information.
113
+ *
114
+ * @param array $field Field parameters.
115
+ * @param string $term_ids Term IDs, in CSV format.
116
+ * @param array $args Additional arguments (for image size).
117
+ *
118
+ * @return array
119
+ */
120
+ public static function terms_info( $field, $term_ids, $args ) {
121
+ $args = wp_parse_args( array(
122
+ 'include' => $term_ids,
123
  'hide_empty' => false,
124
  ), $args );
 
125
 
126
+ $info = get_terms( $field['taxonomy'], $args );
127
+ $info = is_array( $info ) ? $info : array();
128
+ return $field['multiple'] ? $info : reset( $info );
 
 
 
129
  }
130
  }
inc/fields/taxonomy.php CHANGED
@@ -30,9 +30,12 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
30
  // Set default field args.
31
  $field = parent::normalize( $field );
32
  $field = wp_parse_args( $field, array(
33
- 'taxonomy' => 'category',
34
  ) );
35
 
 
 
 
36
  // Set default query args.
37
  $field['query_args'] = wp_parse_args( $field['query_args'], array(
38
  'hide_empty' => false,
@@ -95,7 +98,10 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
95
  public static function save( $new, $old, $post_id, $field ) {
96
  $new = array_unique( array_map( 'intval', (array) $new ) );
97
  $new = empty( $new ) ? null : $new;
98
- wp_set_object_terms( $post_id, $new, $field['taxonomy'] );
 
 
 
99
  }
100
 
101
  /**
@@ -112,12 +118,7 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
112
  return '';
113
  }
114
 
115
- $meta = get_the_terms( $object_id, $field['taxonomy'] );
116
-
117
- if ( ! is_array( $meta ) || empty( $meta ) ) {
118
- return $field['multiple'] ? array() : '';
119
- }
120
-
121
  $meta = wp_list_pluck( $meta, 'term_id' );
122
 
123
  return $field['multiple'] ? $meta : reset( $meta );
@@ -134,7 +135,7 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
134
  * @return array List of post term objects.
135
  */
136
  public static function get_value( $field, $args = array(), $post_id = null ) {
137
- $value = get_the_terms( $post_id, $field['taxonomy'] );
138
 
139
  // Get single value if necessary.
140
  if ( ! $field['clone'] && ! $field['multiple'] && is_array( $value ) ) {
30
  // Set default field args.
31
  $field = parent::normalize( $field );
32
  $field = wp_parse_args( $field, array(
33
+ 'taxonomy' => 'category',
34
  ) );
35
 
36
+ // Force taxonomy to be an array.
37
+ $field['taxonomy'] = (array) $field['taxonomy'];
38
+
39
  // Set default query args.
40
  $field['query_args'] = wp_parse_args( $field['query_args'], array(
41
  'hide_empty' => false,
98
  public static function save( $new, $old, $post_id, $field ) {
99
  $new = array_unique( array_map( 'intval', (array) $new ) );
100
  $new = empty( $new ) ? null : $new;
101
+
102
+ foreach ( $field['taxonomy'] as $taxonomy ) {
103
+ wp_set_object_terms( $post_id, $new, $taxonomy );
104
+ }
105
  }
106
 
107
  /**
118
  return '';
119
  }
120
 
121
+ $meta = wp_get_object_terms( $object_id, $field['taxonomy'] );
 
 
 
 
 
122
  $meta = wp_list_pluck( $meta, 'term_id' );
123
 
124
  return $field['multiple'] ? $meta : reset( $meta );
135
  * @return array List of post term objects.
136
  */
137
  public static function get_value( $field, $args = array(), $post_id = null ) {
138
+ $value = wp_get_object_terms( $post_id, $field['taxonomy'] );
139
 
140
  // Get single value if necessary.
141
  if ( ! $field['clone'] && ! $field['multiple'] && is_array( $value ) ) {
inc/fields/text-list.php CHANGED
@@ -22,16 +22,18 @@ class RWMB_Text_List_Field extends RWMB_Multiple_Values_Field {
22
  $input = '<label><input type="text" class="rwmb-text-list" name="%s" value="%s" placeholder="%s"> %s</label>';
23
 
24
  $count = 0;
25
- foreach ( $field['options'] as $placeholder => $label ) {
26
- $html[] = sprintf(
27
- $input,
28
- $field['field_name'],
29
- isset( $meta[ $count ] ) ? esc_attr( $meta[ $count ] ) : '',
30
- $placeholder,
31
- $label
32
- );
33
- $count ++;
34
- }
 
 
35
 
36
  return implode( ' ', $html );
37
  }
22
  $input = '<label><input type="text" class="rwmb-text-list" name="%s" value="%s" placeholder="%s"> %s</label>';
23
 
24
  $count = 0;
25
+ if ( ! empty( $field['options'] ) ) :
26
+ foreach ( $field['options'] as $placeholder => $label ) {
27
+ $html[] = sprintf(
28
+ $input,
29
+ $field['field_name'],
30
+ isset( $meta[ $count ] ) ? esc_attr( $meta[ $count ] ) : '',
31
+ $placeholder,
32
+ $label
33
+ );
34
+ $count ++;
35
+ }
36
+ endif;
37
 
38
  return implode( ' ', $html );
39
  }
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.14.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', '4.14.1' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
inc/meta-box.php CHANGED
@@ -297,6 +297,8 @@ class RW_Meta_Box {
297
 
298
  // Call defined method to save meta value, if there's no methods, call common one.
299
  RWMB_Field::call( $field, 'save', $new, $old, $post_id );
 
 
300
  }
301
  }
302
 
297
 
298
  // Call defined method to save meta value, if there's no methods, call common one.
299
  RWMB_Field::call( $field, 'save', $new, $old, $post_id );
300
+
301
+ RWMB_Field::filter( 'after_save_field', null, $field, $new, $old, $post_id, $field );
302
  }
303
  }
304
 
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.14.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: 4.14.1
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: 4.9.4
7
- Stable tag: 4.14.0
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.4
7
+ Stable tag: 4.14.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.