Skip to content

Commit

Permalink
use "script" property to pull js to the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicente Canales committed Mar 4, 2021
1 parent fa18ba7 commit 2144245
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/block-library/src/frontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Internal dependencies
*/
import './navigation/modals';
3 changes: 2 additions & 1 deletion packages/block-library/src/navigation-link/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
16 changes: 12 additions & 4 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/modals/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// console.log( 'hi this is the new modals.js' );
console.log( 'hi this is the new modals.js' );

0 comments on commit 2144245

Please sign in to comment.