From 8db0a72001ea323f825262fdaeec55612e573ba1 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Tue, 25 Feb 2025 00:59:06 +0700 Subject: [PATCH] Only localize scripts once --- classes/helpers/FrmAppHelper.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index bf5c5610cb..851168d7b4 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -36,6 +36,11 @@ class FrmAppHelper { */ private static $included_svg = false; + /** + * @var array Keys are locations and values are true or false. + */ + private static $localized_script_locations = array(); + /** * @since 1.07.02 * @@ -3324,6 +3329,10 @@ public static function load_font_style() { * @return void */ public static function localize_script( $location ) { + if ( ! empty( self::$localized_script_locations[ $location ] ) ) { + return; + } + global $wp_scripts, $wp_version; $script_strings = array( @@ -3427,6 +3436,8 @@ public static function localize_script( $location ) { wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings ); } }//end if + + self::$localized_script_locations[ $location ] = true; } /**