Meta Box - Version 4.9.6

Version Description

  • Fix: Wrong CSS selector when cloning wysiwyg field
  • Fix: Remove preview for oembed field when cloning
  • Fix: 'std' for taxonomy field now works
Download this release

Release Info

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

Code changes from version 4.9.5 to 4.9.6

css/oembed.css CHANGED
@@ -3,9 +3,9 @@
3
  vertical-align: top;
4
  display: inline-block;
5
  }
6
- .rwmb-oembed-wrapper .embed-code {
7
  margin-top: 1em;
8
  }
9
- .rwmb-oembed-wrapper .embed-code iframe {
10
  max-width: 100%;
11
  }
3
  vertical-align: top;
4
  display: inline-block;
5
  }
6
+ .rwmb-embed-media {
7
  margin-top: 1em;
8
  }
9
+ .rwmb-embed-media iframe {
10
  max-width: 100%;
11
  }
inc/fields/oembed.php CHANGED
@@ -75,9 +75,9 @@ class RWMB_OEmbed_Field extends RWMB_Text_Field
75
  public static function html( $meta, $field )
76
  {
77
  return parent::html( $meta, $field ) . sprintf(
78
- '<a href="#" class="show-embed button">%s</a>
79
  <span class="spinner"></span>
80
- <div class="embed-code">%s</div>',
81
  esc_html__( 'Preview', 'meta-box' ),
82
  $meta ? self::get_embed( $meta ) : ''
83
  );
75
  public static function html( $meta, $field )
76
  {
77
  return parent::html( $meta, $field ) . sprintf(
78
+ '<a href="#" class="rwmb-embed-show button">%s</a>
79
  <span class="spinner"></span>
80
+ <div class="rwmb-embed-media">%s</div>',
81
  esc_html__( 'Preview', 'meta-box' ),
82
  $meta ? self::get_embed( $meta ) : ''
83
  );
inc/fields/taxonomy-advanced.php CHANGED
@@ -28,8 +28,6 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field
28
  * @param mixed $old
29
  * @param int $post_id
30
  * @param array $field
31
- *
32
- * @return string
33
  */
34
  public static function save( $new, $old, $post_id, $field )
35
  {
@@ -53,6 +51,27 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field
53
  $meta = get_post_meta( $post_id, $field['id'], true );
54
  $meta = wp_parse_id_list( $meta );
55
  $meta = array_filter( $meta );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  return $meta;
57
  }
58
 
@@ -73,7 +92,7 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field
73
 
74
  $value = self::meta( $post_id, '', $field );
75
  if( empty( $value ) )
76
- return;
77
 
78
  // Allow to pass more arguments to "get_terms"
79
  $args = wp_parse_args( array(
28
  * @param mixed $old
29
  * @param int $post_id
30
  * @param array $field
 
 
31
  */
32
  public static function save( $new, $old, $post_id, $field )
33
  {
51
  $meta = get_post_meta( $post_id, $field['id'], true );
52
  $meta = wp_parse_id_list( $meta );
53
  $meta = array_filter( $meta );
54
+
55
+ // Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
56
+ $meta = ! $saved ? $field['std'] : $meta;
57
+
58
+ // Escape attributes
59
+ $meta = self::call( $field, 'esc_meta', $meta );
60
+
61
+ // Make sure meta value is an array for clonable and multiple fields
62
+ if ( $field['clone'] || $field['multiple'] )
63
+ {
64
+ if ( empty( $meta ) || ! is_array( $meta ) )
65
+ {
66
+ /**
67
+ * Note: if field is clonable, $meta must be an array with values
68
+ * so that the foreach loop in self::show() runs properly
69
+ * @see self::show()
70
+ */
71
+ $meta = $field['clone'] ? array( '' ) : array();
72
+ }
73
+ }
74
+
75
  return $meta;
76
  }
77
 
92
 
93
  $value = self::meta( $post_id, '', $field );
94
  if( empty( $value ) )
95
+ return null;
96
 
97
  // Allow to pass more arguments to "get_terms"
98
  $args = wp_parse_args( array(
inc/fields/taxonomy.php CHANGED
@@ -94,8 +94,6 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field
94
  * @param mixed $old
95
  * @param int $post_id
96
  * @param array $field
97
- *
98
- * @return string
99
  */
100
  public static function save( $new, $old, $post_id, $field )
101
  {
@@ -119,6 +117,26 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field
119
  $meta = (array) $meta;
120
  $meta = wp_list_pluck( $meta, 'term_id' );
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  return $meta;
123
  }
124
 
94
  * @param mixed $old
95
  * @param int $post_id
96
  * @param array $field
 
 
97
  */
98
  public static function save( $new, $old, $post_id, $field )
99
  {
117
  $meta = (array) $meta;
118
  $meta = wp_list_pluck( $meta, 'term_id' );
119
 
120
+ // Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
121
+ $meta = ! $saved ? $field['std'] : $meta;
122
+
123
+ // Escape attributes
124
+ $meta = self::call( $field, 'esc_meta', $meta );
125
+
126
+ // Make sure meta value is an array for clonable and multiple fields
127
+ if ( $field['clone'] || $field['multiple'] )
128
+ {
129
+ if ( empty( $meta ) || ! is_array( $meta ) )
130
+ {
131
+ /**
132
+ * Note: if field is clonable, $meta must be an array with values
133
+ * so that the foreach loop in self::show() runs properly
134
+ * @see self::show()
135
+ */
136
+ $meta = $field['clone'] ? array( '' ) : array();
137
+ }
138
+ }
139
+
140
  return $meta;
141
  }
142
 
inc/loader.php CHANGED
@@ -18,7 +18,7 @@ class RWMB_Loader
18
  protected function constants()
19
  {
20
  // Script version, used to add version for scripts and styles
21
- define( 'RWMB_VER', '4.9.5' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
18
  protected function constants()
19
  {
20
  // Script version, used to add version for scripts and styles
21
+ define( 'RWMB_VER', '4.9.6' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
js/oembed.js CHANGED
@@ -1,10 +1,12 @@
1
- jQuery( function( $ )
2
- {
3
  'use strict';
4
 
5
- $( '.rwmb-oembed-wrapper .spinner' ).hide();
 
 
 
 
6
 
7
- $( 'body' ).on( 'click', '.rwmb-oembed-wrapper .show-embed', function() {
8
  var $this = $( this ),
9
  $spinner = $this.siblings( '.spinner' ),
10
  data = {
@@ -12,13 +14,23 @@ jQuery( function( $ )
12
  url: $this.siblings( 'input' ).val()
13
  };
14
 
15
- $spinner.show();
16
- $.post( ajaxurl, data, function( r )
17
- {
18
- $spinner.hide();
19
- $this.siblings( '.embed-code' ).html( r.data );
20
  }, 'json' );
 
21
 
22
- return false;
23
- } );
 
 
 
 
 
 
 
 
 
 
24
  } );
1
+ jQuery( function ( $ ) {
 
2
  'use strict';
3
 
4
+ /**
5
+ * Show preview of oembeded media.
6
+ */
7
+ function showPreview( e ) {
8
+ e.preventDefault();
9
 
 
10
  var $this = $( this ),
11
  $spinner = $this.siblings( '.spinner' ),
12
  data = {
14
  url: $this.siblings( 'input' ).val()
15
  };
16
 
17
+ $spinner.css( 'visibility', 'visible' );
18
+ $.post( ajaxurl, data, function ( r ) {
19
+ $spinner.css( 'visibility', 'hidden' );
20
+ $this.siblings( '.rwmb-embed-media' ).html( r.data );
 
21
  }, 'json' );
22
+ }
23
 
24
+ /**
25
+ * Remove oembed preview when cloning.
26
+ */
27
+ function removePreview() {
28
+ $( this ).siblings( '.rwmb-embed-media' ).html( '' );
29
+ }
30
+
31
+ // Show oembeded media when clicking "Preview" button
32
+ $( 'body' ).on( 'click', '.rwmb-embed-show', showPreview );
33
+
34
+ // Remove oembed preview when cloning
35
+ $( '.rwmb-input' ).on( 'clone', '.rwmb-oembed', removePreview );
36
  } );
js/wysiwyg.js CHANGED
@@ -99,6 +99,6 @@ jQuery( function ( $ )
99
  .find( '.quicktags-toolbar' ).attr( 'id', 'qt_' + id + '_toolbar' ).html( '' );
100
  }
101
 
102
- $( ':input.rwmb-date' ).each( update );
103
  $( '.rwmb-input' ).on( 'clone', ':input.rwmb-wysiwyg', update );
104
  } );
99
  .find( '.quicktags-toolbar' ).attr( 'id', 'qt_' + id + '_toolbar' ).html( '' );
100
  }
101
 
102
+ $( ':input.rwmb-wysiwyg' ).each( update );
103
  $( '.rwmb-input' ).on( 'clone', ':input.rwmb-wysiwyg', update );
104
  } );
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 for any post type in WordPress.
6
- * Version: 4.9.5
7
  * Author: Rilwis
8
  * Author URI: http://www.deluxeblogtips.com
9
  * License: GPL2+
3
  * Plugin Name: Meta Box
4
  * Plugin URI: https://metabox.io
5
  * Description: Create custom meta boxes and custom fields for any post type in WordPress.
6
+ * Version: 4.9.6
7
  * Author: Rilwis
8
  * Author URI: http://www.deluxeblogtips.com
9
  * License: GPL2+
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.1
6
  Tested up to: 4.6.1
7
- Stable tag: 4.9.5
8
  License: GPLv2 or later
9
 
10
  Meta Box plugin is a powerful, professional solution to create custom meta boxes and custom fields for WordPress websites.
@@ -80,6 +80,11 @@ To getting started with the plugin API, please read [this tutorial](https://meta
80
 
81
  == Changelog ==
82
 
 
 
 
 
 
83
  = 4.9.5 =
84
  * Fix: Quick fix for wrong field wrapper class which causes color field to render incorrectly
85
 
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.1
6
  Tested up to: 4.6.1
7
+ Stable tag: 4.9.6
8
  License: GPLv2 or later
9
 
10
  Meta Box plugin is a powerful, professional solution to create custom meta boxes and custom fields for WordPress websites.
80
 
81
  == Changelog ==
82
 
83
+ = 4.9.6 =
84
+ * Fix: Wrong CSS selector when cloning wysiwyg field
85
+ * Fix: Remove preview for oembed field when cloning
86
+ * Fix: 'std' for taxonomy field now works
87
+
88
  = 4.9.5 =
89
  * Fix: Quick fix for wrong field wrapper class which causes color field to render incorrectly
90