File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change 1616if ( ! class_exists ( 'Stackable_Init ' ) ) {
1717 class Stackable_Init {
1818
19- /**
20- * Holds the scripts which are already enqueued, to ensure we only do it once per script.
21- * @var Array
22- */
23- public $ scripts_loaded = array ();
24-
2519 /**
2620 * Enqueue the frontend scripts, ensures we only do it once.
2721 *
@@ -243,15 +237,15 @@ public function load_frontend_scripts_conditionally( $block_content, $block ) {
243237 }
244238
245239 // Enqueue the block script once.
246- if ( ! isset ( $ this ->scripts_loaded [ $ block ['blockName ' ] ] ) ) {
247- $ stackable_block = substr ( $ block ['blockName ' ], 10 );
248- do_action ( 'stackable/ ' . $ stackable_block . '/enqueue_scripts ' );
249- $ this ->scripts_loaded [ $ block ['blockName ' ] ] = true ;
240+ if ( did_action ( 'stackable/ ' . $ block ['blockName ' ] . '/enqueue_scripts ' ) === 0 ) {
241+ do_action ( 'stackable/ ' . $ block ['blockName ' ] . '/enqueue_scripts ' );
250242 }
251243
252244 // Check whether the current block needs to enqueue some scripts.
253245 // This gets called across all the blocks.
254- do_action ( 'stackable/enqueue_scripts ' , $ block_content , $ block );
246+ if ( did_action ( 'stackable/enqueue_scripts ' ) === 0 ) {
247+ do_action ( 'stackable/enqueue_scripts ' , $ block_content , $ block );
248+ }
255249
256250 return $ block_content ;
257251 }
You can’t perform that action at this time.
0 commit comments