Meta Box - Version 5.6.4

Version Description

  • 2022-05-05 =
  • Fix when field taxonomy return WP_Error
  • Fix field image_upload not working with tab
  • Fix wysiwyg not working for attachment in the media modal
  • Improve license check
Download this release

Release Info

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

Code changes from version 5.6.3 to 5.6.4

css/media-modal.css ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* CSS fixes
2
+ --------------------------------------------------------------*/
3
+ #post-body-content table.compat-attachment-fields,
4
+ #post-body-content table.compat-attachment-fields > tbody,
5
+ #post-body-content table.compat-attachment-fields tbody > tr,
6
+ #post-body-content table.compat-attachment-fields tbody > tr > th,
7
+ #post-body-content table.compat-attachment-fields tbody > tr > td,
8
+ #post-body-content table.compat-attachment-fields tbody > tr > td input,
9
+ #post-body-content table.compat-attachment-fields tbody > tr > td textarea {
10
+ display: block;
11
+ width: 100%;
12
+ }
13
+ #post-body-content table.compat-attachment-fields tbody > tr {
14
+ margin: 1em 0;
15
+ }
16
+ #post-body-content table.compat-attachment-fields tbody > tr > th.label span {
17
+ font-weight: 600;
18
+ }
inc/fields/taxonomy.php CHANGED
@@ -215,7 +215,9 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
215
 
216
  $taxonomy = reset( $field['taxonomy'] );
217
  $term = wp_insert_term( $term, $taxonomy );
218
-
 
 
219
  return isset( $term['term_id'] ) ? $term['term_id'] : null;
220
  }
221
 
215
 
216
  $taxonomy = reset( $field['taxonomy'] );
217
  $term = wp_insert_term( $term, $taxonomy );
218
+ if ( is_wp_error( $term ) ) {
219
+ return null;
220
+ }
221
  return isset( $term['term_id'] ) ? $term['term_id'] : null;
222
  }
223
 
inc/fields/wysiwyg.php CHANGED
@@ -52,6 +52,7 @@ class RWMB_Wysiwyg_Field extends RWMB_Field {
52
 
53
  wp_editor( $meta, $attributes['id'], $options );
54
  echo '<script class="rwmb-wysiwyg-id" type="text/html" data-id="', esc_attr( $attributes['id'] ), '" data-options="', esc_attr( wp_json_encode( $options ) ), '"></script>';
 
55
 
56
  return ob_get_clean();
57
  }
52
 
53
  wp_editor( $meta, $attributes['id'], $options );
54
  echo '<script class="rwmb-wysiwyg-id" type="text/html" data-id="', esc_attr( $attributes['id'] ), '" data-options="', esc_attr( wp_json_encode( $options ) ), '"></script>';
55
+ echo '<script>if ( typeof rwmb !== "undefined" ) rwmb.$document.trigger( "mb_init_editors" );</script>';
56
 
57
  return ob_get_clean();
58
  }
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.6.3' );
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.6.4' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
inc/media-modal.php CHANGED
@@ -24,12 +24,23 @@ class RWMB_Media_Modal {
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
 
30
  add_filter( 'rwmb_show', array( $this, 'is_in_normal_mode' ), 10, 2 );
31
  }
32
 
 
 
 
 
 
 
 
 
 
33
  /**
34
  * Get list of custom fields and store in the current object for future use.
35
  */
