Meta Box - Version 5.1.2

Version Description

  • 2019-08-29 =

Fixed

  • Fix adding >
Download this release

Release Info

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

Code changes from version 5.1.1 to 5.1.2

css/wysiwyg.css CHANGED
@@ -4,3 +4,8 @@
4
  .rwmb-wysiwyg-clone {
5
  padding-top: 20px;
6
  }
 
 
 
 
 
4
  .rwmb-wysiwyg-clone {
5
  padding-top: 20px;
6
  }
7
+
8
+ /* Fix style for Gutenberg */
9
+ .block-editor .wp-editor-wrap {
10
+ box-sizing: content-box;
11
+ }
inc/about/about.php CHANGED
@@ -9,6 +9,22 @@
9
  * About page class.
10
  */
11
  class RWMB_About {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * Init hooks.
14
  */
@@ -110,7 +126,7 @@ class RWMB_About {
110
  <div id="postbox-container-1" class="postbox-container">
111
  <?php
112
  include dirname( __FILE__ ) . '/sections/newsletter.php';
113
- if ( ! $this->is_premium_user() ) {
114
  include dirname( __FILE__ ) . '/sections/upgrade.php';
115
  }
116
  ?>
@@ -133,16 +149,8 @@ class RWMB_About {
133
  * Change WordPress footer text on about page.
134
  */
135
  public function change_footer_text() {
136
- $allowed_html = array(
137
- 'a' => array(
138
- 'href' => array(),
139
- 'target' => array(),
140
- ),
141
- 'strong' => array(),
142
- );
143
-
144
  // Translators: %1$s - link to review form.
145
- echo wp_kses( sprintf( __( 'Please rate <strong>Meta Box</strong> <a href="%1$s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> on <a href="%1$s" target="_blank">WordPress.org</a> to help us spread the word. Thank you from the Meta Box team!', 'meta-box' ), 'https://wordpress.org/support/view/plugin-reviews/meta-box?filter=5#new-post' ), $allowed_html );
146
  }
147
 
148
  /**
@@ -199,20 +207,4 @@ class RWMB_About {
199
  }
200
  return false;
201
  }
202
-
203
- /**
204
- * Check if current user is a premium user.
205
- *
206
- * @return bool
207
- */
208
- protected function is_premium_user() {
209
- $option = is_multisite() ? get_site_option( 'meta_box_updater' ) : get_option( 'meta_box_updater' );
210
- if ( empty( $option['api_key'] ) ) {
211
- return false;
212
- }
213
- if ( isset( $option['status'] ) && 'success' !== $option['status'] ) {
214
- return false;
215
- }
216
- return true;
217
- }
218
  }
9
  * About page class.
10
  */
11
  class RWMB_About {
12
+ /**
13
+ * The updater checker object.
14
+ *
15
+ * @var object
16
+ */
17
+ private $update_checker;
18
+
19
+ /**
20
+ * Constructor.
21
+ *
22
+ * @param object $update_checker The updater checker object.
23
+ */
24
+ public function __construct( $update_checker ) {
25
+ $this->update_checker = $update_checker;
26
+ }
27
+
28
  /**
29
  * Init hooks.
30
  */
126
  <div id="postbox-container-1" class="postbox-container">
127
  <?php
128
  include dirname( __FILE__ ) . '/sections/newsletter.php';
129
+ if ( ! $this->update_checker->has_extensions() ) {
130
  include dirname( __FILE__ ) . '/sections/upgrade.php';
131
  }
132
  ?>
149
  * Change WordPress footer text on about page.
150
  */
151
  public function change_footer_text() {
 
 
 
 
 
 
 
 
152
  // Translators: %1$s - link to review form.
153
+ echo wp_kses_post( sprintf( __( 'Please rate <strong>Meta Box</strong> <a href="%1$s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> on <a href="%1$s" target="_blank">WordPress.org</a> to help us spread the word. Thank you from the Meta Box team!', 'meta-box' ), 'https://wordpress.org/support/view/plugin-reviews/meta-box?filter=5#new-post' ) );
154
  }
155
 
156
  /**
207
  }
208
  return false;
209
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  }
inc/fields/media.php CHANGED
@@ -152,7 +152,18 @@ class RWMB_Media_Field extends RWMB_File_Field {
152
  $attributes['value'] = implode( ',', $value );
153
 
154
  // Add attachment details.
155
- $attachments = array_values( array_filter( array_map( 'wp_prepare_attachment_for_js', $value ) ) );
 
 
 
 
 
 
 
 
 
 
 
156
  $attributes['data-attachments'] = json_encode( $attachments );
157
 
158
  return $attributes;
152
  $attributes['value'] = implode( ',', $value );
153
 
154
  // Add attachment details.
155
+ $attachments = array();
156
+ foreach ( $value as $media ) {
157
+ $media = wp_prepare_attachment_for_js( $media );
158
+ // Some themes/plugins add HTML, shortcodes to "compat" attrbute which break JSON validity.
159
+ if ( isset( $media['compat'] ) ) {
160
+ unset( $media['compat'] );
161
+ }
162
+ if ( ! empty( $media ) ) {
163
+ $attachments[] = $media;
164
+ }
165
+ }
166
+ $attachments = array_values( $attachments );
167
  $attributes['data-attachments'] = json_encode( $attachments );
168
 
169
  return $attributes;
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.1.1' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
@@ -88,11 +88,6 @@ class RWMB_Loader {
88
  $core = new RWMB_Core();
89
  $core->init();
90
 
91
- if ( is_admin() ) {
92
- $about = new RWMB_About();
93
- $about->init();
94
- }
95
-
96
  // Validation module.
97
  new RWMB_Validation();
98
 
@@ -115,6 +110,11 @@ class RWMB_Loader {
115
  $update_notification = new RWMB_Update_Notification( $update_checker, $update_option );
116
  $update_notification->init();
117
 
 
 
 
 
 
118
  // Public functions.
119
  require_once RWMB_INC_DIR . 'functions.php';
120
  }
18
  */
19
  protected function constants() {
20
  // Script version, used to add version for scripts and styles.
21
+ define( 'RWMB_VER', '5.1.2' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
88
  $core = new RWMB_Core();
89
  $core->init();
90
 
 
 
 
 
 
91
  // Validation module.
92
  new RWMB_Validation();
93
 
110
  $update_notification = new RWMB_Update_Notification( $update_checker, $update_option );
111
  $update_notification->init();
112
 
113
+ if ( is_admin() ) {
114
+ $about = new RWMB_About( $update_checker );
115
+ $about->init();
116
+ }
117
+
118
  // Public functions.
119
  require_once RWMB_INC_DIR . 'functions.php';
120
  }
inc/update/checker.php CHANGED
@@ -176,7 +176,7 @@ class RWMB_Update_Checker {
176
  $args = wp_parse_args(
177
  $args,
178
  array(
179
- 'api_key' => $this->get_api_key(),
180
  )
181
  );
182
  $args = array_filter( $args );
@@ -204,13 +204,4 @@ class RWMB_Update_Checker {
204
 
205
  return isset( $plugins[ $plugin_data->plugin ] ) && version_compare( $plugins[ $plugin_data->plugin ]['Version'], $plugin_data->new_version, '<' );
206
  }
207
-
208
- /**
209
- * Get the API key.
210
- *
211
- * @return string
212
- */
213
- public function get_api_key() {
214
- return defined( 'META_BOX_KEY' ) ? META_BOX_KEY : $this->option->get( 'api_key' );
215
- }
216
  }
176
  $args = wp_parse_args(
177
  $args,
178
  array(
179
+ 'api_key' => $this->option->get_api_key(),
180
  )
181
  );
182
  $args = array_filter( $args );
204
 
205
  return isset( $plugins[ $plugin_data->plugin ] ) && version_compare( $plugins[ $plugin_data->plugin ]['Version'], $plugin_data->new_version, '<' );
206
  }
 
 
 
 
 
 
 
 
 
207
  }
inc/update/notification.php CHANGED
@@ -42,7 +42,7 @@ class RWMB_Update_Notification {
42
  $this->checker = $checker;
43
  $this->option = $option;
44
 
45
- $this->settings_page = is_multisite() ? network_admin_url( 'settings.php?page=meta-box-updater' ) : admin_url( 'admin.php?page=meta-box-updater' );
46
  }
47
 
48
  /**
@@ -66,7 +66,7 @@ class RWMB_Update_Notification {
66
  return;
67
  }
68
 
69
- $admin_notices_hook = is_multisite() ? 'network_admin_notices' : 'admin_notices';
70
  add_action( $admin_notices_hook, array( $this, 'notify' ) );
71
 
72
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
@@ -103,7 +103,7 @@ class RWMB_Update_Notification {
103
  public function notify() {
104
  // Do not show notification on License page.
105
  $screen = get_current_screen();
106
- if ( 'meta-box_page_meta-box-updater' === $screen->id ) {
107
  return;
108
  }
109
 
@@ -117,7 +117,7 @@ class RWMB_Update_Notification {
117
  // Translators: %3$s - URL to the My Account page.
118
  'expired' => __( 'Your license key for Meta Box is <b>expired</b>. Please <a href="%3$s" target="_blank">renew your license</a> to get automatic updates and premium support.', 'meta-box' ),
119
  );
120
- $status = $this->get_license_status();
121
  if ( ! isset( $messages[ $status ] ) ) {
122
  return;
123
  }
@@ -147,7 +147,7 @@ class RWMB_Update_Notification {
147
  // Translators: %3$s - URL to the My Account page.
148
  'expired' => __( 'Your license key is <b>expired</b>. Please <a href="%3$s" target="_blank">renew your license</a>.', 'meta-box' ),
149
  );
150
- $status = $this->get_license_status();
151
  if ( ! isset( $messages[ $status ] ) ) {
152
  return;
153
  }
@@ -163,7 +163,7 @@ class RWMB_Update_Notification {
163
  * @return array
164
  */
165
  public function plugin_links( $links ) {
166
- $status = $this->get_license_status();
167
  if ( 'active' === $status ) {
168
  return $links;
169
  }
@@ -174,13 +174,6 @@ class RWMB_Update_Notification {
174
  return $links;
175
  }
176
 
177
- /**
178
- * Get license status.
179
- */
180
- private function get_license_status() {
181
- return $this->checker->get_api_key() ? $this->option->get( 'status', 'active' ) : 'no_key';
182
- }
183
-
184
  /**
185
  * Check if the global notification is dismissed.
186
  * Auto re-enable the notification every 2 weeks after it's dissmissed.
42
  $this->checker = $checker;
43
  $this->option = $option;
44
 
45
+ $this->settings_page = $option->is_network_activated() ? network_admin_url( 'settings.php?page=meta-box-updater' ) : admin_url( 'admin.php?page=meta-box-updater' );
46
  }
47
 
48
  /**
66
  return;
67
  }
68
 
69
+ $admin_notices_hook = $this->option->is_network_activated() ? 'network_admin_notices' : 'admin_notices';
70
  add_action( $admin_notices_hook, array( $this, 'notify' ) );
71
 
72
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
103
  public function notify() {
104
  // Do not show notification on License page.
105
  $screen = get_current_screen();
106
+ if ( in_array( $screen->id, array( 'meta-box_page_meta-box-updater', 'settings_page_meta-box-updater-network' ), true ) ) {
107
  return;
108
  }
109
 
117
  // Translators: %3$s - URL to the My Account page.
118
  'expired' => __( 'Your license key for Meta Box is <b>expired</b>. Please <a href="%3$s" target="_blank">renew your license</a> to get automatic updates and premium support.', 'meta-box' ),
119
  );
120
+ $status = $this->option->get_license_status();
121
  if ( ! isset( $messages[ $status ] ) ) {
122
  return;
123
  }
147
  // Translators: %3$s - URL to the My Account page.
148
  'expired' => __( 'Your license key is <b>expired</b>. Please <a href="%3$s" target="_blank">renew your license</a>.', 'meta-box' ),
149
  );
150
+ $status = $this->option->get_license_status();
151
  if ( ! isset( $messages[ $status ] ) ) {
152
  return;
153
  }
163
  * @return array
164
  */
165
  public function plugin_links( $links ) {
166
+ $status = $this->option->get_license_status();
167
  if ( 'active' === $status ) {
168
  return $links;
169
  }
174
  return $links;
175
  }
176
 
 
 
 
 
 
 
 
177
  /**
178
  * Check if the global notification is dismissed.
179
  * Auto re-enable the notification every 2 weeks after it's dissmissed.
inc/update/option.php CHANGED
@@ -27,11 +27,27 @@ class RWMB_Update_Option {
27
  * @return mixed Option value or option array.
28
  */
29
  public function get( $name = null, $default = null ) {
30
- $option = is_multisite() ? get_site_option( $this->option, array() ) : get_option( $this->option, array() );
31
 
32
  return null === $name ? $option : ( isset( $option[ $name ] ) ? $option[ $name ] : $default );
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  /**
36
  * Update the option array.
37
  *
@@ -41,10 +57,22 @@ class RWMB_Update_Option {
41
  $old_option = (array) $this->get();
42
 
43
  $option = array_merge( $old_option, $option );
44
- if ( is_multisite() ) {
45
  update_site_option( $this->option, $option );
46
  } else {
47
  update_option( $this->option, $option );
48
  }
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
27
  * @return mixed Option value or option array.
28
  */
29
  public function get( $name = null, $default = null ) {
30
+ $option = $this->is_network_activated() ? get_site_option( $this->option, array() ) : get_option( $this->option, array() );
31
 
32
  return null === $name ? $option : ( isset( $option[ $name ] ) ? $option[ $name ] : $default );
33
  }
34
 
35
+ /**
36
+ * Get the API key.
37
+ *
38
+ * @return string
39
+ */
40
+ public function get_api_key() {
41
+ return defined( 'META_BOX_KEY' ) ? META_BOX_KEY : $this->get( 'api_key' );
42
+ }
43
+
44
+ /**
45
+ * Get license status.
46
+ */
47
+ public function get_license_status() {
48
+ return $this->get_api_key() ? $this->get( 'status', 'active' ) : 'no_key';
49
+ }
50
+
51
  /**
52
  * Update the option array.
53
  *
57
  $old_option = (array) $this->get();
58
 
59
  $option = array_merge( $old_option, $option );
60
+ if ( $this->is_network_activated() ) {
61
  update_site_option( $this->option, $option );
62
  } else {
63
  update_option( $this->option, $option );
64
  }
65
  }
66
+
67
+ /**
68
+ * Detect if the plugin is network activated in Multisite environment.
69
+ *
70
+ * @return bool
71
+ */
72
+ public function is_network_activated() {
73
+ if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
74
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
75
+ }
76
+ return is_multisite() && is_plugin_active_for_network( 'meta-box/meta-box.php' );
77
+ }
78
  }
inc/update/settings.php CHANGED
@@ -41,7 +41,8 @@ class RWMB_Update_Settings {
41
  */
42
  public function init() {
43
  // Whether to enable Meta Box menu. Priority 1 makes sure it runs before adding Meta Box menu.
44
- add_action( 'admin_menu', array( $this, 'enable_menu' ), 1 );
 
45
  }
46
 
47
  /**
@@ -52,11 +53,13 @@ class RWMB_Update_Settings {
52
  return;
53
  }
54
 
55
- // Enable Meta Box menu.
56
- add_filter( 'rwmb_admin_menu', '__return_true' );
 
 
57
 
58
  // Add submenu. Priority 90 makes it the last sub-menu item.
59
- $admin_menu_hook = is_multisite() ? 'network_admin_menu' : 'admin_menu';
60
  add_action( $admin_menu_hook, array( $this, 'add_settings_page' ), 90 );
61
  }
62
 
@@ -64,9 +67,9 @@ class RWMB_Update_Settings {
64
  * Add settings page.
65
  */
66
  public function add_settings_page() {
67
- $parent = is_multisite() ? 'settings.php' : 'meta-box';
68
- $capability = is_multisite() ? 'manage_network_options' : 'manage_options';
69
- $title = is_multisite() ? esc_html__( 'Meta Box License', 'meta-box' ) : esc_html__( 'License', 'meta-box' );
70
  $page_hook = add_submenu_page(
71
  $parent,
72
  $title,
@@ -115,7 +118,7 @@ class RWMB_Update_Settings {
115
  'expired' => __( 'Your license key is <b>expired</b>. Please <a href="%2$s" target="_blank">renew your license</a>.', 'meta-box' ),
116
  'active' => __( 'Your license key is <b>active</b>.', 'meta-box' ),
117
  );
118
- $status = $this->checker->get_api_key() ? $this->option->get( 'status', 'active' ) : 'no_key';
119
  if ( isset( $messages[ $status ] ) ) {
120
  echo '<p class="description">', wp_kses_post( sprintf( $messages[ $status ], 'https://metabox.io/pricing/', 'https://metabox.io/my-account/' ) ), '</p>';
121
  }
@@ -169,7 +172,7 @@ class RWMB_Update_Settings {
169
 
170
  $option['status'] = $status;
171
 
172
- $admin_notices_hook = is_multisite() ? 'network_admin_notices' : 'admin_notices';
173
  add_action( $admin_notices_hook, 'settings_errors' );
174
 
175
  $this->option->update( $option );
41
  */
42
  public function init() {
43
  // Whether to enable Meta Box menu. Priority 1 makes sure it runs before adding Meta Box menu.
44
+ $admin_menu_hook = $this->option->is_network_activated() ? 'network_admin_menu' : 'admin_menu';
45
+ add_action( $admin_menu_hook, array( $this, 'enable_menu' ), 1 );
46
  }
47
 
48
  /**
53
  return;
54
  }
55
 
56
+ // Enable Meta Box menu only in single site.
57
+ if ( ! $this->option->is_network_activated() ) {
58
+ add_filter( 'rwmb_admin_menu', '__return_true' );
59
+ }
60
 
61
  // Add submenu. Priority 90 makes it the last sub-menu item.
62
+ $admin_menu_hook = $this->option->is_network_activated() ? 'network_admin_menu' : 'admin_menu';
63
  add_action( $admin_menu_hook, array( $this, 'add_settings_page' ), 90 );
64
  }
65
 
67
  * Add settings page.
68
  */
69
  public function add_settings_page() {
70
+ $parent = $this->option->is_network_activated() ? 'settings.php' : 'meta-box';
71
+ $capability = $this->option->is_network_activated() ? 'manage_network_options' : 'manage_options';
72
+ $title = $this->option->is_network_activated() ? esc_html__( 'Meta Box License', 'meta-box' ) : esc_html__( 'License', 'meta-box' );
73
  $page_hook = add_submenu_page(
74
  $parent,
75
  $title,
118
  'expired' => __( 'Your license key is <b>expired</b>. Please <a href="%2$s" target="_blank">renew your license</a>.', 'meta-box' ),
119
  'active' => __( 'Your license key is <b>active</b>.', 'meta-box' ),
120
  );
121
+ $status = $this->option->get_license_status();
122
  if ( isset( $messages[ $status ] ) ) {
123
  echo '<p class="description">', wp_kses_post( sprintf( $messages[ $status ], 'https://metabox.io/pricing/', 'https://metabox.io/my-account/' ) ), '</p>';
124
  }
172
 
173
  $option['status'] = $status;
174
 
175
+ $admin_notices_hook = $this->option->is_network_activated() ? 'network_admin_notices' : 'admin_notices';
176
  add_action( $admin_notices_hook, 'settings_errors' );
177
 
178
  $this->option->update( $option );
js/autocomplete.js CHANGED
@@ -1,20 +1,17 @@
1
- ( function ( $, rwmb ) {
2
  'use strict';
3
 
4
  /**
5
- * Update date picker element
6
- * Used for static & dynamic added elements (when clone)
7
  */
8
- function updateAutocomplete( e ) {
9
  var $this = $( this ),
10
  $search = $this.siblings( '.rwmb-autocomplete-search' ),
11
  $result = $this.siblings( '.rwmb-autocomplete-results' ),
12
  name = $this.attr( 'name' );
13
 
14
  // If the function is called on cloning, then change the field name and clear all results
15
- // @see clone.js
16
  if ( e.hasOwnProperty( 'type' ) && 'clone' == e.type ) {
17
- // Clear all results
18
  $result.html( '' );
19
  }
20
 
@@ -25,13 +22,13 @@
25
  $result.append(
26
  '<div class="rwmb-autocomplete-result">' +
27
  '<div class="label">' + ( typeof ui.item.excerpt !== 'undefined' ? ui.item.excerpt : ui.item.label ) + '</div>' +
28
- '<div class="actions">' + RWMB_Autocomplete.delete + '</div>' +
29
  '<input type="hidden" class="rwmb-autocomplete-value" name="' + name + '" value="' + ui.item.value + '">' +
30
  '</div>'
31
  );
32
 
33
- // Reinitialize value
34
- $search.val( '' );
35
 
36
  return false;
37
  }
@@ -40,15 +37,19 @@
40
 
41
  function deleteSelection( e ) {
42
  e.preventDefault();
43
- $( this ).parent().remove();
 
 
 
 
44
  }
45
 
46
  function init( e ) {
47
- $( e.target ).find( '.rwmb-autocomplete-wrapper input[type="hidden"]' ).each( updateAutocomplete );
48
  }
49
 
50
  rwmb.$document
51
  .on( 'mb_ready', init )
52
- .on( 'clone', '.rwmb-autocomplete', updateAutocomplete )
53
  .on( 'click', '.rwmb-autocomplete-result .actions', deleteSelection );
54
- } )( jQuery, rwmb );
1
+ ( function ( $, rwmb, i18n ) {
2
  'use strict';
3
 
4
  /**
5
+ * Transform an input into an autocomplete.
 
6
  */
7
+ function transform( e ) {
8
  var $this = $( this ),
9
  $search = $this.siblings( '.rwmb-autocomplete-search' ),
10
  $result = $this.siblings( '.rwmb-autocomplete-results' ),
11
  name = $this.attr( 'name' );
12
 
13
  // If the function is called on cloning, then change the field name and clear all results
 
14
  if ( e.hasOwnProperty( 'type' ) && 'clone' == e.type ) {
 
15
  $result.html( '' );
16
  }
17
 
22
  $result.append(
23
  '<div class="rwmb-autocomplete-result">' +
24
  '<div class="label">' + ( typeof ui.item.excerpt !== 'undefined' ? ui.item.excerpt : ui.item.label ) + '</div>' +
25
+ '<div class="actions">' + i18n.delete + '</div>' +
26
  '<input type="hidden" class="rwmb-autocomplete-value" name="' + name + '" value="' + ui.item.value + '">' +
27
  '</div>'
28
  );
29
 
30
+ // Reinitialize value.
31
+ $search.val( '' ).trigger( 'change' );
32
 
33
  return false;
34
  }
37
 
38
  function deleteSelection( e ) {
39
  e.preventDefault();
40
+ var $item = $( this ).parent(),
41
+ $search = $item.parent().siblings( '.rwmb-autocomplete-search' );
42
+
43
+ $item.remove();
44
+ $search.trigger( 'change' );
45
  }
46
 
47
  function init( e ) {
48
+ $( e.target ).find( '.rwmb-autocomplete-wrapper input[type="hidden"]' ).each( transform );
49
  }
50
 
51
  rwmb.$document
52
  .on( 'mb_ready', init )
53
+ .on( 'clone', '.rwmb-autocomplete', transform )
54
  .on( 'click', '.rwmb-autocomplete-result .actions', deleteSelection );
55
+ } )( jQuery, rwmb, RWMB_Autocomplete );
js/clone.js CHANGED
@@ -135,11 +135,10 @@
135
  function clone( $container ) {
136
  var $last = $container.children( '.rwmb-clone' ).last(),
137
  $clone = $last.clone(),
138
- inputSelectors = 'input[class*="rwmb"], textarea[class*="rwmb"], select[class*="rwmb"], button[class*="rwmb"]',
139
  nextIndex = cloneIndex.nextIndex( $container );
140
 
141
  // Reset value for fields
142
- var $inputs = $clone.find( inputSelectors );
143
  $inputs.each( cloneValue.reset );
144
 
145
  // Insert Clone
@@ -156,6 +155,9 @@
156
 
157
  // After cloning fields.
158
  $inputs.trigger( 'after_clone', nextIndex );
 
 
 
159
  }
160
 
161
  /**
@@ -212,6 +214,9 @@
212
  $this.parent().trigger( 'remove' ).remove();
213
  toggleRemoveButtons( $container );
214
  toggleAddButton( $container );
 
 
 
215
  }
216
 
217
  /**
@@ -238,14 +243,16 @@
238
 
239
  // Fixed WYSIWYG field blank when inside a sortable, cloneable group.
240
  // https://stackoverflow.com/a/25667486/371240
241
- $( ui.item ).find( '.rwmb-wysiwyg' ).each( function () {
242
  tinymce.execCommand( 'mceRemoveEditor', false, this.id );
243
  } );
244
  },
245
- stop: function(e,ui) {
246
- $( ui.item ).find( '.rwmb-wysiwyg' ).each( function () {
247
  tinymce.execCommand( 'mceAddEditor', true, this.id );
248
  } );
 
 
249
  }
250
  } );
251
  }
135
  function clone( $container ) {
136
  var $last = $container.children( '.rwmb-clone' ).last(),
137
  $clone = $last.clone(),
 
138
  nextIndex = cloneIndex.nextIndex( $container );
139
 
140
  // Reset value for fields
141
+ var $inputs = $clone.find( rwmb.inputSelectors );
142
  $inputs.each( cloneValue.reset );
143
 
144
  // Insert Clone
155
 
156
  // After cloning fields.
157
  $inputs.trigger( 'after_clone', nextIndex );
158
+
159
+ // Trigger custom change event for MB Blocks to update block attributes.
160
+ $inputs.first().trigger( 'mb_change' );
161
  }
162
 
163
  /**
214
  $this.parent().trigger( 'remove' ).remove();
215
  toggleRemoveButtons( $container );
216
  toggleAddButton( $container );
217
+
218
+ // Trigger custom change event for MB Blocks to update block attributes.
219
+ $container.find( rwmb.inputSelectors ).first().trigger( 'mb_change' );
220
  }
221
 
222
  /**
243
 
244
  // Fixed WYSIWYG field blank when inside a sortable, cloneable group.
245
  // https://stackoverflow.com/a/25667486/371240
246
+ ui.item.find( '.rwmb-wysiwyg' ).each( function () {
247
  tinymce.execCommand( 'mceRemoveEditor', false, this.id );
248
  } );
249
  },
250
+ update: function( event, ui ) {
251
+ ui.item.find( '.rwmb-wysiwyg' ).each( function () {
252
  tinymce.execCommand( 'mceAddEditor', true, this.id );
253
  } );
254
+
255
+ ui.item.find( rwmb.inputSelectors ).first().trigger( 'mb_change' );
256
  }
257
  } );
258
  }
js/color.js CHANGED
@@ -10,10 +10,10 @@
10
  data = $.extend(
11
  {
12
  change: function () {
13
- $( this ).trigger( 'color:change' );
14
  },
15
  clear: function () {
16
- $( this ).trigger( 'color:clear' );
17
  }
18
  },
19
  $this.data( 'options' )
10
  data = $.extend(
11
  {
12
  change: function () {
13
+ $this.trigger( 'color:change' ).trigger( 'mb_change' );
14
  },
15
  clear: function () {
16
+ $this.trigger( 'color:clear' ).trigger( 'mb_change' );
17
  }
18
  },
19
  $this.data( 'options' )
js/date.js CHANGED
@@ -13,9 +13,15 @@
13
  $picker = $inline.length ? $inline : $this;
14
 
15
  $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
 
 
 
 
 
16
  if ( $timestamp.length ) {
17
  options.onClose = options.onSelect = function () {
18
  $timestamp.val( getTimestamp( $picker.datepicker( 'getDate' ) ) );
 
19
  };
20
  }
21
 
13
  $picker = $inline.length ? $inline : $this;
14
 
15
  $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
16
+
17
+ options.onSelect = function() {
18
+ $this.trigger( 'change' );
19
+ }
20
+
21
  if ( $timestamp.length ) {
22
  options.onClose = options.onSelect = function () {
23
  $timestamp.val( getTimestamp( $picker.datepicker( 'getDate' ) ) );
24
+ $this.trigger( 'change' );
25
  };
26
  }
27
 
js/datetime.js CHANGED
@@ -13,9 +13,15 @@
13
  $picker = $inline.length ? $inline : $this;
14
 
15
  $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
 
 
 
 
 
16
  if ( $timestamp.length ) {
17
  options.onClose = options.onSelect = function () {
18
  $timestamp.val( getTimestamp( $picker.datetimepicker( 'getDate' ) ) );
 
19
  };
20
  }
21
 
13
  $picker = $inline.length ? $inline : $this;
14
 
15
  $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
16
+
17
+ options.onSelect = function() {
18
+ $this.trigger( 'change' );
19
+ }
20
+
21
  if ( $timestamp.length ) {
22
  options.onClose = options.onSelect = function () {
23
  $timestamp.val( getTimestamp( $picker.datetimepicker( 'getDate' ) ) );
24
+ $this.trigger( 'change' );
25
  };
26
  }
27
 
js/file-input.js CHANGED
@@ -25,13 +25,13 @@
25
  // Handle selection
26
  frame.on( 'select', function () {
27
  var url = frame.state().get( 'selection' ).first().toJSON().url;
28
- $el.siblings( 'input' ).val( url ).siblings( 'a' ).removeClass( 'hidden' );
29
  } );
30
  }
31
 
32
  function clearSelection( e ) {
33
  e.preventDefault();
34
- $( this ).addClass( 'hidden' ).siblings( 'input' ).val( '' );
35
  }
36
 
37
  function hideRemoveButtonWhenCloning() {
25
  // Handle selection
26
  frame.on( 'select', function () {
27
  var url = frame.state().get( 'selection' ).first().toJSON().url;
28
+ $el.siblings( 'input' ).val( url ).trigger( 'change' ).siblings( 'a' ).removeClass( 'hidden' );
29
  } );
30
  }
31
 
32
  function clearSelection( e ) {
33
  e.preventDefault();
34
+ $( this ).addClass( 'hidden' ).siblings( 'input' ).val( '' ).trigger( 'change' );
35
  }
36
 
37
  function hideRemoveButtonWhenCloning() {
js/file.js CHANGED
@@ -66,9 +66,12 @@
66
  file.sort = function () {
67
  $( this ).sortable( {
68
  items: 'li',
69
- start: function ( e, ui ) {
70
  ui.placeholder.height( ui.helper.outerHeight() );
71
  ui.placeholder.width( ui.helper.outerWidth() );
 
 
 
72
  }
73
  } );
74
  };
66
  file.sort = function () {
67
  $( this ).sortable( {
68
  items: 'li',
69
+ start: function ( event, ui ) {
70
  ui.placeholder.height( ui.helper.outerHeight() );
71
  ui.placeholder.width( ui.helper.outerWidth() );
72
+ },
73
+ update: function( event, ui ) {
74
+ ui.item.find( rwmb.inputSelectors ).first().trigger( 'mb_change' );
75
  }
76
  } );
77
  };
js/input-list.js CHANGED
@@ -22,7 +22,7 @@
22
  checked = true;
23
  }
24
 
25
- $this.parent().siblings( '.rwmb-input-list' ).find( 'input' ).prop( 'checked', checked );
26
 
27
  checked = ! checked;
28
  $this.data( 'checked', checked );
22
  checked = true;
23
  }
24
 
25
+ $this.parent().siblings( '.rwmb-input-list' ).find( 'input' ).prop( 'checked', checked ).trigger( 'change' );
26
 
27
  checked = ! checked;
28
  $this.data( 'checked', checked );
js/map.js CHANGED
@@ -105,7 +105,7 @@
105
  $( window ).on( 'rwmb_map_refresh', that.refresh );
106
 
107
  // Refresh on meta box hide and show
108
- $( document ).on( 'postbox-toggled', that.refresh );
109
  // Refresh on sorting meta boxes
110
  $( '.meta-box-sortables' ).on( 'sortstop', that.refresh );
111
  },
@@ -174,7 +174,7 @@
174
  // Update coordinate to input field
175
  updateCoordinate: function ( latLng ) {
176
  var zoom = this.map.getZoom();
177
- this.$coordinate.val( latLng.lat() + ',' + latLng.lng() + ',' + zoom );
178
  },
179
 
180
  // Find coordinates by address
105
  $( window ).on( 'rwmb_map_refresh', that.refresh );
106
 
107
  // Refresh on meta box hide and show
108
+ rwmb.$document.on( 'postbox-toggled', that.refresh );
109
  // Refresh on sorting meta boxes
110
  $( '.meta-box-sortables' ).on( 'sortstop', that.refresh );
111
  },
174
  // Update coordinate to input field
175
  updateCoordinate: function ( latLng ) {
176
  var zoom = this.map.getZoom();
177
+ this.$coordinate.val( latLng.lat() + ',' + latLng.lng() + ',' + zoom ).trigger( 'change' );
178
  },
179
 
180
  // Find coordinates by address
js/media.js CHANGED
@@ -139,7 +139,7 @@
139
  }, 500 ) );
140
 
141
  this.controller.get( 'items' ).on( 'remove', _.debounce( function () {
142
- that.$input.val( '' );
143
  }, 500 ) );
144
  },
145
 
@@ -212,7 +212,10 @@
212
 
213
  // Sort items using helper 'clone' to prevent trigger click on the image, which means reselect.
214
  this.$el.sortable( {
215
- helper : 'clone'
 
 
 
216
  } );
217
  },
218
 
139
  }, 500 ) );
140
 
141
  this.controller.get( 'items' ).on( 'remove', _.debounce( function () {
142
+ that.$input.val( '' ).trigger( 'change' );
143
  }, 500 ) );
144
  },
145
 
212
 
213
  // Sort items using helper 'clone' to prevent trigger click on the image, which means reselect.
214
  this.$el.sortable( {
215
+ helper : 'clone',
216
+ update: function( event, ui ) {
217
+ ui.item.find( rwmb.inputSelectors ).first().trigger( 'mb_change' );
218
+ }
219
  } );
220
  },
221
 
js/osm.js CHANGED
@@ -114,7 +114,7 @@
114
  $( window ).on( 'rwmb_map_refresh', that.refresh );
115
 
116
  // Refresh on meta box hide and show
117
- $( document ).on( 'postbox-toggled', that.refresh );
118
  // Refresh on sorting meta boxes
119
  $( '.meta-box-sortables' ).on( 'sortstop', that.refresh );
120
  },
@@ -181,7 +181,7 @@
181
  // Update coordinate to input field
182
  updateCoordinate: function ( latLng ) {
183
  var zoom = this.map.getZoom();
184
- this.$coordinate.val( latLng.lat + ',' + latLng.lng + ',' + zoom );
185
  },
186
 
187
  // Find coordinates by address
114
  $( window ).on( 'rwmb_map_refresh', that.refresh );
115
 
116
  // Refresh on meta box hide and show
117
+ rwmb.$document.on( 'postbox-toggled', that.refresh );
118
  // Refresh on sorting meta boxes
119
  $( '.meta-box-sortables' ).on( 'sortstop', that.refresh );
120
  },
181
  // Update coordinate to input field
182
  updateCoordinate: function ( latLng ) {
183
  var zoom = this.map.getZoom();
184
+ this.$coordinate.val( latLng.lat + ',' + latLng.lng + ',' + zoom ).trigger( 'change' );
185
  },
186
 
187
  // Find coordinates by address
js/script.js CHANGED
@@ -10,4 +10,12 @@ window.rwmb = window.rwmb || {};
10
  rwmb.$document.on( 'ready', function() {
11
  rwmb.$document.trigger( 'mb_ready' );
12
  } );
 
 
 
 
 
 
 
 
13
  } )( jQuery, document, rwmb );
10
  rwmb.$document.on( 'ready', function() {
11
  rwmb.$document.trigger( 'mb_ready' );
12
  } );
13
+
14
+ // Selectors for all plugin inputs.
15
+ rwmb.inputSelectors = 'input[class*="rwmb"], textarea[class*="rwmb"], select[class*="rwmb"], button[class*="rwmb"]';
16
+
17
+ // Generate unique ID.
18
+ rwmb.uniqid = function uniqid() {
19
+ return Math.random().toString( 36 ).substr( 2 );
20
+ }
21
  } )( jQuery, document, rwmb );
js/slider.js CHANGED
@@ -24,7 +24,7 @@
24
  value = ui.values[ 0 ] + '|' + ui.values[ 1 ];
25
  }
26
 
27
- $input.val( value );
28
  $valueLabel.html( value );
29
  };
30
 
24
  value = ui.values[ 0 ] + '|' + ui.values[ 1 ];
25
  }
26
 
27
+ $input.val( value ).trigger( 'change' );
28
  $valueLabel.html( value );
29
  };
30
 
js/time.js CHANGED
@@ -12,6 +12,10 @@
12
 
13
  $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
14
 
 
 
 
 
15
  if ( ! $inline.length ) {
16
  $this.removeClass( 'hasDatepicker' ).timepicker( options );
17
  return;
12
 
13
  $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
14
 
15
+ options.onSelect = function() {
16
+ $this.trigger( 'change' );
17
+ }
18
+
19
  if ( ! $inline.length ) {
20
  $this.removeClass( 'hasDatepicker' ).timepicker( options );
21
  return;
js/wysiwyg.js CHANGED
@@ -7,13 +7,20 @@
7
  function transform() {
8
  var $this = $( this ),
9
  $wrapper = $this.closest( '.wp-editor-wrap' ),
10
- id = $this.attr( 'id' );
 
11
 
12
  // Ignore existing editor.
13
- if ( tinyMCEPreInit.mceInit[id] ) {
14
  return;
15
  }
16
 
 
 
 
 
 
 
17
  // Update the DOM
18
  $this.show();
19
  updateDom( $wrapper, id );
7
  function transform() {
8
  var $this = $( this ),
9
  $wrapper = $this.closest( '.wp-editor-wrap' ),
10
+ id = $this.attr( 'id' ),
11
+ isInBlock = $this.closest( '.wp-block' ).length > 0;
12
 
13
  // Ignore existing editor.
14
+ if ( ! isInBlock && tinyMCEPreInit.mceInit[id] ) {
15
  return;
16
  }
17
 
18
+ // Update the ID attribute if the editor is in a new block.
19
+ if ( isInBlock ) {
20
+ id = id + '_' + rwmb.uniqid();
21
+ $this.attr( 'id', id );
22
+ }
23
+
24
  // Update the DOM
25
  $this.show();
26
  updateDom( $wrapper, 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: 5.1.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: 5.1.2
7
  * Author: MetaBox.io
8
  * Author URI: https://metabox.io
9
  * License: GPL2+
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced,
5
  Requires at least: 4.3
6
  Requires PHP: 5.3
7
  Tested up to: 5.2.2
8
- Stable tag: 5.1.1
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 WordPress.
@@ -167,6 +167,20 @@ To getting started with the plugin, please read the [Quick Start Guide](https://
167
 
168
  == Changelog ==
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  = 5.1.1 - 2019-08-23 =
171
 
172
  **Fixed**
5
  Requires at least: 4.3
6
  Requires PHP: 5.3
7
  Tested up to: 5.2.2
8
+ Stable tag: 5.1.2
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 WordPress.
167
 
168
  == Changelog ==
169
 
170
+ = 5.1.2 - 2019-08-29 =
171
+
172
+ **Fixed**
173
+
174
+ - Fix adding >= 2 blocks containing a wysiwyg field not rendering
175
+ - Fix CSS for wyswigy field in Gutenberg
176
+ - Do not show upgrade message in the Dashboard for premium users
177
+ - Fix media field is blank
178
+ - Fix cannot access to license page in Multisite
179
+
180
+ **Changed**
181
+
182
+ - Fire `change` and/or `mb_change` events when fields change to update custom blocks in real-time (requires [MB Blocks](https://metabox.io/plugins/mb-blocks/) extension)
183
+
184
  = 5.1.1 - 2019-08-23 =
185
 
186
  **Fixed**