Meta Box - Version 4.13.2

Version Description

Download this release

Release Info

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

Code changes from version 4.13.1 to 4.13.2

css/video.css CHANGED
@@ -14,34 +14,12 @@
14
  background: #EEE;
15
  }
16
 
17
- .rwmb-video-item .rwmb-media-preview:before {
18
- padding-top: 56.25%;
19
- }
20
-
21
  .rwmb-video-item video {
22
  width: auto;
23
  height: 100%;
24
  }
25
 
26
- .rwmb-media-content .rwmb-video-wrapper {
27
- -webkit-transform: translate(-50%, -50%);
28
- -ms-transform: translate(-50%, -50%);
29
- transform: translate(-50%, -50%);
30
- max-height: 100%;
31
- max-width: 100%;
32
- border-radius: 3px;
33
- }
34
-
35
  .rwmb-video-item .rwmb-media-info {
36
  margin-left: 0;
37
- float: none;
38
- background: #FFF;
39
  padding: 10px;
40
  }
41
-
42
- .rwmb-video-item .rwmb-media-info h4 {
43
- white-space: nowrap;
44
- overflow: hidden;
45
- display: block;
46
- text-overflow: ellipsis;
47
- }
14
  background: #EEE;
15
  }
16
 
 
 
 
 
17
  .rwmb-video-item video {
18
  width: auto;
19
  height: 100%;
20
  }
21
 
 
 
 
 
 
 
 
 
 
22
  .rwmb-video-item .rwmb-media-info {
23
  margin-left: 0;
 
 
24
  padding: 10px;
25
  }
 
 
 
 
 
 
 
inc/fields/video.php CHANGED
@@ -3,7 +3,7 @@
3
  * Video field which uses WordPress media popup to upload and select video.
4
  *
5
  * @package Meta Box
6
- * @since 4.10
7
  */
8
 
9
  /**
@@ -40,7 +40,7 @@ class RWMB_Video_Field extends RWMB_Media_Field {
40
  * Get uploaded file information.
41
  *
42
  * @param int $file_id Attachment image ID (post ID). Required.
43
- * @param array $args Array of arguments (for size).
44
  *
45
  * @return array|bool False if file not found. Array of image info on success.
46
  */
@@ -100,18 +100,29 @@ class RWMB_Video_Field extends RWMB_Media_Field {
100
  }
101
 
102
  /**
103
- * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
104
  *
105
- * @param array $field Field parameters.
106
- * @param array $value The value.
107
- * @param array $args Additional arguments. Rarely used. See specific fields for details.
108
- * @param int|null $post_id Post ID. null for current post. Optional.
109
  *
110
  * @return string
111
  */
