diff --git a/composer.json b/composer.json index 0519082..59ef22b 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ "wpmetabox/mb-relationships": "dev-master", "wpmetabox/mb-rest-api": "dev-master", "wpmetabox/mb-yoast-seo": "dev-master", - "wpmetabox/meta-box": "^5.10", + "wpmetabox/meta-box": "dev-master", "wpmetabox/meta-box-beaver-themer-integrator": "dev-master", "wpmetabox/meta-box-facetwp-integrator": "dev-master", "wpmetabox/text-limiter": "dev-master" diff --git a/composer.lock b/composer.lock index 37a92fc..027fc6b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "50712d73fbed87cd52ee2d447a66b018", + "content-hash": "104d4ad9a76a0a6225f0b125cddcf5bf", "packages": [ { "name": "composer/installers", @@ -777,11 +777,11 @@ }, { "name": "wpmetabox/meta-box", - "version": "5.10.5", + "version": "dev-master", "source": { "type": "git", "url": "git@github.com:wpmetabox/meta-box.git", - "reference": "3fa649ba0e8624c71f066a8437a4a47af5998710" + "reference": "9e243e8d8cbfbd3ef69218a441619394374a1708" }, "require": { "meta-box/support": "dev-master" @@ -789,6 +789,7 @@ "require-dev": { "phpunit/phpunit": "^11.3" }, + "default-branch": true, "type": "wordpress-plugin", "extra": { "dev-files": { @@ -866,7 +867,7 @@ "wordpress", "wordpress-plugin" ], - "time": "2024-12-16T06:50:30+00:00" + "time": "2025-01-09T08:25:10+00:00" }, { "name": "wpmetabox/meta-box-beaver-themer-integrator", @@ -1017,6 +1018,7 @@ "wpmetabox/mb-relationships": 20, "wpmetabox/mb-rest-api": 20, "wpmetabox/mb-yoast-seo": 20, + "wpmetabox/meta-box": 20, "wpmetabox/meta-box-beaver-themer-integrator": 20, "wpmetabox/meta-box-facetwp-integrator": 20, "wpmetabox/text-limiter": 20 diff --git a/modules/meta-box/css/image-select.css b/modules/meta-box/css/image-select.css index 1e9ecbe..d15344f 100644 --- a/modules/meta-box/css/image-select.css +++ b/modules/meta-box/css/image-select.css @@ -1,21 +1,31 @@ .rwmb-image-select { - display: inline-block; width: 80px; height: 80px; float: left; - margin: 0 10px 10px 0; + margin: 0 8px 8px 0; border: 3px solid #d8d8d8; - border-radius: 3px; + border-radius: 4px; padding: 1px; + cursor: pointer; + + --color: #2271b1; } + +.block-editor-page .rwmb-image-select { + --color: var(--wp-admin-theme-color, #2271b1); +} + .rwmb-image-select img { width: 100%; height: 100%; + object-fit: cover; } + .rwmb-image-select:hover, -.rwmb-image-select.rwmb-active { - border-color: #0074a2; +.rwmb-image-select:has(:checked) { + border-color: var(--color); } + .rwmb-image_select.rwmb-image_select { display: none; } diff --git a/modules/meta-box/css/key-value.css b/modules/meta-box/css/key-value.css index 748648c..69f0292 100644 --- a/modules/meta-box/css/key-value.css +++ b/modules/meta-box/css/key-value.css @@ -1,6 +1,7 @@ .rwmb-key_value-clone { display: flex; align-items: center; + gap: 8px; } .rwmb-key_value-clone input { flex: 1; diff --git a/modules/meta-box/inc/field.php b/modules/meta-box/inc/field.php index cc12baf..393d56d 100644 --- a/modules/meta-box/inc/field.php +++ b/modules/meta-box/inc/field.php @@ -38,7 +38,7 @@ public static function show( array $field, bool $saved, $post_id = 0 ) { } $end = static::end_html( $field ); - $end = self::filter( 'end_html', $end, $field, $meta ); + $end = self::filter( 'end_html', $end, $field, $meta ); $html = self::filter( 'wrapper_html', $begin . $field_html . $end, $field, $meta ); // Display label and input in DIV and allow user-defined classes to be appended. @@ -75,20 +75,15 @@ public static function html( $meta, $field ) { protected static function begin_html( array $field ): string { $id = $field['attributes']['id'] ?? $field['id']; $required = $field['required'] || ! empty( $field['attributes']['required'] ); + $required = $required ? '*' : ''; $label = $field['name'] ? sprintf( - '', + // Translators: %1$s - field ID, %2$s - field label, %3$s - required asterisk, %4$s - label description. + '
%4$s
', esc_attr( $id ), $field['name'], - $required ? '*' : '' - ) : ''; - - $label .= static::label_description( $field ); - - $label = $label ? sprintf( - '
%s
', - esc_attr( $id ), - $label + $required, + static::label_description( $field ) ) : ''; $data_min_clone = is_numeric( $field['min_clone'] ) && $field['min_clone'] > 1 ? ' data-min-clone=' . $field['min_clone'] : ''; diff --git a/modules/meta-box/inc/fields/fieldset-text.php b/modules/meta-box/inc/fields/fieldset-text.php index 907c801..1aaa147 100644 --- a/modules/meta-box/inc/fields/fieldset-text.php +++ b/modules/meta-box/inc/fields/fieldset-text.php @@ -41,10 +41,6 @@ protected static function input_description( array $field ) : string { return ''; } - protected static function label_description( array $field ) : string { - return ''; - } - /** * Normalize parameters for field. * diff --git a/modules/meta-box/inc/fields/image-select.php b/modules/meta-box/inc/fields/image-select.php index 23c2f4a..38f9d6b 100644 --- a/modules/meta-box/inc/fields/image-select.php +++ b/modules/meta-box/inc/fields/image-select.php @@ -8,7 +8,6 @@ class RWMB_Image_Select_Field extends RWMB_Field { public static function admin_enqueue_scripts() { wp_enqueue_style( 'rwmb-image-select', RWMB_CSS_URL . 'image-select.css', [], RWMB_VER ); wp_style_add_data( 'rwmb-image-select', 'path', RWMB_CSS_DIR . 'image-select.css' ); - wp_enqueue_script( 'rwmb-image-select', RWMB_JS_URL . 'image-select.js', [ 'jquery' ], RWMB_VER, true ); } /** diff --git a/modules/meta-box/inc/fields/key-value.php b/modules/meta-box/inc/fields/key-value.php index 6a1cd61..542844a 100644 --- a/modules/meta-box/inc/fields/key-value.php +++ b/modules/meta-box/inc/fields/key-value.php @@ -35,22 +35,7 @@ public static function html( $meta, $field ) { } protected static function begin_html( array $field ) : string { - $desc = $field['desc'] ? "

{$field['desc']}

" : ''; - - if ( empty( $field['name'] ) ) { - return '
' . $desc; - } - - return sprintf( - '
- -
-
- %s', - $field['id'], - $field['name'], - $desc - ); + return parent::begin_html( $field ) . parent::input_description( $field ); } protected static function input_description( array $field ) : string { diff --git a/modules/meta-box/js/date.js b/modules/meta-box/js/date.js index 3a8451f..ee99109 100644 --- a/modules/meta-box/js/date.js +++ b/modules/meta-box/js/date.js @@ -5,23 +5,28 @@ * Transform an input into a date picker. */ function transform() { - var $this = $( this ), - options = $this.data( 'options' ), - $inline = $this.siblings( '.rwmb-datetime-inline' ), - $timestamp = $this.siblings( '.rwmb-datetime-timestamp' ), + let $this = $( this ), + options = $this.data( 'options' ); + + let $inline = $this.siblings( '.rwmb-datetime-inline' ); + if ( !$inline.length ) { + $inline = $this.closest( '.rwmb-input-group' ).siblings( '.rwmb-datetime-inline' ); + } + + let $timestamp = $this.siblings( '.rwmb-datetime-timestamp' ), current = $this.val(), $picker = $inline.length ? $inline : $this; $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text - options.onSelect = function() { + options.onSelect = function () { $this.trigger( 'change' ); - } - options.beforeShow = function( i ) { + }; + options.beforeShow = function ( i ) { if ( $( i ).prop( 'readonly' ) ) { return false; } - } + }; if ( $timestamp.length ) { options.onClose = options.onSelect = function () { @@ -36,7 +41,7 @@ } ); } - if ( ! $inline.length ) { + if ( !$inline.length ) { $this.removeClass( 'hasDatepicker' ).datepicker( options ); return; } @@ -44,7 +49,7 @@ options.altField = '#' + $this.attr( 'id' ); $this.on( 'keydown', _.debounce( function () { // if val is empty, return to allow empty datepicker input. - if ( ! $this.val() ) { + if ( !$this.val() ) { return; } $picker diff --git a/modules/meta-box/js/datetime.js b/modules/meta-box/js/datetime.js index e8d1c72..5cf26f8 100644 --- a/modules/meta-box/js/datetime.js +++ b/modules/meta-box/js/datetime.js @@ -5,23 +5,28 @@ * Transform an input into a datetime picker. */ function transform() { - var $this = $( this ), - options = $this.data( 'options' ), - $inline = $this.siblings( '.rwmb-datetime-inline' ), - $timestamp = $this.siblings( '.rwmb-datetime-timestamp' ), + let $this = $( this ), + options = $this.data( 'options' ); + + let $inline = $this.siblings( '.rwmb-datetime-inline' ); + if ( !$inline.length ) { + $inline = $this.closest( '.rwmb-input-group' ).siblings( '.rwmb-datetime-inline' ); + } + + let $timestamp = $this.siblings( '.rwmb-datetime-timestamp' ), current = $this.val(), $picker = $inline.length ? $inline : $this; $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text - options.onSelect = function() { + options.onSelect = function () { $this.trigger( 'change' ); - } - options.beforeShow = function( i ) { + }; + options.beforeShow = function ( i ) { if ( $( i ).prop( 'readonly' ) ) { return false; } - } + }; if ( $timestamp.length ) { options.onClose = options.onSelect = function () { @@ -36,7 +41,7 @@ } ); } - if ( ! $inline.length ) { + if ( !$inline.length ) { $this.removeClass( 'hasDatepicker' ).datetimepicker( options ); return; } @@ -44,7 +49,7 @@ options.altField = '#' + $this.attr( 'id' ); $this.on( 'keydown', _.debounce( function () { // if val is empty, return to allow empty datepicker input. - if ( ! $this.val() ) { + if ( !$this.val() ) { return; } $picker @@ -78,9 +83,9 @@ // Set language if available function setTimeI18n() { if ( $.timepicker.regional.hasOwnProperty( i18n.locale ) ) { - $.timepicker.setDefaults( $.timepicker.regional[i18n.locale] ); + $.timepicker.setDefaults( $.timepicker.regional[ i18n.locale ] ); } else if ( $.timepicker.regional.hasOwnProperty( i18n.localeShort ) ) { - $.timepicker.setDefaults( $.timepicker.regional[i18n.localeShort] ); + $.timepicker.setDefaults( $.timepicker.regional[ i18n.localeShort ] ); } } diff --git a/modules/meta-box/js/image-select.js b/modules/meta-box/js/image-select.js deleted file mode 100644 index 6365f8e..0000000 --- a/modules/meta-box/js/image-select.js +++ /dev/null @@ -1,27 +0,0 @@ -( function ( $, rwmb ) { - 'use strict'; - - function setActiveClass() { - var $this = $( this ), - type = $this.attr( 'type' ), - selected = $this.is( ':checked' ), - $parent = $this.parent(), - $others = $parent.siblings(); - if ( selected ) { - $parent.addClass( 'rwmb-active' ); - if ( type === 'radio' ) { - $others.removeClass( 'rwmb-active' ); - } - } else { - $parent.removeClass( 'rwmb-active' ); - } - } - - function init( e ) { - $( e.target ).find( '.rwmb-image-select input' ).trigger( 'change' ); - } - - rwmb.$document - .on( 'mb_ready', init ) - .on( 'change', '.rwmb-image-select input', setActiveClass ); -} )( jQuery, rwmb ); diff --git a/modules/meta-box/js/time.js b/modules/meta-box/js/time.js index 8b0335b..d4ba9e0 100644 --- a/modules/meta-box/js/time.js +++ b/modules/meta-box/js/time.js @@ -5,9 +5,8 @@ * Transform an input into a time picker. */ function transform() { - var $this = $( this ), + let $this = $( this ), options = $this.data( 'options' ), - $inline = $this.siblings( '.rwmb-datetime-inline' ), current = $this.val(); current = formatTime( current ); @@ -22,6 +21,10 @@ } }; + let $inline = $this.siblings( '.rwmb-datetime-inline' ); + if ( !$inline.length ) { + $inline = $this.closest( '.rwmb-input-group' ).siblings( '.rwmb-datetime-inline' ); + } if ( !$inline.length ) { $this.removeClass( 'hasDatepicker' ).timepicker( options ).timepicker( 'setTime', current ); return; diff --git a/modules/meta-box/src/Updater/Checker.php b/modules/meta-box/src/Updater/Checker.php index 8cbb62e..55720e9 100644 --- a/modules/meta-box/src/Updater/Checker.php +++ b/modules/meta-box/src/Updater/Checker.php @@ -15,19 +15,19 @@ public function init() { add_action( 'init', [ $this, 'enable_update' ], 1 ); } - public function enable_update() { - if ( $this->has_extensions() ) { + public function enable_update(): void { + if ( $this->has_extensions() || $this->has_free_extensions() ) { add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_updates' ] ); add_filter( 'plugins_api', [ $this, 'get_info' ], 10, 3 ); } } - public function has_extensions() { + public function has_extensions(): bool { $extensions = $this->get_extensions(); return ! empty( $extensions ); } - public function get_extensions() { + public function get_extensions(): array { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } @@ -65,6 +65,25 @@ public function get_extensions() { return array_intersect( $extensions, $plugins ); } + private function has_free_extensions(): bool { + $extensions = $this->get_free_extensions(); + return ! empty( $extensions ); + } + + private function get_free_extensions(): array { + if ( ! function_exists( 'get_plugins' ) ) { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + } + + $extensions = [ + 'meta-box-lite', + ]; + $plugins = get_plugins(); + $plugins = array_map( 'dirname', array_keys( $plugins ) ); + + return array_intersect( $extensions, $plugins ); + } + /** * Check plugin for updates * diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e238f19..49d4e0d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -819,12 +819,12 @@ }, { "name": "wpmetabox/meta-box", - "version": "5.10.5", - "version_normalized": "5.10.5.0", + "version": "dev-master", + "version_normalized": "dev-master", "source": { "type": "git", "url": "git@github.com:wpmetabox/meta-box.git", - "reference": "3fa649ba0e8624c71f066a8437a4a47af5998710" + "reference": "9e243e8d8cbfbd3ef69218a441619394374a1708" }, "require": { "meta-box/support": "dev-master" @@ -832,7 +832,8 @@ "require-dev": { "phpunit/phpunit": "^11.3" }, - "time": "2024-12-16T06:50:30+00:00", + "time": "2025-01-09T08:25:10+00:00", + "default-branch": true, "type": "wordpress-plugin", "extra": { "dev-files": { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 08e598e..29b4866 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '5f2dc7eef0622809b122e35020a5791b6ca5b483', + 'reference' => 'aa429e6fa625dc45861768197aa221e03522f43b', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ '__root__' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '5f2dc7eef0622809b122e35020a5791b6ca5b483', + 'reference' => 'aa429e6fa625dc45861768197aa221e03522f43b', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -204,12 +204,14 @@ 'dev_requirement' => false, ), 'wpmetabox/meta-box' => array( - 'pretty_version' => '5.10.5', - 'version' => '5.10.5.0', - 'reference' => '3fa649ba0e8624c71f066a8437a4a47af5998710', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '9e243e8d8cbfbd3ef69218a441619394374a1708', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../modules/meta-box', - 'aliases' => array(), + 'aliases' => array( + 0 => '9999999-dev', + ), 'dev_requirement' => false, ), 'wpmetabox/meta-box-beaver-themer-integrator' => array(