Version Description
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 4.14.4 |
Comparing to | |
See all releases |
Code changes from version 4.14.2 to 4.14.4
- inc/fields/post.php +18 -13
- inc/fields/taxonomy.php +18 -12
- inc/fields/user.php +3 -3
- inc/loader.php +1 -1
- inc/meta-box.php +5 -1
- meta-box.php +1 -1
- readme.txt +2 -2
inc/fields/post.php
CHANGED
@@ -17,30 +17,35 @@ class RWMB_Post_Field extends RWMB_Object_Choice_Field {
|
|
17 |
*/
|
18 |
public static function normalize( $field ) {
|
19 |
// Set default field args.
|
20 |
-
$field = parent::normalize( $field );
|
21 |
$field = wp_parse_args( $field, array(
|
22 |
'post_type' => 'post',
|
23 |
'parent' => false,
|
24 |
) );
|
25 |
|
26 |
-
|
27 |
-
$field['query_args']['post_type'] = $field['post_type'];
|
28 |
-
}
|
29 |
|
30 |
-
|
31 |
-
* Set default placeholder
|
32 |
* - If multiple post types: show 'Select a post'.
|
33 |
* - If single post type: show 'Select a %post_type_name%'.
|
34 |
*/
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
// Translators: %s is the
|
41 |
-
$
|
42 |
}
|
43 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
// Set parent option, which will change field name to `parent_id` to save as post parent.
|
46 |
if ( $field['parent'] ) {
|
17 |
*/
|
18 |
public static function normalize( $field ) {
|
19 |
// Set default field args.
|
|
|
20 |
$field = wp_parse_args( $field, array(
|
21 |
'post_type' => 'post',
|
22 |
'parent' => false,
|
23 |
) );
|
24 |
|
25 |
+
$field['post_type'] = (array) $field['post_type'];
|
|
|
|
|
26 |
|
27 |
+
/*
|
28 |
+
* Set default placeholder:
|
29 |
* - If multiple post types: show 'Select a post'.
|
30 |
* - If single post type: show 'Select a %post_type_name%'.
|
31 |
*/
|
32 |
+
$placeholder = __( 'Select a post', 'meta-box' );
|
33 |
+
if ( 1 === count( $field['post_type'] ) ) {
|
34 |
+
$post_type = reset( $field['post_type'] );
|
35 |
+
$post_type_object = get_post_type_object( $post_type );
|
36 |
+
if ( ! empty( $post_type_object ) ) {
|
37 |
+
// Translators: %s is the taxonomy singular label.
|
38 |
+
$placeholder = sprintf( __( 'Select a %s', 'meta-box' ), strtolower( $post_type_object->labels->singular_name ) );
|
39 |
}
|
40 |
}
|
41 |
+
$field = wp_parse_args( $field, array(
|
42 |
+
'placeholder' => $placeholder,
|
43 |
+
) );
|
44 |
+
$field = parent::normalize( $field );
|
45 |
+
|
46 |
+
if ( ! isset( $field['query_args']['post_type'] ) ) {
|
47 |
+
$field['query_args']['post_type'] = $field['post_type'];
|
48 |
+
}
|
49 |
|
50 |
// Set parent option, which will change field name to `parent_id` to save as post parent.
|
51 |
if ( $field['parent'] ) {
|
inc/fields/taxonomy.php
CHANGED
@@ -28,7 +28,6 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
28 |
}
|
29 |
|
30 |
// Set default field args.
|
31 |
-
$field = parent::normalize( $field );
|
32 |
$field = wp_parse_args( $field, array(
|
33 |
'taxonomy' => 'category',
|
34 |
) );
|
@@ -36,25 +35,29 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
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,
|
42 |
-
) );
|
43 |
-
|
44 |
/*
|
45 |
* Set default placeholder:
|
46 |
* - If multiple taxonomies: show 'Select a term'.
|
47 |
* - If single taxonomy: show 'Select a %taxonomy_name%'.
|
48 |
*/
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
// Translators: %s is the taxonomy singular label.
|
55 |
-
$
|
56 |
}
|
57 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
// Prevent cloning for taxonomy field.
|
60 |
$field['clone'] = false;
|
@@ -135,6 +138,9 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
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.
|
28 |
}
|
29 |
|
30 |
// Set default field args.
|
|
|
31 |
$field = wp_parse_args( $field, array(
|
32 |
'taxonomy' => 'category',
|
33 |
) );
|
35 |
// Force taxonomy to be an array.
|
36 |
$field['taxonomy'] = (array) $field['taxonomy'];
|
37 |
|
|
|
|
|
|
|
|
|
|
|
38 |
/*
|
39 |
* Set default placeholder:
|
40 |
* - If multiple taxonomies: show 'Select a term'.
|
41 |
* - If single taxonomy: show 'Select a %taxonomy_name%'.
|
42 |
*/
|
43 |
+
$placeholder = __( 'Select a term', 'meta-box' );
|
44 |
+
if ( 1 === count( $field['taxonomy'] ) ) {
|
45 |
+
$taxonomy = reset( $field['taxonomy'] );
|
46 |
+
$taxonomy_object = get_taxonomy( $taxonomy );
|
47 |
+
if ( false !== $taxonomy_object ) {
|
48 |
// Translators: %s is the taxonomy singular label.
|
49 |
+
$placeholder = sprintf( __( 'Select a %s', 'meta-box' ), strtolower( $taxonomy_object->labels->singular_name ) );
|
50 |
}
|
51 |
}
|
52 |
+
$field = wp_parse_args( $field, array(
|
53 |
+
'placeholder' => $placeholder,
|
54 |
+
) );
|
55 |
+
$field = parent::normalize( $field );
|
56 |
+
|
57 |
+
// Set default query args.
|
58 |
+
$field['query_args'] = wp_parse_args( $field['query_args'], array(
|
59 |
+
'hide_empty' => false,
|
60 |
+
) );
|
61 |
|
62 |
// Prevent cloning for taxonomy field.
|
63 |
$field['clone'] = false;
|
138 |
* @return array List of post term objects.
|
139 |
*/
|
140 |
public static function get_value( $field, $args = array(), $post_id = null ) {
|
141 |
+
if ( ! $post_id ) {
|
142 |
+
$post_id = get_the_ID();
|
143 |
+
}
|
144 |
$value = wp_get_object_terms( $post_id, $field['taxonomy'] );
|
145 |
|
146 |
// Get single value if necessary.
|
inc/fields/user.php
CHANGED
@@ -18,6 +18,9 @@ class RWMB_User_Field extends RWMB_Object_Choice_Field {
|
|
18 |
*/
|
19 |
public static function normalize( $field ) {
|
20 |
// Set default field args.
|
|
|
|
|
|
|
21 |
$field = parent::normalize( $field );
|
22 |
|
23 |
// Prevent select tree for user since it's not hierarchical.
|
@@ -26,9 +29,6 @@ class RWMB_User_Field extends RWMB_Object_Choice_Field {
|
|
26 |
// Set to always flat.
|
27 |
$field['flatten'] = true;
|
28 |
|
29 |
-
// Set default placeholder.
|
30 |
-
$field['placeholder'] = empty( $field['placeholder'] ) ? __( 'Select an user', 'meta-box' ) : $field['placeholder'];
|
31 |
-
|
32 |
// Set default query args.
|
33 |
$field['query_args'] = wp_parse_args( $field['query_args'], array(
|
34 |
'orderby' => 'display_name',
|
18 |
*/
|
19 |
public static function normalize( $field ) {
|
20 |
// Set default field args.
|
21 |
+
$field = wp_parse_args( $field, array(
|
22 |
+
'placeholder' => __( 'Select an user', 'meta-box' ),
|
23 |
+
) );
|
24 |
$field = parent::normalize( $field );
|
25 |
|
26 |
// Prevent select tree for user since it's not hierarchical.
|
29 |
// Set to always flat.
|
30 |
$field['flatten'] = true;
|
31 |
|
|
|
|
|
|
|
32 |
// Set default query args.
|
33 |
$field['query_args'] = wp_parse_args( $field['query_args'], array(
|
34 |
'orderby' => 'display_name',
|
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.4' );
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
inc/meta-box.php
CHANGED
@@ -210,7 +210,9 @@ class RW_Meta_Box {
|
|
210 |
* Callback function to show fields in meta box
|
211 |
*/
|
212 |
public function show() {
|
213 |
-
|
|
|
|
|
214 |
$saved = $this->is_saved();
|
215 |
|
216 |
// Container.
|
@@ -294,6 +296,8 @@ class RW_Meta_Box {
|
|
294 |
$new = RWMB_Field::filter( 'sanitize', $new, $field );
|
295 |
}
|
296 |
$new = RWMB_Field::filter( 'value', $new, $field, $old );
|
|
|
|
|
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 );
|
210 |
* Callback function to show fields in meta box
|
211 |
*/
|
212 |
public function show() {
|
213 |
+
if ( ! $this->object_id ) {
|
214 |
+
$this->set_object_id( $this->get_current_object_id() );
|
215 |
+
}
|
216 |
$saved = $this->is_saved();
|
217 |
|
218 |
// Container.
|
296 |
$new = RWMB_Field::filter( 'sanitize', $new, $field );
|
297 |
}
|
298 |
$new = RWMB_Field::filter( 'value', $new, $field, $old );
|
299 |
+
// Filter to allow the field to be modified.
|
300 |
+
$field = RWMB_Field::filter( 'field', $new, $field, $old );
|
301 |
|
302 |
// Call defined method to save meta value, if there's no methods, call common one.
|
303 |
RWMB_Field::call( $field, 'save', $new, $old, $post_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: 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.4
|
7 |
* Author: MetaBox.io
|
8 |
* Author URI: https://metabox.io
|
9 |
* License: GPL2+
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: metabox, rilwis, fitwp, f-j-kaiser, funkatronic, PerWiklander, rua
|
|
3 |
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.
|
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.
|
3 |
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.5
|
7 |
+
Stable tag: 4.14.4
|
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.
|