112
- public static function format_single_value( $field, $value, $args, $post_id ) {
113
  $ids = implode( ',', wp_list_pluck( $value, 'ID' ) );
114
 
 
 
 
 
 
 
 
 
 
 
 
115
  return wp_playlist_shortcode( array(
116
  'ids' => $ids,
117
  'type' => 'video',
3
  * Video field which uses WordPress media popup to upload and select video.
4
  *
5
  * @package Meta Box
6
+ * @since 4.10
7
  */
8
 
9
  /**
40
  * Get uploaded file information.
41
  *
42
  * @param int $file_id Attachment image ID (post ID). Required.
43
+ * @param array $args Array of arguments (for size).
44
  *
45
  * @return array|bool False if file not found. Array of image info on success.
46
  */
100
  }
101
 
102
  /**
103
+ * Format value for a clone.
104
  *
105
+ * @param array $field Field parameters.
106
+ * @param string|array $value The field meta value.
107
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
108
+ * @param int|null $post_id Post ID. null for current post. Optional.
109
  *
110
  * @return string
111
  */
112
+ public static function format_clone_value( $field, $value, $args, $post_id ) {
113
  $ids = implode( ',', wp_list_pluck( $value, 'ID' ) );
114
 
115
+ // Display single video.
116
+ if ( 1 === count( $value ) ) {
117
+ $video = reset( $value );
118
+ return wp_video_shortcode( array(
119
+ 'src' => $video['src'],
120
+ 'width' => $video['dimensions']['width'],
121
+ 'height' => $video['dimensions']['height'],
122
+ ) );
123
+ }
124
+
125
+ // Display multiple videos in a playlist.
126
  return wp_playlist_shortcode( array(
127
  'ids' => $ids,
128
  'type' => 'video',
inc/functions.php CHANGED
@@ -17,7 +17,7 @@ if ( ! function_exists( 'rwmb_meta' ) ) {
17
  */
18
  function rwmb_meta( $key, $args = array(), $post_id = null ) {
19
  $args = wp_parse_args( $args );
20
- $field = rwmb_get_field_data( $key, $args, $post_id );
21
 
22
  /*
23
  * If field is not found, which can caused by registering meta boxes for the backend only or conditional registration.
@@ -33,9 +33,9 @@ if ( ! function_exists( 'rwmb_meta' ) ) {
33
  }
34
  }
35
 
36
- if ( ! function_exists( 'rwmb_get_field_data' ) ) {
37
  /**
38
- * Get field data.
39
  *
40
  * @param string $key Meta key. Required.
41
  * @param array $args Array of arguments. Optional.
@@ -43,7 +43,7 @@ if ( ! function_exists( 'rwmb_get_field_data' ) ) {
43
  *
44
  * @return array
45
  */
46
- function rwmb_get_field_data( $key, $args = array(), $object_id = null ) {
47
  $args = wp_parse_args( $args, array(
48
  'object_type' => 'post',
49
  ) );
@@ -115,7 +115,7 @@ if ( ! function_exists( 'rwmb_get_value' ) ) {
115
  */
116
  function rwmb_get_value( $field_id, $args = array(), $post_id = null ) {
117
  $args = wp_parse_args( $args );
118
- $field = rwmb_get_field_data( $field_id, $args, $post_id );
119
 
120
  // Get field value.
121
  $value = $field ? RWMB_Field::call( 'get_value', $field, $args, $post_id ) : false;
@@ -148,7 +148,7 @@ if ( ! function_exists( 'rwmb_the_value' ) ) {
148
  */
149
  function rwmb_the_value( $field_id, $args = array(), $post_id = null, $echo = true ) {
150
  $args = wp_parse_args( $args );
151
- $field = rwmb_get_field_data( $field_id, $args, $post_id );
152
 
153
  if ( ! $field ) {
154
  return '';
17
  */
18
  function rwmb_meta( $key, $args = array(), $post_id = null ) {
19
  $args = wp_parse_args( $args );
20
+ $field = rwmb_get_field_settings( $key, $args, $post_id );
21
 
22
  /*
23
  * If field is not found, which can caused by registering meta boxes for the backend only or conditional registration.
33
  }
34
  }
35
 
36
+ if ( ! function_exists( 'rwmb_get_field_settings' ) ) {
37
  /**
38
+ * Get field settings.
39
  *
40
  * @param string $key Meta key. Required.
41
  * @param array $args Array of arguments. Optional.
43
  *
44
  * @return array
45
  */
46
+ function rwmb_get_field_settings( $key, $args = array(), $object_id = null ) {
47
  $args = wp_parse_args( $args, array(
48
  'object_type' => 'post',
49
  ) );
115
  */
116
  function rwmb_get_value( $field_id, $args = array(), $post_id = null ) {
117
  $args = wp_parse_args( $args );
118
+ $field = rwmb_get_field_settings( $field_id, $args, $post_id );
119
 
120
  // Get field value.
121
  $value = $field ? RWMB_Field::call( 'get_value', $field, $args, $post_id ) : false;
148
  */
149
  function rwmb_the_value( $field_id, $args = array(), $post_id = null, $echo = true ) {
150
  $args = wp_parse_args( $args );
151
+ $field = rwmb_get_field_settings( $field_id, $args, $post_id );
152
 
153
  if ( ! $field ) {
154
  return '';
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.13.1' );
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.13.2' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
inc/media-modal.php CHANGED
@@ -21,7 +21,9 @@ class RWMB_Media_Modal {
21
  * Initialize.
22
  */
23
  public function init() {
24
- add_action( 'init', array( $this, 'get_fields' ) );
 
 
25
  add_filter( 'attachment_fields_to_edit', array( $this, 'add_fields' ), 11, 2 );
26
  add_filter( 'attachment_fields_to_save', array( $this, 'save_fields' ), 11, 2 );
27
 
21
  * Initialize.
22
  */
23
  public function init() {
24
+ // Meta boxes are registered at priority 20, so we use 30 to capture them all.
25
+ add_action( 'init', array( $this, 'get_fields' ), 30 );
26
+
27
  add_filter( 'attachment_fields_to_edit', array( $this, 'add_fields' ), 11, 2 );
28
  add_filter( 'attachment_fields_to_save', array( $this, 'save_fields' ), 11, 2 );
29
 
inc/templates/video.php CHANGED
@@ -23,15 +23,15 @@
23
  </div>
24
  </div>
25
  <div class="rwmb-media-info">
26
- <h4>
27
- <a href="{{{ data.url }}}" target="_blank" title="{{{ i18nRwmbMedia.view }}}">
28
- <# if( data.title ) { #> {{{ data.title }}}
29
- <# } else { #> {{{ i18nRwmbMedia.noTitle }}}
30
- <# } #>
31
- </a>
32
- </h4>
33
- <p>{{{ data.mime }}}</p>
34
- <p>
35
  <a class="rwmb-edit-media" title="{{{ i18nRwmbMedia.edit }}}" href="{{{ data.editLink }}}" target="_blank">
36
  <span class="dashicons dashicons-edit"></span>{{{ i18nRwmbMedia.edit }}}
37
  </a>
23
  </div>
24
  </div>
25
  <div class="rwmb-media-info">
26
+ <a href="{{{ data.url }}}" class="rwmb-media-title" target="_blank">
27
+ <# if( data.title ) { #>
28
+ {{{ data.title }}}
29
+ <# } else { #>
30
+ {{{ i18nRwmbMedia.noTitle }}}
31
+ <# } #>
32
+ </a>
33
+ <p class="rwmb-media-name">{{{ data.filename }}}</p>
34
+ <p class="rwmb-media-actions">
35
  <a class="rwmb-edit-media" title="{{{ i18nRwmbMedia.edit }}}" href="{{{ data.editLink }}}" target="_blank">
36
  <span class="dashicons dashicons-edit"></span>{{{ i18nRwmbMedia.edit }}}
37
  </a>
js/clone.js CHANGED
@@ -181,13 +181,36 @@ jQuery( function ( $ ) {
181
  * @param $container .rwmb-input container
182
  */
183
  function toggleAddButton( $container ) {
184
- var $button = $container.find( '.add-clone' ),
185
  maxClone = parseInt( $container.data( 'max-clone' ) ),
186
- numClone = $container.find( '.rwmb-clone' ).length;
187
 
188
  $button.toggle( isNaN( maxClone ) || ( maxClone && numClone < maxClone ) );
189
  }
190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  $( document )
192
  // Add clones
193
  .on( 'click', '.add-clone', function ( e ) {
@@ -198,6 +221,7 @@ jQuery( function ( $ ) {
198
 
199
  toggleRemoveButtons( $container );
200
  toggleAddButton( $container );
 
201
  } )
202
  // Remove clones
203
  .on( 'click', '.remove-clone', function ( e ) {
181
  * @param $container .rwmb-input container
182
  */
183
  function toggleAddButton( $container ) {
184
+ var $button = $container.children( '.add-clone' ),
185
  maxClone = parseInt( $container.data( 'max-clone' ) ),
186
+ numClone = $container.children( '.rwmb-clone' ).length;
187
 
188
  $button.toggle( isNaN( maxClone ) || ( maxClone && numClone < maxClone ) );
189
  }
190
 
191
+ /**
192
+ * Initialize clone sorting.
193
+ */
194
+ function initSortable() {
195
+ $( '.rwmb-input' ).each( function () {
196
+ var $container = $( this );
197
+
198
+ if ( undefined !== $container.sortable( 'instance' ) ) {
199
+ return;
200
+ }
201
+
202
+ $container.sortable( {
203
+ handle: '.rwmb-clone-icon',
204
+ placeholder: ' rwmb-clone rwmb-sortable-placeholder',
205
+ items: '.rwmb-clone',
206
+ start: function ( event, ui ) {
207
+ // Make the placeholder has the same height as dragged item
208
+ ui.placeholder.height( ui.item.outerHeight() );
209
+ }
210
+ } );
211
+ } );
212
+ }
213
+
214
  $( document )
215
  // Add clones
216
  .on( 'click', '.add-clone', function ( e ) {
221
 
222
  toggleRemoveButtons( $container );
223
  toggleAddButton( $container );
224
+ initSortable();
225
  } )
226
  // Remove clones
227
  .on( 'click', '.remove-clone', function ( e ) {
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.13.1
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.13.2
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: http://paypal.me/anhtnt
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.1
7
- Stable tag: 4.13.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.
@@ -67,6 +67,7 @@ See more documentation [here](https://docs.metabox.io).
67
  #### Free Extensions
68
 
69
  - [MB Custom Post Type](https://wordpress.org/plugins/mb-custom-post-type/): Create and manage custom post types and taxonomies easily in WordPress with an easy-to-use interface.
 
70
  - [Meta Box Yoast SEO](https://wordpress.org/plugins/meta-box-yoast-seo/): Add content of custom fields to Yoast SEO Content Analysis to have better/correct SEO score.
71
  - [MB Rest API](https://metabox.io/plugins/mb-rest-api/): Pull all meta value from posts, terms into the WP REST API responses.
72
  - [MB Comment Meta](https://wordpress.org/plugins/mb-comment-meta/): Add custom fields to comments in WordPress. Support all field types and options.
3
  Donate link: http://paypal.me/anhtnt
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.2
7
+ Stable tag: 4.13.2
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.
67
  #### Free Extensions
68
 
69
  - [MB Custom Post Type](https://wordpress.org/plugins/mb-custom-post-type/): Create and manage custom post types and taxonomies easily in WordPress with an easy-to-use interface.
70
+ - [MB Relationships](https://wordpress.org/plugins/mb-relationships/): Create many-to-many relationships from posts to posts.
71
  - [Meta Box Yoast SEO](https://wordpress.org/plugins/meta-box-yoast-seo/): Add content of custom fields to Yoast SEO Content Analysis to have better/correct SEO score.
72
  - [MB Rest API](https://metabox.io/plugins/mb-rest-api/): Pull all meta value from posts, terms into the WP REST API responses.
73
  - [MB Comment Meta](https://wordpress.org/plugins/mb-comment-meta/): Add custom fields to comments in WordPress. Support all field types and options.