Support Forum
Meta-box is throwing an error when trying to load the validation file:
wp-content/plugins/meta-box/js/js/validation
one too many /js
Upon further inspection of inc/validation.php
we see this function:
public function enqueue() {
wp_enqueue_script( 'rwmb-validation', RWMB_JS_URL . 'validation.min.js', [ 'jquery', 'rwmb' ], RWMB_VER, true );
$locale = determine_locale();
$locale_short = substr( $locale, 0, 2 );
$locale = file_exists( RWMB_DIR . "js/validation/i18n/messages_$locale.js" ) ? $locale : $locale_short;
if ( file_exists( RWMB_DIR . "js/validation/i18n/messages_$locale.js" ) ) {
wp_enqueue_script( 'rwmb-validation-i18n', RWMB_JS_URL . "validation/i18n/messages_$locale.js", ['rwmb-validation'], RWMB_VER, true );
}
RWMB_Helpers_Field::localize_script_once( 'rwmb-validation', 'rwmbValidation', [
'message' => esc_html( apply_filters( 'rwmb_validation_message_string', __( 'Please correct the errors highlighted below and try again.', 'meta-box' ) ) ),
] );
}
We changed to the following as a workaround... but please, review and fix this in the next release:
public function enqueue() {
wp_enqueue_script( 'rwmb-validation', RWMB_JS_URL . 'validation.min.js', [ 'jquery', 'rwmb' ], RWMB_VER, true );
$locale = determine_locale();
$locale_short = substr( $locale, 0, 2 );
$locale = file_exists( RWMB_DIR . "validation/i18n/messages_$locale.js" ) ? $locale : $locale_short;
if ( file_exists( RWMB_DIR . "validation/i18n/messages_$locale.js" ) ) {
wp_enqueue_script( 'rwmb-validation-i18n', RWMB_JS_URL . "validation/i18n/messages_$locale.js", ['rwmb-validation'], RWMB_VER, true );
}
RWMB_Helpers_Field::localize_script_once( 'rwmb-validation', 'rwmbValidation', [
'message' => esc_html( apply_filters( 'rwmb_validation_message_string', __( 'Please correct the errors highlighted below and try again.', 'meta-box' ) ) ),
] );
}
Hello,
I do not see that issue on my demo site. The constant RWMB_DIR
should return the path to the meta-box
plugin folder /wp-content/plugins/meta-box/
.
You can output the constant RWMB_DIR
on your site and see what displayed
echo RWMB_DIR;
If it returns /wp-content/plugins/meta-box/js/
then it is the wrong path.
Are you testing this in the default language?
Try switching WordPress to another language...
if ( file_exists( RWMB_DIR . "validation/i18n/messages_$locale.js" ) ) {...}
And yes, we have tested both the RWMB_DIR
and the RWMB_JS_URL
constants, which is the reason of opening this thread.
This has been happening across all sites that is running the latest 5.7.5 version of MetaBox.
If it helps, we can provide step-by-step instructions to recreate the issue, but figured it was self explanatory
Hello,
Here is the screenshot when I test with the German language https://imgur.com/yiLWdj4
I don't see that issue. Please share the steps to reproduce the issue. You can also deactivate all plugins except Meta Box, MB extensions, switch to a standard theme of WordPress and recheck this. Or even re-install Meta Box on the site.
I have submitted a PR to fix this https://github.com/wpmetabox/meta-box/pull/1526 so it should be fixed in the next update. It was caused (also by me...) when adding the localized validation messages https://github.com/wpmetabox/meta-box/pull/1525/files