@@ -64,7 +75,8 @@ class RWMB_Media_Modal {
64
 
65
  ob_start();
66
  $field['name'] = ''; // Don't show field label as it's already handled by WordPress.
67
- RWMB_Field::call( 'show', $field, false );
 
68
  $form_field['html'] = ob_get_clean();
69
 
70
  $form_fields[ $field['id'] ] = $form_field;
@@ -106,7 +118,18 @@ class RWMB_Media_Modal {
106
  * @return bool
107
  */
108
  public function is_in_normal_mode( $show, $meta_box ) {
109
- return $show && ! $this->is_in_modal( $meta_box );
 
 
 
 
 
 
 
 
 
 
 
110
  }
111
 
112
  /**
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_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
28
+
29
  add_filter( 'attachment_fields_to_edit', array( $this, 'add_fields' ), 11, 2 );
30
  add_filter( 'attachment_fields_to_save', array( $this, 'save_fields' ), 11, 2 );
31
 
32
  add_filter( 'rwmb_show', array( $this, 'is_in_normal_mode' ), 10, 2 );
33
  }
34
 
35
+ /**
36
+ * Enqueue common scripts and styles.
37
+ */
38
+ public function enqueue() {
39
+ if ( get_current_screen()->post_type === 'attachment' ) {
40
+ wp_enqueue_style( 'rwmb', RWMB_CSS_URL . 'media-modal.css', array(), RWMB_VER );
41
+ }
42
+ }
43
+
44
  /**
45
  * Get list of custom fields and store in the current object for future use.
46
  */
75
 
76
  ob_start();
77
  $field['name'] = ''; // Don't show field label as it's already handled by WordPress.
78
+
79
+ RWMB_Field::call( 'show', $field, true, $post->ID );
80
  $form_field['html'] = ob_get_clean();
81
 
82
  $form_fields[ $field['id'] ] = $form_field;
118
  * @return bool
119
  */
120
  public function is_in_normal_mode( $show, $meta_box ) {
121
+ if ( ! $show ) {
122
+ return $show;
123
+ }
124
+
125
+ // Show the meta box in the modal on Media screen.
126
+ global $pagenow;
127
+ if ( $pagenow === 'upload.php' ) {
128
+ return $this->is_in_modal( $meta_box );
129
+ }
130
+
131
+ // Show the meta box only if not in the modal on the post edit screen.
132
+ return ! $this->is_in_modal( $meta_box );
133
  }
134
 
135
  /**
inc/meta-box.php CHANGED
@@ -440,7 +440,7 @@ class RW_Meta_Box {
440
  $screen = get_current_screen();
441
  }
442
 
443
- return 'post' === $screen->base && in_array( $screen->post_type, $this->post_types, true );
444
  }
445
 
446
  /**
440
  $screen = get_current_screen();
441
  }
442
 
443
+ return in_array( $screen->base, array( 'post', 'upload' ), true ) && in_array( $screen->post_type, $this->post_types, true );
444
  }
445
 
446
  /**
inc/update/checker.php CHANGED
@@ -1,77 +1,34 @@
1
  <?php
2
- /**
3
- * The main update logic for updating Meta Box extensions.
4
- *
5
- * @package Meta Box
6
- */
7
-
8
- /**
9
- * The update checker class for Meta Box extensions
10
- *
11
- * @package Meta Box
12
- */
13
  class RWMB_Update_Checker {
14
- /**
15
- * Update API endpoint URL.
16
- *
17
- * @var string
18
- */
19
- private $api_url = 'https://metabox.io/index.php';
20
-
21
- /**
22
- * The update option object.
23
- *
24
- * @var object
25
- */
26
  private $option;
27
 
28
- /**
29
- * Constructor.
30
- *
31
- * @param object $option Update option object.
32
- */
33
  public function __construct( $option ) {
34
  $this->option = $option;
35
  }
36
 
37
- /**
38
- * Add hooks to check plugin updates.
39
- */
40
  public function init() {
41
- add_action( 'init', array( $this, 'enable_update' ), 1 );
42
  }
43
 
44
- /**
45
- * Enable update checker when premium extensions are installed.
46
- */
47
  public function enable_update() {
48
  if ( $this->has_extensions() ) {
49
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_updates' ) );
50
- add_filter( 'plugins_api', array( $this, 'get_info' ), 10, 3 );
51
  }
52
  }
53
 
54
- /**
55
- * Check if any premium extension is installed.
56
- *
57
- * @return bool
58
- */
59
  public function has_extensions() {
60
  $extensions = $this->get_extensions();
61
  return ! empty( $extensions );
62
  }
63
 
64
- /**
65
- * Get installed premium extensions.
66
- *
67
- * @return array Array of extension slugs.
68
- */
69
  public function get_extensions() {
70
  if ( ! function_exists( 'get_plugins' ) ) {
71
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
72
  }
73
 
74
- $extensions = array(
75
  'mb-admin-columns',
76
  'mb-blocks',
77
  'mb-core',
@@ -97,7 +54,7 @@ class RWMB_Update_Checker {
97
  'mb-favorite-posts',
98
  'mb-testimonials',
99
  'mb-user-avatar',
100
- );
101
  $plugins = get_plugins();
102
  $plugins = array_map( 'dirname', array_keys( $plugins ) );
103
 
@@ -123,10 +80,10 @@ class RWMB_Update_Checker {
123
 
124
  // Make sure to send remote request once.
125
  if ( null === $response ) {
126
- $response = $this->request( array( 'action' => 'check_updates' ) );
127
  }
128
 
129
- if ( false === $response ) {
130
  return $data;
131
  }
132
 
@@ -134,24 +91,22 @@ class RWMB_Update_Checker {
134
  $data = new stdClass;
135
  }
136
  if ( ! isset( $data->response ) ) {
137
- $data->response = array();
138
  }
139
 
140
- $plugins = array_filter( $response['data'], array( $this, 'has_update' ) );
141
  foreach ( $plugins as $plugin ) {
142
- if ( empty( $plugin->package ) ) {
143
- $plugin->upgrade_notice = __( 'UPDATE UNAVAILABLE! Please enter a valid license key to enable automatic updates.', 'meta-box' );
144
  }
145
 
146
- $data->response[ $plugin->plugin ] = $plugin;
147
  }
148
 
149
- $this->option->update(
150
- array(
151
- 'status' => $response['status'],
152
- 'plugins' => array_keys( $plugins ),
153
- )
154
- );
155
 
156
  return $data;
157
  }
@@ -166,55 +121,58 @@ class RWMB_Update_Checker {
166
  * @return mixed
167
  */
168
  public function get_info( $data, $action, $args ) {
169
- $plugins = $this->option->get( 'plugins', array() );
170
  if ( 'plugin_information' !== $action || ! isset( $args->slug ) || ! in_array( $args->slug, $plugins, true ) ) {
171
  return $data;
172
  }
173
 
174
- $response = $this->request(
175
- array(
176
- 'action' => 'get_info',
177
- 'product' => $args->slug,
178
- )
179
- );
180
-
181
- return false === $response ? $data : $response['data'];
182
  }
183
 
184
- /**
185
- * Send request to remote host
186
- *
187
- * @param array|string $args Query arguments.
188
- *
189
- * @return mixed
190
- */
191
- public function request( $args = '' ) {
192
- $args = wp_parse_args(
193
- $args,
194
- array(
195
- 'api_key' => $this->option->get_api_key(),
196
- 'url' => home_url(),
197
- )
198
- );
199
  $args = array_filter( $args );
200
 
201
- $request = wp_remote_get( add_query_arg( $args, $this->api_url ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  $response = wp_remote_retrieve_body( $request );
203
- $response = $response ? @unserialize( $response ) : false;
 
 
 
 
 
 
 
204
 
205
  return $response;
206
  }
207
 
208
- /**
209
- * Check if a plugin has an update to a new version.
210
- *
211
- * @param object $plugin_data The plugin update data.
212
- *
213
- * @return bool
214
- */
215
- private function has_update( $plugin_data ) {
216
  $plugins = get_plugins();
217
 
218
- return isset( $plugins[ $plugin_data->plugin ] ) && version_compare( $plugins[ $plugin_data->plugin ]['Version'], $plugin_data->new_version, '<' );
 
 
 
 
 
219
  }
220
  }
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
2
  class RWMB_Update_Checker {
3
+ private $api_url = 'https://metabox.io/wp-json/buse2/updater/';
 
 
 
 
 
 
 
 
 
 
 
4
  private $option;
5
 
 
 
 
 
 
6
  public function __construct( $option ) {
7
  $this->option = $option;
8
  }
9
 
 
 
 
10
  public function init() {
11
+ add_action( 'init', [ $this, 'enable_update' ], 1 );
12
  }
13
 
 
 
 
14
  public function enable_update() {
15
  if ( $this->has_extensions() ) {
16
+ add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_updates' ] );
17
+ add_filter( 'plugins_api', [ $this, 'get_info' ], 10, 3 );
18
  }
19
  }
20
 
 
 
 
 
 
21
  public function has_extensions() {
22
  $extensions = $this->get_extensions();
23
  return ! empty( $extensions );
24
  }
25
 
 
 
 
 
 
26
  public function get_extensions() {
27
  if ( ! function_exists( 'get_plugins' ) ) {
28
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
29
  }
30
 
31
+ $extensions = [
32
  'mb-admin-columns',
33
  'mb-blocks',
34
  'mb-core',
54
  'mb-favorite-posts',
55
  'mb-testimonials',
56
  'mb-user-avatar',
57
+ ];
58
  $plugins = get_plugins();
59
  $plugins = array_map( 'dirname', array_keys( $plugins ) );
60
 
80
 
81
  // Make sure to send remote request once.
82
  if ( null === $response ) {
83
+ $response = $this->request( 'plugins' );
84
  }
85
 
86
+ if ( empty( $response ) ) {
87
  return $data;
88
  }
89
 
91
  $data = new stdClass;
92
  }
93
  if ( ! isset( $data->response ) ) {
94
+ $data->response = [];
95
  }
96
 
97
+ $plugins = array_filter( $response['data'], [ $this, 'has_update' ] );
98
  foreach ( $plugins as $plugin ) {
99
+ if ( empty( $plugin['package'] ) ) {
100
+ $plugin['upgrade_notice'] = __( 'UPDATE UNAVAILABLE! Please enter a valid license key to enable automatic updates.', 'meta-box' );
101
  }
102
 
103
+ $data->response[ $plugin['plugin'] ] = (object) $plugin;
104
  }
105
 
106
+ $this->option->update( [
107
+ 'status' => $response['status'],
108
+ 'plugins' => array_keys( $plugins ),
109
+ ] );
 
 
110
 
111
  return $data;
112
  }
121
  * @return mixed
122
  */
123
  public function get_info( $data, $action, $args ) {
124
+ $plugins = $this->option->get( 'plugins', [] );
125
  if ( 'plugin_information' !== $action || ! isset( $args->slug ) || ! in_array( $args->slug, $plugins, true ) ) {
126
  return $data;
127
  }
128
 
129
+ $response = $this->request( 'plugin', [ 'product' => $args->slug ] );
130
+ return $response ? (object) $response['data'] : $data;
 
 
 
 
 
 
131
  }
132
 
133
+ public function request( $endpoint, $args = [] ) {
134
+ $args = wp_parse_args( $args, [
135
+ 'key' => $this->option->get_api_key(),
136
+ 'url' => home_url(),
137
+ ] );
 
 
 
 
 
 
 
 
 
 
138
  $args = array_filter( $args );
139
 
140
+ // Get from cache first.
141
+ $data = compact( 'endpoint', 'args' );
142
+ $cache_key = 'meta_box_' . md5( serialize( $data ) );
143
+ if ( $this->option->is_network_activated() ) {
144
+ $cache = get_site_transient( $cache_key );
145
+ } else {
146
+ $cache = get_transient( $cache_key );
147
+ }
148
+ if ( $cache ) {
149
+ return $cache;
150
+ }
151
+
152
+ $url = $this->api_url . $endpoint;
153
+ $request = wp_remote_get( add_query_arg( $args, $url ) );
154
  $response = wp_remote_retrieve_body( $request );
155
+ $response = json_decode( $response, true );
156
+
157
+ // Cache requests.
158
+ if ( $this->option->is_network_activated() ) {
159
+ set_site_transient( $cache_key, $response, DAY_IN_SECONDS );
160
+ } else {
161
+ set_transient( $cache_key, $response, DAY_IN_SECONDS );
162
+ }
163
 
164
  return $response;
165
  }
166
 
167
+ private function has_update( $remote_plugin_data ) {
168
+ $slug = $remote_plugin_data['plugin'];
 
 
 
 
 
 
169
  $plugins = get_plugins();
170
 
171
+ if ( empty( $plugins[ $slug ] ) ) {
172
+ return false;
173
+ }
174
+
175
+ $plugin = $plugins[ $slug ];
176
+ return version_compare( $plugin['Version'], $remote_plugin_data['new_version'], '<' );
177
  }
178
  }
inc/update/settings.php CHANGED
@@ -1,53 +1,19 @@
1
  <?php
2
- /**
3
- * This class handles plugin settings, including adding settings page, show fields, save settings
4
- *
5
- * @package Meta Box
6
- */
7
-
8
- /**
9
- * Meta Box Update Settings class
10
- *
11
- * @package Meta Box
12
- */
13
  class RWMB_Update_Settings {
14
- /**
15
- * The update option object.
16
- *
17
- * @var object
18
- */
19
  private $option;
20
-
21
- /**
22
- * The update checker object
23
- *
24
- * @var object
25
- */
26
  private $checker;
27
 
28
- /**
29
- * Constructor.
30
- *
31
- * @param object $checker Update checker object.
32
- * @param object $option Update option object.
33
- */
34
  public function __construct( $checker, $option ) {
35
  $this->checker = $checker;
36
  $this->option = $option;
37
  }
38
 
39
- /**
40
- * Add hooks to create the settings page.
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
- /**
49
- * Enable Meta Box menu when a premium extension is installed.
50
- */
51
  public function enable_menu() {
52
  if ( ! $this->checker->has_extensions() ) {
53
  return;
@@ -60,12 +26,9 @@ class RWMB_Update_Settings {
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
 
66
- /**
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';
@@ -76,14 +39,11 @@ class RWMB_Update_Settings {
76
  $title,
77
  $capability,
78
  'meta-box-updater',
79
- array( $this, 'render' )
80
  );
81
- add_action( "load-{$page_hook}", array( $this, 'save' ) );
82
  }
83
 
84
- /**
85
- * Render the content of settings page.
86
- */
87
  public function render() {
88
  ?>
89
  <div class="wrap">
@@ -108,12 +68,12 @@ class RWMB_Update_Settings {
108
  <th scope="row"><?php esc_html_e( 'License Key', 'meta-box' ); ?></th>
109
  <td>
110
  <?php
111
- $messages = array(
112
  'invalid' => __( 'Your license key is <b style="color: #d63638">invalid</b>.', 'meta-box' ),
113
  'error' => __( 'Your license key is <b style="color: #d63638">invalid</b>.', 'meta-box' ),
114
  'expired' => __( 'Your license key is <b style="color: #d63638">expired</b>.', 'meta-box' ),
115
  'active' => __( 'Your license key is <b style="color: #00a32a">active</b>.', 'meta-box' ),
116
- );
117
  $status = $this->option->get_license_status();
118
  $api_key = $this->option->get( 'api_key' );
119
  ?>
@@ -131,9 +91,6 @@ class RWMB_Update_Settings {
131
  <?php
132
  }
133
 
134
- /**
135
- * Save update settings.
136
- */
137
  public function save() {
138
  $request = rwmb_request();
139
  if ( ! $request->post( 'submit' ) ) {
@@ -141,16 +98,23 @@ class RWMB_Update_Settings {
141
  }
142
  check_admin_referer( 'meta-box' );
143
 
144
- $option = $request->post( 'meta_box_updater', array() );
145
- $option = (array) $option;
146
- $option['status'] = 'active';
147
 
148
- $args = $option;
149
- $args['action'] = 'check_license';
150
- $response = $this->checker->request( $args );
151
- $status = isset( $response['status'] ) ? $response['status'] : 'invalid';
 
 
 
 
 
 
 
 
 
152
 
153
- if ( false === $response ) {
154
  add_settings_error( '', 'mb-error', __( 'Something wrong with the connection to metabox.io. Please try again later.', 'meta-box' ) );
155
  } elseif ( 'active' === $status ) {
156
  add_settings_error( '', 'mb-success', __( 'Your license is activated.', 'meta-box' ), 'updated' );
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
2
  class RWMB_Update_Settings {
 
 
 
 
 
3
  private $option;
 
 
 
 
 
 
4
  private $checker;
5
 
 
 
 
 
 
 
6
  public function __construct( $checker, $option ) {
7
  $this->checker = $checker;
8
  $this->option = $option;
9
  }
10
 
 
 
 
11
  public function init() {
12
  // Whether to enable Meta Box menu. Priority 1 makes sure it runs before adding Meta Box menu.
13
  $admin_menu_hook = $this->option->is_network_activated() ? 'network_admin_menu' : 'admin_menu';
14
+ add_action( $admin_menu_hook, [ $this, 'enable_menu' ], 1 );
15
  }
16
 
 
 
 
17
  public function enable_menu() {
18
  if ( ! $this->checker->has_extensions() ) {
19
  return;
26
 
27
  // Add submenu. Priority 90 makes it the last sub-menu item.
28
  $admin_menu_hook = $this->option->is_network_activated() ? 'network_admin_menu' : 'admin_menu';
29
+ add_action( $admin_menu_hook, [ $this, 'add_settings_page' ], 90 );
30
  }
31
 
 
 
 
32
  public function add_settings_page() {
33
  $parent = $this->option->is_network_activated() ? 'settings.php' : 'meta-box';
34
  $capability = $this->option->is_network_activated() ? 'manage_network_options' : 'manage_options';
39
  $title,
40
  $capability,
41
  'meta-box-updater',
42
+ [ $this, 'render' ]
43
  );
44
+ add_action( "load-{$page_hook}", [ $this, 'save' ] );
45
  }
46
 
 
 
 
47
  public function render() {
48
  ?>
49
  <div class="wrap">
68
  <th scope="row"><?php esc_html_e( 'License Key', 'meta-box' ); ?></th>
69
  <td>
70
  <?php
71
+ $messages = [
72
  'invalid' => __( 'Your license key is <b style="color: #d63638">invalid</b>.', 'meta-box' ),
73
  'error' => __( 'Your license key is <b style="color: #d63638">invalid</b>.', 'meta-box' ),
74
  'expired' => __( 'Your license key is <b style="color: #d63638">expired</b>.', 'meta-box' ),
75
  'active' => __( 'Your license key is <b style="color: #00a32a">active</b>.', 'meta-box' ),
76
+ ];
77
  $status = $this->option->get_license_status();
78
  $api_key = $this->option->get( 'api_key' );
79
  ?>
91
  <?php
92
  }
93
 
 
 
 
94
  public function save() {
95
  $request = rwmb_request();
96
  if ( ! $request->post( 'submit' ) ) {
98
  }
99
  check_admin_referer( 'meta-box' );
100
 
101
+ $option = (array) $request->post( 'meta_box_updater', [] );
 
 
102
 
103
+ // Do nothing if license key remains the same.
104
+ $prev_key = $this->option->get_api_key();
105
+ if ( isset( $option['api_key'] ) && $option['api_key'] === $prev_key ) {
106
+ return;
107
+ }
108
+
109
+ $status = 'invalid';
110
+ $response = null;
111
+ if ( isset( $option['api_key'] ) ) {
112
+ $args = [ 'key' => $option['api_key'] ];
113
+ $response = $this->checker->request( 'status', $args );
114
+ $status = isset( $response['status'] ) ? $response['status'] : 'invalid';
115
+ }
116
 
117
+ if ( empty( $response ) ) {
118
  add_settings_error( '', 'mb-error', __( 'Something wrong with the connection to metabox.io. Please try again later.', 'meta-box' ) );
119
  } elseif ( 'active' === $status ) {
120
  add_settings_error( '', 'mb-success', __( 'Your license is activated.', 'meta-box' ), 'updated' );
js/image-upload.js CHANGED
@@ -26,7 +26,7 @@
26
  $this.after( view.el );
27
 
28
  // Init uploader after view is inserted to make wp.Uploader works.
29
- view.addButton.initUploader();
30
 
31
  $this.data( 'view', view );
32
  }
26
  $this.after( view.el );
27
 
28
  // Init uploader after view is inserted to make wp.Uploader works.
29
+ view.addButton.initUploader( $this );
30
 
31
  $this.data( 'view', view );
32
  }
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.6.3
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.6.4
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 post types, custom taxonomies, cpt, meta b
5
  Requires at least: 4.3
6
  Requires PHP: 5.6
7
  Tested up to: 5.9.3
8
- Stable tag: 5.6.3
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.6.3 - 2022-04-18 =
172
  - Improve Google Maps search, allowing to search by place names
173
  - Fix incorrect the label ID for subfield in groups
5
  Requires at least: 4.3
6
  Requires PHP: 5.6
7
  Tested up to: 5.9.3
8
+ Stable tag: 5.6.4
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.6.4 - 2022-05-05 =
172
+ - Fix when field taxonomy return WP_Error
173
+ - Fix field image_upload not working with tab
174
+ - Fix wysiwyg not working for attachment in the media modal
175
+ - Improve license check
176
+
177
  = 5.6.3 - 2022-04-18 =
178
  - Improve Google Maps search, allowing to search by place names
179
  - Fix incorrect the label ID for subfield in groups