Opened 9 months ago
Last modified 8 months ago
#60850 assigned defect (bug)
Localize script not working in WordPress 6.5-RC3-57856
Reported by: | dev28 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.5 |
Component: | Script Loader | Keywords: | close |
Focuses: | Cc: |
Description
During my testing of the plugin, I encountered an issue with the localized script while using the 6.5 beta version. Specifically, I noticed a JavaScript error that prevented the script from working as intended. However, I would like to clarify that this issue is not present in the current version, and the localized script works flawlessly without any errors.
System info:
`
### wp-core ###
version: 6.5-RC3-57856
site_language: en_US
user_language: en_US
timezone: +05:00
permalink: /%postname%/
https_status: false
multisite: false
user_registration: 0
blog_public: 0
default_comment_status: open
environment_type: production
user_count: 1
dotorg_communication: true
### wp-paths-sizes ###
wordpress_path: /home/worldwebusers/phpdev3/public_html/wordpressbeta
wordpress_size: 54.67 MB (57325890 bytes)
uploads_path: /home/worldwebusers/phpdev3/public_html/wordpressbeta/wp-content/uploads
uploads_size: 1.35 MB (1419920 bytes)
themes_path: /home/worldwebusers/phpdev3/public_html/wordpressbeta/wp-content/themes
themes_size: 36.91 MB (38701146 bytes)
plugins_path: /home/worldwebusers/phpdev3/public_html/wordpressbeta/wp-content/plugins
plugins_size: 6.99 MB (7332893 bytes)
database_size: 2.75 MB (2883584 bytes)
total_size: 102.68 MB (107663433 bytes)
### wp-active-theme ###
name: Twenty Twenty-Four (twentytwentyfour)
version: 1.0
author: the WordPress team
author_website: https://wordpress.org
parent_theme: none
theme_features: core-block-patterns, post-thumbnails, responsive-embeds, editor-styles, html5, automatic-feed-links, widgets-block-editor, block-templates
theme_path: /home/worldwebusers/phpdev3/public_html/wordpressbeta/wp-content/themes/twentytwentyfour
auto_update: Disabled
### wp-themes-inactive (13) ###
Twenty Eleven: version: 4.5, author: the WordPress team, Auto-updates disabled
Twenty Fifteen: version: 3.6, author: the WordPress team, Auto-updates disabled
Twenty Fourteen: version: 3.8, author: the WordPress team, Auto-updates disabled
Twenty Nineteen: version: 2.7, author: the WordPress team, Auto-updates disabled
Twenty Seventeen: version: 3.5, author: the WordPress team, Auto-updates disabled
Twenty Sixteen: version: 3.1, author: the WordPress team, Auto-updates disabled
Twenty Ten: version: 4.0, author: the WordPress team, Auto-updates disabled
Twenty Thirteen: version: 4.0, author: the WordPress team, Auto-updates disabled
Twenty Twelve: version: 4.1, author: the WordPress team, Auto-updates disabled
Twenty Twenty: version: 2.5, author: the WordPress team, Auto-updates disabled
Twenty Twenty-One: version: 2.1, author: the WordPress team, Auto-updates disabled
Twenty Twenty-Three: version: 1.3, author: the WordPress team, Auto-updates disabled
Twenty Twenty-Two: version: 1.6, author: the WordPress team, Auto-updates disabled
### wp-plugins-active (2) ###
Loan Calculator WP: version: 1.2.3, author: World Web Technology, Auto-updates disabled
Loan Calculator WP Pro: version: 1.0.0, author: World Web Technology, Auto-updates disabled
### wp-plugins-inactive (5) ###
Akismet Anti-spam: Spam Protection: version: 5.3.2, author: Automattic - Anti-spam Team, Auto-updates disabled
Classic Editor: version: 1.6.3, author: WordPress Contributors, Auto-updates disabled
Hello Dolly: version: 1.7.2, author: Matt Mullenweg, Auto-updates disabled
Reviews Sorted: version: 2.3.10, author: Reviews Sorted, Auto-updates disabled
WP Custom Post Type Filter: version: 1.0.0, author: WWT, Auto-updates disabled
### wp-media ###
image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1809
imagemagick_version: ImageMagick 7.1.1-29 Q16-HDRI x86_64 21991 https://imagemagick.org
imagick_version: 3.7.0
file_uploads: 1
post_max_size: 512M
upload_max_filesize: 512M
max_effective_size: 512 MB
max_file_uploads: 20
imagick_limits:
imagick::RESOURCETYPE_AREA: 62 GB
imagick::RESOURCETYPE_DISK: 9.2233720368548E+18
imagick::RESOURCETYPE_FILE: 768
imagick::RESOURCETYPE_MAP: 31 GB
imagick::RESOURCETYPE_MEMORY: 16 GB
imagick::RESOURCETYPE_THREAD: 1
imagick::RESOURCETYPE_TIME: 0
imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, ASHLAR, AVI, AVS, BAYER, BAYERA, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUBE, CUR, CUT, DATA, DCM, DCR, DCRAW, DCX, DDS, DFONT, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FARBFELD, FAX, FF, FILE, FITS, FL32, FLV, FRACTAL, FTP, FTS, FTXT, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, KERNEL, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MPO, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORA, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PHM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PS, PS2, PS3, PSB, PSD, PTIF, PWP, QOI, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGB565, RGBA, RGBO, RGF, RLA, RLE, RMF, RSVG, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, STRIMG, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TM2, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YAML, YCbCr, YCbCrA, YUV
gd_version: 2.3.3
gd_formats: GIF, JPEG, PNG, WebP, BMP, AVIF, XPM
ghostscript_version: 9.25
### wp-server ###
server_architecture: Linux 3.10.0-1160.114.2.el7.x86_64 x86_64
httpd_software: Apache/2.4.6
php_version: 8.1.27 64bit
php_sapi: cgi-fcgi
max_input_variables: 1500
time_limit: 300
memory_limit: -1
max_input_time: 600
upload_max_filesize: 512M
php_post_max_size: 512M
curl_version: 7.29.0 NSS/3.90
suhosin: false
imagick_availability: true
pretty_permalinks: true
htaccess_extra_rules: false
current: 2024-03-27T08:25:43+00:00
utc-time: Wednesday, 27-Mar-24 08:25:43 UTC
server-time: 2024-03-27T13:25:38+05:00
### wp-database ###
extension: mysqli
server_version: 5.7.36
client_version: mysqlnd 8.1.27
max_allowed_packet: 1073741824
max_connections: 151
### wp-constants ###
WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /home/worldwebusers/phpdev3/public_html/wordpressbeta/wp-content
WP_PLUGIN_DIR: /home/worldwebusers/phpdev3/public_html/wordpressbeta/wp-content/plugins
WP_MEMORY_LIMIT: 2048M
WP_MAX_MEMORY_LIMIT: -1
WP_DEBUG: false
WP_DEBUG_DISPLAY: false
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: Undefined
WP_DEVELOPMENT_MODE: undefined
DB_CHARSET: utf8
DB_COLLATE: undefined
### wp-filesystem ###
wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
`
Hi there and welcome to WordPress Trac!
wp_localize_script
works only if the script has already been registered. This has always been this way.In your plugin I see that you are registering the script on
wp_enqueue_script
and callingwp_localize_script
in the shortcode callback.In classic theme that would work, because the former usually runs in
wp_head
and the shortcode is only parsed later.However, in block themes, the content (and shortcodes) can be parsed before the
wp_enqueue_scripts
, which leads to this scenario here where your script is not registered yet. This has always been this way.Since you are using
'loan-calculator-frontend-script'
only in the frontend anyway, an easy fix would be to move the script registration to the shortcode callback as well.