Version Description
- 2021-12-14 =
- Add
min_clone
parameter to set the minimum number of clones. Props @baden03. - Post field: find by title only
- Meta Box Builder compatibility: parse choice options in real-time
- Prevent inputs overflow the container
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 5.5.0 |
Comparing to | |
See all releases |
Code changes from version 5.4.8 to 5.5.0
- css/style.css +5 -0
- inc/field.php +13 -6
- inc/fields/choice.php +5 -0
- inc/fields/file.php +1 -1
- inc/fields/osm.php +2 -2
- inc/fields/post.php +36 -3
- inc/loader.php +1 -1
- js/clone.js +8 -2
- meta-box.php +2 -2
- readme.txt +8 -2
css/style.css
CHANGED
@@ -41,6 +41,11 @@
|
|
41 |
.rwmb-input input[type="button"] {
|
42 |
width: auto;
|
43 |
}
|
|
|
|
|
|
|
|
|
|
|
44 |
.rwmb-textarea {
|
45 |
resize: vertical;
|
46 |
}
|
41 |
.rwmb-input input[type="button"] {
|
42 |
width: auto;
|
43 |
}
|
44 |
+
.rwmb-input input,
|
45 |
+
.rwmb-input textarea,
|
46 |
+
.rwmb-input select {
|
47 |
+
max-width: 100%;
|
48 |
+
}
|
49 |
.rwmb-textarea {
|
50 |
resize: vertical;
|
51 |
}
|
inc/field.php
CHANGED
@@ -105,10 +105,12 @@ abstract class RWMB_Field {
|
|
105 |
);
|
106 |
}
|
107 |
|
|
|
108 |
$data_max_clone = is_numeric( $field['max_clone'] ) && $field['max_clone'] > 1 ? ' data-max-clone=' . $field['max_clone'] : '';
|
109 |
|
110 |
$input_open = sprintf(
|
111 |
-
'<div class="rwmb-input"%s>',
|
|
|
112 |
$data_max_clone
|
113 |
);
|
114 |
|
@@ -339,6 +341,7 @@ abstract class RWMB_Field {
|
|
339 |
'save_field' => true,
|
340 |
|
341 |
'clone' => false,
|
|
|
342 |
'max_clone' => 0,
|
343 |
'sort_clone' => false,
|
344 |
'add_button' => __( '+ Add more', 'meta-box' ),
|
@@ -548,9 +551,6 @@ abstract class RWMB_Field {
|
|
548 |
|
549 |
/**
|
550 |
* Call a method of a field.
|
551 |
-
* This should be replaced by static::$method( $args ) in PHP 5.3.
|
552 |
-
*
|
553 |
-
* @return mixed
|
554 |
*/
|
555 |
public static function call() {
|
556 |
$args = func_get_args();
|
@@ -561,7 +561,9 @@ abstract class RWMB_Field {
|
|
561 |
if ( is_string( $check ) ) {
|
562 |
$method = array_shift( $args );
|
563 |
$field = reset( $args ); // Keep field as 1st param.
|
564 |
-
}
|
|
|
|
|
565 |
$field = array_shift( $args );
|
566 |
$method = array_shift( $args );
|
567 |
|
@@ -573,7 +575,12 @@ abstract class RWMB_Field {
|
|
573 |
}
|
574 |
}
|
575 |
|
576 |
-
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
|
579 |
/**
|
105 |
);
|
106 |
}
|
107 |
|
108 |
+
$data_min_clone = is_numeric( $field['min_clone'] ) && $field['min_clone'] > 1 ? ' data-min-clone=' . $field['min_clone'] : '';
|
109 |
$data_max_clone = is_numeric( $field['max_clone'] ) && $field['max_clone'] > 1 ? ' data-max-clone=' . $field['max_clone'] : '';
|
110 |
|
111 |
$input_open = sprintf(
|
112 |
+
'<div class="rwmb-input" %s %s>',
|
113 |
+
$data_min_clone,
|
114 |
$data_max_clone
|
115 |
);
|
116 |
|
341 |
'save_field' => true,
|
342 |
|
343 |
'clone' => false,
|
344 |
+
'min_clone' => 0,
|
345 |
'max_clone' => 0,
|
346 |
'sort_clone' => false,
|
347 |
'add_button' => __( '+ Add more', 'meta-box' ),
|
551 |
|
552 |
/**
|
553 |
* Call a method of a field.
|
|
|
|
|
|
|
554 |
*/
|
555 |
public static function call() {
|
556 |
$args = func_get_args();
|
561 |
if ( is_string( $check ) ) {
|
562 |
$method = array_shift( $args );
|
563 |
$field = reset( $args ); // Keep field as 1st param.
|
564 |
+
}
|
565 |
+
// Params: field, method name, other params.
|
566 |
+
else {
|
567 |
$field = array_shift( $args );
|
568 |
$method = array_shift( $args );
|
569 |
|
575 |
}
|
576 |
}
|
577 |
|
578 |
+
$class = RWMB_Helpers_Field::get_class( $field );
|
579 |
+
if ( method_exists( $class, $method ) ) {
|
580 |
+
return call_user_func_array( array( $class, $method ), $args );
|
581 |
+
} else {
|
582 |
+
_deprecated_function( "$class::$method", '5.4.8' );
|
583 |
+
}
|
584 |
}
|
585 |
|
586 |
/**
|
inc/fields/choice.php
CHANGED
@@ -36,6 +36,11 @@ abstract class RWMB_Choice_Field extends RWMB_Field {
|
|
36 |
)
|
37 |
);
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
return $field;
|
40 |
}
|
41 |
|
36 |
)
|
37 |
);
|
38 |
|
39 |
+
// Use callback: function_name format from Meta Box Builder.
|
40 |
+
if ( isset( $field['_callback'] ) && is_callable( $field['_callback'] ) ) {
|
41 |
+
$field['options'] = call_user_func( $field['_callback'] );
|
42 |
+
}
|
43 |
+
|
44 |
return $field;
|
45 |
}
|
46 |
|
inc/fields/file.php
CHANGED
@@ -288,7 +288,7 @@ class RWMB_File_Field extends RWMB_Field {
|
|
288 |
$new = array_filter( (array) $new );
|
289 |
|
290 |
$count = self::transform( $input );
|
291 |
-
for ( $i = 0; $i
|
292 |
$attachment = self::handle_upload( "{$input}_{$i}", $post_id, $field );
|
293 |
if ( $attachment && ! is_wp_error( $attachment ) ) {
|
294 |
$new[] = $attachment;
|
288 |
$new = array_filter( (array) $new );
|
289 |
|
290 |
$count = self::transform( $input );
|
291 |
+
for ( $i = 0; $i < $count; $i ++ ) {
|
292 |
$attachment = self::handle_upload( "{$input}_{$i}", $post_id, $field );
|
293 |
if ( $attachment && ! is_wp_error( $attachment ) ) {
|
294 |
$new[] = $attachment;
|
inc/fields/osm.php
CHANGED
@@ -15,8 +15,8 @@ class RWMB_OSM_Field extends RWMB_Field {
|
|
15 |
*/
|
16 |
public static function admin_enqueue_scripts() {
|
17 |
// Because map is a hosted service, it's ok to use hosted Leaflet scripts.
|
18 |
-
wp_enqueue_style( 'leaflet', 'https://unpkg.com/leaflet@1.
|
19 |
-
wp_enqueue_script( 'leaflet', 'https://unpkg.com/leaflet@1.
|
20 |
|
21 |
wp_enqueue_style( 'rwmb-osm', RWMB_CSS_URL . 'osm.css', array( 'leaflet' ), RWMB_VER );
|
22 |
wp_enqueue_script( 'rwmb-osm', RWMB_JS_URL . 'osm.js', array( 'jquery', 'jquery-ui-autocomplete', 'leaflet' ), RWMB_VER, true );
|
15 |
*/
|
16 |
public static function admin_enqueue_scripts() {
|
17 |
// Because map is a hosted service, it's ok to use hosted Leaflet scripts.
|
18 |
+
wp_enqueue_style( 'leaflet', 'https://unpkg.com/leaflet@1.7.1/dist/leaflet.css', array(), '1.7.1' );
|
19 |
+
wp_enqueue_script( 'leaflet', 'https://unpkg.com/leaflet@1.7.1/dist/leaflet.js', array(), '1.7.1', true );
|
20 |
|
21 |
wp_enqueue_style( 'rwmb-osm', RWMB_CSS_URL . 'osm.css', array( 'leaflet' ), RWMB_VER );
|
22 |
wp_enqueue_script( 'rwmb-osm', RWMB_JS_URL . 'osm.js', array( 'jquery', 'jquery-ui-autocomplete', 'leaflet' ), RWMB_VER, true );
|
inc/fields/post.php
CHANGED
@@ -150,11 +150,15 @@ class RWMB_Post_Field extends RWMB_Object_Choice_Field {
|
|
150 |
return $options;
|
151 |
}
|
152 |
|
153 |
-
|
|
|
|
|
|
|
|
|
154 |
$options = array();
|
155 |
foreach ( $query->posts as $post ) {
|
156 |
-
$label
|
157 |
-
$label
|
158 |
$options[ $post->ID ] = array(
|
159 |
'value' => $post->ID,
|
160 |
'label' => $label,
|
@@ -168,6 +172,35 @@ class RWMB_Post_Field extends RWMB_Object_Choice_Field {
|
|
168 |
return $options;
|
169 |
}
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
/**
|
172 |
* Get meta value.
|
173 |
* If field is cloneable, value is saved as a single entry in DB.
|
150 |
return $options;
|
151 |
}
|
152 |
|
153 |
+
// Only search by title.
|
154 |
+
add_filter( 'posts_search', [ __CLASS__, 'search_by_title' ], 10, 2 );
|
155 |
+
$query = new WP_Query( $args );
|
156 |
+
remove_filter( 'posts_search', [ __CLASS__, 'search_by_title' ] );
|
157 |
+
|
158 |
$options = array();
|
159 |
foreach ( $query->posts as $post ) {
|
160 |
+
$label = $post->post_title ? $post->post_title : __( '(No title)', 'meta-box' );
|
161 |
+
$label = self::filter( 'choice_label', $label, $field, $post );
|
162 |
$options[ $post->ID ] = array(
|
163 |
'value' => $post->ID,
|
164 |
'label' => $label,
|
172 |
return $options;
|
173 |
}
|
174 |
|
175 |
+
/**
|
176 |
+
* Only search posts by title.
|
177 |
+
* WordPress searches by either title or content which is confused when users can't find their posts.
|
178 |
+
*
|
179 |
+
* @link https://developer.wordpress.org/reference/hooks/posts_search/
|
180 |
+
*/
|
181 |
+
public static function search_by_title( $search, &$wp_query ) {
|
182 |
+
global $wpdb;
|
183 |
+
if ( empty( $search ) ) {
|
184 |
+
return $search;
|
185 |
+
}
|
186 |
+
$q = $wp_query->query_vars;
|
187 |
+
$n = ! empty( $q['exact'] ) ? '' : '%';
|
188 |
+
$search = '';
|
189 |
+
$searchand = '';
|
190 |
+
foreach ( (array) $q['search_terms'] as $term ) {
|
191 |
+
$term = esc_sql( $wpdb->esc_like( $term ) );
|
192 |
+
$search .= "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
|
193 |
+
$searchand = ' AND ';
|
194 |
+
}
|
195 |
+
if ( ! empty( $search ) ) {
|
196 |
+
$search = " AND ({$search}) ";
|
197 |
+
if ( ! is_user_logged_in() ) {
|
198 |
+
$search .= " AND ($wpdb->posts.post_password = '') ";
|
199 |
+
}
|
200 |
+
}
|
201 |
+
return $search;
|
202 |
+
}
|
203 |
+
|
204 |
/**
|
205 |
* Get meta value.
|
206 |
* If field is cloneable, value is saved as a single entry in DB.
|
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.
|
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.5.0' );
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
js/clone.js
CHANGED
@@ -156,8 +156,14 @@
|
|
156 |
* @param $container .rwmb-input container
|
157 |
*/
|
158 |
function toggleRemoveButtons( $container ) {
|
159 |
-
|
160 |
-
$clones.children( '.
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
// Recursive for nested groups.
|
163 |
$container.find( '.rwmb-input' ).each( function () {
|
156 |
* @param $container .rwmb-input container
|
157 |
*/
|
158 |
function toggleRemoveButtons( $container ) {
|
159 |
+
|
160 |
+
var $clones = $container.children( '.rwmb-clone' ),
|
161 |
+
minClone = 1;
|
162 |
+
|
163 |
+
if ( $container.data( 'min-clone' ) ) {
|
164 |
+
minClone = parseInt( $container.data( 'min-clone' ) );
|
165 |
+
}
|
166 |
+
$clones.children( '.remove-clone' ).toggle( $clones.length > minClone );
|
167 |
|
168 |
// Recursive for nested groups.
|
169 |
$container.find( '.rwmb-input' ).each( function () {
|
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.
|
7 |
* Author: MetaBox.io
|
8 |
* Author URI: https://metabox.io
|
9 |
* License: GPL2+
|
@@ -17,4 +17,4 @@ 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 |
-
}
|
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.5.0
|
7 |
* Author: MetaBox.io
|
8 |
* Author URI: https://metabox.io
|
9 |
* License: GPL2+
|
17 |
require_once dirname( __FILE__ ) . '/inc/loader.php';
|
18 |
$rwmb_loader = new RWMB_Loader();
|
19 |
$rwmb_loader->init();
|
20 |
+
}
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: https://metabox.io/pricing/
|
|
4 |
Tags: meta box, custom fields, custom post types, custom taxonomies, cpt, meta boxes, custom field, post type, taxonomy, meta, admin, advanced, custom, edit, field, file, image, magic fields, post types, more fields, post, repeater, simple fields, text, textarea, type, cms, fields post
|
5 |
Requires at least: 4.3
|
6 |
Requires PHP: 5.6
|
7 |
-
Tested up to: 5.8.
|
8 |
-
Stable tag: 5.
|
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 your custom post types in WordPress.
|
@@ -168,6 +168,12 @@ To getting started with the plugin, please read the [Quick Start Guide](https://
|
|
168 |
|
169 |
== Changelog ==
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
= 5.4.8 - 2021-10-20 =
|
172 |
- Respect `cols` attribute of `textarea` field to set the width of the input (without `cols`, textarea is 100% width)
|
173 |
- Fix padding for seamless style in Gutenberg
|
4 |
Tags: meta box, custom fields, custom post types, custom taxonomies, cpt, meta boxes, custom field, post type, taxonomy, meta, admin, advanced, custom, edit, field, file, image, magic fields, post types, more fields, post, repeater, simple fields, text, textarea, type, cms, fields post
|
5 |
Requires at least: 4.3
|
6 |
Requires PHP: 5.6
|
7 |
+
Tested up to: 5.8.2
|
8 |
+
Stable tag: 5.5.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 your custom post types in WordPress.
|
168 |
|
169 |
== Changelog ==
|
170 |
|
171 |
+
= 5.5.0 - 2021-12-14 =
|
172 |
+
- Add `min_clone` parameter to set the minimum number of clones. Props @baden03.
|
173 |
+
- Post field: find by title only
|
174 |
+
- Meta Box Builder compatibility: parse choice options in real-time
|
175 |
+
- Prevent inputs overflow the container
|
176 |
+
|
177 |
= 5.4.8 - 2021-10-20 =
|
178 |
- Respect `cols` attribute of `textarea` field to set the width of the input (without `cols`, textarea is 100% width)
|
179 |
- Fix padding for seamless style in Gutenberg
|