Version Description
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 4.18.3 |
Comparing to | |
See all releases |
Code changes from version 4.18.2 to 4.18.3
- inc/fields/input-list.php +1 -1
- inc/fields/media.php +1 -1
- inc/fields/taxonomy.php +23 -2
- inc/loader.php +1 -1
- js/input-list.js +3 -1
- js/media.js +41 -12
- js/osm.js +8 -0
- js/select-tree.js +54 -46
- js/validate.js +6 -1
- meta-box.php +1 -1
- readme.txt +2 -2
inc/fields/input-list.php
CHANGED
@@ -89,7 +89,7 @@ class RWMB_Input_List_Field extends RWMB_Choice_Field {
|
|
89 |
*/
|
90 |
public static function get_select_all_html( $field ) {
|
91 |
if ( $field['multiple'] && $field['select_all_none'] ) {
|
92 |
-
return sprintf( '<p><button class="rwmb-input-list-select-all-none button" data-name="%s">%s</button></p>', $field['id'], __( '
|
93 |
}
|
94 |
return '';
|
95 |
}
|
89 |
*/
|
90 |
public static function get_select_all_html( $field ) {
|
91 |
if ( $field['multiple'] && $field['select_all_none'] ) {
|
92 |
+
return sprintf( '<p><button class="rwmb-input-list-select-all-none button" data-name="%s">%s</button></p>', $field['id'], __( 'Toggle All', 'meta-box' ) );
|
93 |
}
|
94 |
return '';
|
95 |
}
|
inc/fields/media.php
CHANGED
@@ -149,7 +149,7 @@ class RWMB_Media_Field extends RWMB_File_Field {
|
|
149 |
$attributes['value'] = implode( ',', $value );
|
150 |
|
151 |
// Add attachment details.
|
152 |
-
$attachments = array_filter( array_map( 'wp_prepare_attachment_for_js', $value ) );
|
153 |
$attributes['data-attachments'] = json_encode( $attachments );
|
154 |
|
155 |
return $attributes;
|
149 |
$attributes['value'] = implode( ',', $value );
|
150 |
|
151 |
// Add attachment details.
|
152 |
+
$attachments = array_values( array_filter( array_map( 'wp_prepare_attachment_for_js', $value ) ) );
|
153 |
$attributes['data-attachments'] = json_encode( $attachments );
|
154 |
|
155 |
return $attributes;
|
inc/fields/taxonomy.php
CHANGED
@@ -31,8 +31,9 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
31 |
$field = wp_parse_args(
|
32 |
$field,
|
33 |
array(
|
34 |
-
'taxonomy'
|
35 |
-
'query_args'
|
|
|
36 |
)
|
37 |
);
|
38 |
|
@@ -284,6 +285,26 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
284 |
parent::admin_enqueue_scripts();
|
285 |
wp_enqueue_style( 'rwmb-taxonomy', RWMB_CSS_URL . 'taxonomy.css', array(), RWMB_VER );
|
286 |
wp_enqueue_script( 'rwmb-taxonomy', RWMB_JS_URL . 'taxonomy.js', array( 'jquery' ), RWMB_VER, true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
}
|
288 |
|
289 |
/**
|
31 |
$field = wp_parse_args(
|
32 |
$field,
|
33 |
array(
|
34 |
+
'taxonomy' => 'category',
|
35 |
+
'query_args' => array(),
|
36 |
+
'remove_default' => true,
|
37 |
)
|
38 |
);
|
39 |
|
285 |
parent::admin_enqueue_scripts();
|
286 |
wp_enqueue_style( 'rwmb-taxonomy', RWMB_CSS_URL . 'taxonomy.css', array(), RWMB_VER );
|
287 |
wp_enqueue_script( 'rwmb-taxonomy', RWMB_JS_URL . 'taxonomy.js', array( 'jquery' ), RWMB_VER, true );
|
288 |
+
|
289 |
+
// Field is the 1st param.
|
290 |
+
$args = func_get_args();
|
291 |
+
$field = $args[0];
|
292 |
+
self::remove_default_meta_box( $field );
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Remove default WordPress taxonomy meta box.
|
297 |
+
*
|
298 |
+
* @param array $field Field settings.
|
299 |
+
*/
|
300 |
+
protected static function remove_default_meta_box( $field ) {
|
301 |
+
if ( empty( $field['remove_default'] ) ) {
|
302 |
+
return;
|
303 |
+
}
|
304 |
+
foreach ( $field['taxonomy'] as $taxonomy ) {
|
305 |
+
$id = is_taxonomy_hierarchical( $taxonomy ) ? "{$taxonomy}div" : "tagsdiv-{$taxonomy}";
|
306 |
+
remove_meta_box( $id, null, 'side' );
|
307 |
+
}
|
308 |
}
|
309 |
|
310 |
/**
|
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.18.
|
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.18.3' );
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
js/input-list.js
CHANGED
@@ -18,7 +18,9 @@ jQuery( function ( $ ) {
|
|
18 |
.on( 'clone', '.rwmb-input-list.rwmb-collapse input[type="checkbox"]', update );
|
19 |
$( '.rwmb-input-list.rwmb-collapse input[type="checkbox"]' ).each( update );
|
20 |
|
21 |
-
$( document ).on( 'click', '.rwmb-input-list-select-all-none', function() {
|
|
|
|
|
22 |
var $this = $( this ),
|
23 |
checked = $this.data( 'checked' );
|
24 |
|
18 |
.on( 'clone', '.rwmb-input-list.rwmb-collapse input[type="checkbox"]', update );
|
19 |
$( '.rwmb-input-list.rwmb-collapse input[type="checkbox"]' ).each( update );
|
20 |
|
21 |
+
$( document ).on( 'click', '.rwmb-input-list-select-all-none', function( e ) {
|
22 |
+
e.preventDefault();
|
23 |
+
|
24 |
var $this = $( this ),
|
25 |
checked = $this.data( 'checked' );
|
26 |
|
js/media.js
CHANGED
@@ -12,7 +12,9 @@ jQuery( function ( $ ) {
|
|
12 |
MediaCollection, Controller, MediaField, MediaList, MediaItem, MediaButton, MediaStatus, EditMedia,
|
13 |
MediaDetails, MediaLibrary, MediaSelect;
|
14 |
|
15 |
-
MediaCollection =
|
|
|
|
|
16 |
initialize: function ( models, options ) {
|
17 |
this.controller = options.controller || new models.Controller;
|
18 |
this.on( 'add remove reset', function () {
|
@@ -20,8 +22,6 @@ jQuery( function ( $ ) {
|
|
20 |
this.controller.set( 'length', this.length );
|
21 |
this.controller.set( 'full', max > 0 && this.length >= max );
|
22 |
} );
|
23 |
-
|
24 |
-
media.model.Attachments.prototype.initialize.call( this, models, options );
|
25 |
},
|
26 |
|
27 |
add: function ( models, options ) {
|
@@ -42,11 +42,15 @@ jQuery( function ( $ ) {
|
|
42 |
models = _.first( models, left );
|
43 |
}
|
44 |
|
45 |
-
|
46 |
},
|
47 |
|
48 |
remove: function ( models, options ) {
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
if ( this.controller.get( 'forceDelete' ) === true ) {
|
51 |
models = ! _.isArray( models ) ? [models] : models;
|
52 |
_.each( models, function ( model ) {
|
@@ -122,14 +126,8 @@ jQuery( function ( $ ) {
|
|
122 |
this.createAddButton();
|
123 |
this.createStatus();
|
124 |
|
125 |
-
// Render
|
126 |
this.render();
|
127 |
-
|
128 |
-
// Load initial attachments.
|
129 |
-
var models = this.$input.data( 'attachments' ).map( function( attachment ) {
|
130 |
-
return wp.media.model.Attachment.create( attachment );
|
131 |
-
} );
|
132 |
-
this.controller.get( 'items' ).add( models );
|
133 |
|
134 |
// Listen for destroy event on input
|
135 |
this.$input.on( 'remove', function () {
|
@@ -149,6 +147,16 @@ jQuery( function ( $ ) {
|
|
149 |
}, 500 ) );
|
150 |
},
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
// Creates media list
|
153 |
createList: function () {
|
154 |
this.list = new MediaList( {controller: this.controller} );
|
@@ -260,6 +268,15 @@ jQuery( function ( $ ) {
|
|
260 |
edit: this.collection
|
261 |
} );
|
262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
this._switchFrame.on( 'select', function () {
|
264 |
var selection = this._switchFrame.state().get( 'selection' ),
|
265 |
collection = this.collection,
|
@@ -354,6 +371,15 @@ jQuery( function ( $ ) {
|
|
354 |
edit: this.collection
|
355 |
} );
|
356 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
this._frame.on( 'select', function () {
|
358 |
var selection = this._frame.state().get( 'selection' );
|
359 |
this.collection.add( selection.models );
|
@@ -494,6 +520,9 @@ jQuery( function ( $ ) {
|
|
494 |
createStates: function () {
|
495 |
var options = this.options;
|
496 |
|
|
|
|
|
|
|
497 |
if ( this.options.states ) {
|
498 |
return;
|
499 |
}
|
12 |
MediaCollection, Controller, MediaField, MediaList, MediaItem, MediaButton, MediaStatus, EditMedia,
|
13 |
MediaDetails, MediaLibrary, MediaSelect;
|
14 |
|
15 |
+
MediaCollection = Backbone.Collection.extend( {
|
16 |
+
model: wp.media.model.Attachment,
|
17 |
+
|
18 |
initialize: function ( models, options ) {
|
19 |
this.controller = options.controller || new models.Controller;
|
20 |
this.on( 'add remove reset', function () {
|
22 |
this.controller.set( 'length', this.length );
|
23 |
this.controller.set( 'full', max > 0 && this.length >= max );
|
24 |
} );
|
|
|
|
|
25 |
},
|
26 |
|
27 |
add: function ( models, options ) {
|
42 |
models = _.first( models, left );
|
43 |
}
|
44 |
|
45 |
+
Backbone.Collection.prototype.add.call( this, models, options );
|
46 |
},
|
47 |
|
48 |
remove: function ( models, options ) {
|
49 |
+
// Don't remove models if event is not fired from MB plugin.
|
50 |
+
if( ! $( event.target ).closest( '.rwmb-field, [data-class="rwmb-field"]' ).length ) {
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
models = Backbone.Collection.prototype.remove.call( this, models, options );
|
54 |
if ( this.controller.get( 'forceDelete' ) === true ) {
|
55 |
models = ! _.isArray( models ) ? [models] : models;
|
56 |
_.each( models, function ( model ) {
|
126 |
this.createAddButton();
|
127 |
this.createStatus();
|
128 |
|
|
|
129 |
this.render();
|
130 |
+
this.loadInitialAttachments();
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
// Listen for destroy event on input
|
133 |
this.$input.on( 'remove', function () {
|
147 |
}, 500 ) );
|
148 |
},
|
149 |
|
150 |
+
loadInitialAttachments: function () {
|
151 |
+
if ( ! this.$input.val() ) {
|
152 |
+
return;
|
153 |
+
}
|
154 |
+
var models = this.$input.data( 'attachments' ).map( function( attachment ) {
|
155 |
+
return wp.media.model.Attachment.create( attachment );
|
156 |
+
} );
|
157 |
+
this.controller.get( 'items' ).add( models );
|
158 |
+
},
|
159 |
+
|
160 |
// Creates media list
|
161 |
createList: function () {
|
162 |
this.list = new MediaList( {controller: this.controller} );
|
268 |
edit: this.collection
|
269 |
} );
|
270 |
|
271 |
+
// Refresh content when frame opens
|
272 |
+
this._switchFrame.on( 'open', function() {
|
273 |
+
var frameContent = this._switchFrame.content.get();
|
274 |
+
if ( frameContent && frameContent.collection ) {
|
275 |
+
frameContent.collection.mirroring._hasMore = true;
|
276 |
+
frameContent.collection.more();
|
277 |
+
}
|
278 |
+
}, this );
|
279 |
+
|
280 |
this._switchFrame.on( 'select', function () {
|
281 |
var selection = this._switchFrame.state().get( 'selection' ),
|
282 |
collection = this.collection,
|
371 |
edit: this.collection
|
372 |
} );
|
373 |
|
374 |
+
// Refresh content when frame opens
|
375 |
+
this._frame.on( 'open', function() {
|
376 |
+
var frameContent = this._frame.content.get();
|
377 |
+
if ( frameContent && frameContent.collection ) {
|
378 |
+
frameContent.collection.mirroring._hasMore = true;
|
379 |
+
frameContent.collection.more();
|
380 |
+
}
|
381 |
+
}, this );
|
382 |
+
|
383 |
this._frame.on( 'select', function () {
|
384 |
var selection = this._frame.state().get( 'selection' );
|
385 |
this.collection.add( selection.models );
|
520 |
createStates: function () {
|
521 |
var options = this.options;
|
522 |
|
523 |
+
// Add reference so we know MediaFrame belongs to MB plugin.
|
524 |
+
this.$el.attr( 'data-class', 'rwmb-field' );
|
525 |
+
|
526 |
if ( this.options.states ) {
|
527 |
return;
|
528 |
}
|
js/osm.js
CHANGED
@@ -16,6 +16,12 @@
|
|
16 |
this.initMarkerPosition();
|
17 |
this.addListeners();
|
18 |
this.autocomplete();
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
},
|
20 |
|
21 |
// Initialize DOM elements
|
@@ -38,6 +44,8 @@
|
|
38 |
center: latLng,
|
39 |
zoom: 14
|
40 |
} );
|
|
|
|
|
41 |
L.tileLayer( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
42 |
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
43 |
} ).addTo( this.map );
|
16 |
this.initMarkerPosition();
|
17 |
this.addListeners();
|
18 |
this.autocomplete();
|
19 |
+
|
20 |
+
// Make sure the map is displayed fully.
|
21 |
+
var map = this.map;
|
22 |
+
setTimeout( function() {
|
23 |
+
map.invalidateSize();
|
24 |
+
}, 0 );
|
25 |
},
|
26 |
|
27 |
// Initialize DOM elements
|
44 |
center: latLng,
|
45 |
zoom: 14
|
46 |
} );
|
47 |
+
|
48 |
+
|
49 |
L.tileLayer( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
50 |
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
51 |
} ).addTo( this.map );
|
js/select-tree.js
CHANGED
@@ -1,46 +1,54 @@
|
|
1 |
-
jQuery( function ( $ ) {
|
2 |
-
'use strict';
|
3 |
-
|
4 |
-
function setInitialRequiredProp() {
|
5 |
-
var $this = $( this ),
|
6 |
-
required = $this.prop( 'required' );
|
7 |
-
|
8 |
-
if ( required ) {
|
9 |
-
$this.data( 'initial-required', required );
|
10 |
-
}
|
11 |
-
}
|
12 |
-
|
13 |
-
function unsetRequiredProp() {
|
14 |
-
$( this ).prop( 'required', false );
|
15 |
-
}
|
16 |
-
|
17 |
-
function setRequiredProp() {
|
18 |
-
var $this = $( this );
|
19 |
-
|
20 |
-
if ( $this.data( 'initial-required' ) ) {
|
21 |
-
$this.prop( 'required', true );
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
25 |
-
function
|
26 |
-
var $this = $( this ),
|
27 |
-
val = $this.val(),
|
28 |
-
$
|
29 |
-
$
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( function ( $ ) {
|
2 |
+
'use strict';
|
3 |
+
|
4 |
+
function setInitialRequiredProp() {
|
5 |
+
var $this = $( this ),
|
6 |
+
required = $this.prop( 'required' );
|
7 |
+
|
8 |
+
if ( required ) {
|
9 |
+
$this.data( 'initial-required', required );
|
10 |
+
}
|
11 |
+
}
|
12 |
+
|
13 |
+
function unsetRequiredProp() {
|
14 |
+
$( this ).prop( 'required', false );
|
15 |
+
}
|
16 |
+
|
17 |
+
function setRequiredProp() {
|
18 |
+
var $this = $( this );
|
19 |
+
|
20 |
+
if ( $this.data( 'initial-required' ) ) {
|
21 |
+
$this.prop( 'required', true );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
function toggleTree() {
|
26 |
+
var $this = $( this ),
|
27 |
+
val = $this.val(),
|
28 |
+
$tree = $this.siblings( '.rwmb-select-tree' ),
|
29 |
+
$selected = $tree.filter( "[data-parent-id='" + val + "']" ),
|
30 |
+
$notSelected = $tree.not( $selected );
|
31 |
+
|
32 |
+
$selected.removeClass( 'hidden' ).find( 'select' ).each( setRequiredProp );
|
33 |
+
$notSelected.addClass( 'hidden' ).find( 'select' ).each( unsetRequiredProp ).prop( 'selectedIndex', 0 );
|
34 |
+
}
|
35 |
+
|
36 |
+
function instantiateSelect2() {
|
37 |
+
var $this = $( this ),
|
38 |
+
options = $this.data( 'options' );
|
39 |
+
|
40 |
+
$this
|
41 |
+
.removeClass( 'select2-hidden-accessible' ).removeAttr( 'data-select2-id' )
|
42 |
+
.children().removeAttr( 'data-select2-id' ).end()
|
43 |
+
.siblings( '.select2-container' ).remove().end()
|
44 |
+
.select2( options );
|
45 |
+
|
46 |
+
toggleTree.call( this );
|
47 |
+
}
|
48 |
+
|
49 |
+
$( '.rwmb-select-tree > select' ).select2();
|
50 |
+
$( '.rwmb-select-tree > select' ).each( setInitialRequiredProp );
|
51 |
+
$( '.rwmb-input' )
|
52 |
+
.on( 'change', '.rwmb-select-tree > select', toggleTree )
|
53 |
+
.on( 'clone', '.rwmb-select-tree > select', instantiateSelect2 );
|
54 |
+
} );
|
js/validate.js
CHANGED
@@ -49,5 +49,10 @@ jQuery( function ( $ ) {
|
|
49 |
} );
|
50 |
|
51 |
// Execute.
|
52 |
-
$form.
|
|
|
|
|
|
|
|
|
|
|
53 |
} );
|
49 |
} );
|
50 |
|
51 |
// Execute.
|
52 |
+
$form.on( 'submit', function() {
|
53 |
+
// Update underlying textarea before submit validation.
|
54 |
+
if ( typeof tinyMCE !== 'undefined' ) {
|
55 |
+
tinyMCE.triggerSave();
|
56 |
+
}
|
57 |
+
} ).validate( rules );
|
58 |
} );
|
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.18.
|
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.18.3
|
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: 5.2.
|
7 |
-
Stable tag: 4.18.
|
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: 5.2.2
|
7 |
+
Stable tag: 4.18.3
|
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.
|