From 21442457fe0492e0b1e1b80fd20839c2e21b0704 Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Thu, 4 Mar 2021 18:51:45 -0300 Subject: [PATCH] use "script" property to pull js to the frontend --- packages/block-library/src/frontend.js | 4 ++++ .../block-library/src/navigation-link/block.json | 3 ++- packages/block-library/src/navigation/index.php | 16 ++++++++++++---- .../block-library/src/navigation/modals/index.js | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 packages/block-library/src/frontend.js diff --git a/packages/block-library/src/frontend.js b/packages/block-library/src/frontend.js new file mode 100644 index 0000000000000..0393a9ca20144 --- /dev/null +++ b/packages/block-library/src/frontend.js @@ -0,0 +1,4 @@ +/** + * Internal dependencies + */ +import './navigation/modals'; diff --git a/packages/block-library/src/navigation-link/block.json b/packages/block-library/src/navigation-link/block.json index 17ea418528737..41497cfdde386 100644 --- a/packages/block-library/src/navigation-link/block.json +++ b/packages/block-library/src/navigation-link/block.json @@ -45,5 +45,6 @@ "html": false }, "editorStyle": "wp-block-navigation-link-editor", - "style": "wp-block-navigation-link" + "style": "wp-block-navigation-link", + "script": "core_block_navigation_load_frontend_scripts" } diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index f604a5a74b300..e35a68887c3fe 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -121,11 +121,19 @@ function render_block_core_navigation( $attributes, $content, $block ) { unset( $attributes['rgbTextColor'], $attributes['rgbBackgroundColor'] ); - wp_enqueue_script( - 'core_block_navigation_load_modals', - plugins_url( 'gutenberg/build/modals/index.js' ), + // wp_enqueue_script( + // 'core_block_navigation_load_frontend_scripts', + // plugins_url( 'gutenberg/build/block-library-frontend/index.js' ), + // array(), + // null, + // true + // ); + + wp_register_script( + 'core_block_navigation_load_frontend_scripts', + plugins_url( 'gutenberg/build/block-library-frontend/index.js' ), array(), - null, + false, true ); diff --git a/packages/block-library/src/navigation/modals/index.js b/packages/block-library/src/navigation/modals/index.js index ac6fcb32816d8..ec810224a6b60 100644 --- a/packages/block-library/src/navigation/modals/index.js +++ b/packages/block-library/src/navigation/modals/index.js @@ -1 +1 @@ -// console.log( 'hi this is the new modals.js' ); +console.log( 'hi this is the new modals.js' );