Path to validation language files is incorrect.
- This topic has 5 replies, 3 voices, and was last updated 1 year, 7 months ago by
SIW.
-
AuthorPosts
-
August 30, 2023 at 2:33 PM #43088
pluginoven
ParticipantMeta-box is throwing an error when trying to load the validation file:
wp-content/plugins/meta-box/js/js/validation
one too many /jsUpon 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' ) ) ), ] ); }
August 30, 2023 at 10:47 PM #43092Peter
ModeratorHello,
I do not see that issue on my demo site. The constant
RWMB_DIR
should return the path to themeta-box
plugin folder/wp-content/plugins/meta-box/
.
You can output the constantRWMB_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.September 11, 2023 at 8:26 PM #43203pluginoven
ParticipantAre 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 theRWMB_DIR
and theRWMB_JS_URL
constants, which is the reason of opening this thread.September 11, 2023 at 8:30 PM #43204pluginoven
ParticipantThis 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 explanatorySeptember 12, 2023 at 9:16 PM #43220Peter
ModeratorHello,
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.
September 17, 2023 at 9:23 PM #43263SIW
ParticipantI 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
-
AuthorPosts
- You must be logged in to reply to this topic.