Version Description
Download this release
Release Info
Developer | rilwis |
Plugin | 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 +27 -18
- inc/fields/taxonomy.php +10 -9
- inc/fields/text-list.php +12 -10
- inc/loader.php +1 -1
- inc/meta-box.php +2 -0
- meta-box.php +1 -1
- readme.txt +1 -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 $
|
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 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
}
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
if ( empty( $value ) ) {
|
104 |
-
return null;
|
105 |
-
}
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
'hide_empty' => false,
|
111 |
), $args );
|
112 |
-
$value = get_terms( $field['taxonomy'], $args );
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
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'
|
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 |
-
|
|
|
|
|
|
|
99 |
}
|
100 |
|
101 |
/**
|
@@ -112,12 +118,7 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
112 |
return '';
|
113 |
}
|
114 |
|
115 |
-
$meta =
|
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 =
|
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 |
-
|
26 |
-
$
|
27 |
-
$
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
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.
|
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.
|
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.
|
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.
|