From 6be733a30b36e18aeaa85317aad7e817d2954cb2 Mon Sep 17 00:00:00 2001 From: prconcepcion Date: Thu, 28 Dec 2023 15:16:47 +0800 Subject: [PATCH] refactored implementation --- src/init.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/init.php b/src/init.php index 0b03efd44..e7178047e 100644 --- a/src/init.php +++ b/src/init.php @@ -55,6 +55,7 @@ function __construct() { // Adds a special class to the body tag, to indicate we can now run animations. add_action( 'wp_footer', array( $this, 'init_animation' ) ); + add_action( 'wp_footer', array( $this, 'init_stackable_vars' ) ); // Add the fallback values for the default block width and wide block width. // These are used for the inside "Content width" option of Columns. @@ -101,9 +102,6 @@ public function register_frontend_assets() { wp_register_script( 'ugb-block-frontend-js', null, [], STACKABLE_VERSION ); } - $args = apply_filters( 'stackable_localize_frontend_script', array() ); - wp_localize_script( 'ugb-block-frontend-js', 'stackable', $args ); - // Register inline frontend styles, these are always loaded. // Register via a dummy style. wp_register_style( 'ugb-style-css-nodep', false ); @@ -452,6 +450,13 @@ public function load_plugin_textdomain() { public function init_animation() { echo ''; } + + public function init_stackable_vars() { + $args = apply_filters( 'stackable_localize_frontend_script', array() ); + if ( array_key_exists( 'restUrl', $args ) ) { + echo ''; + } + } } new Stackable_init();