Skip to content

Commit 042e608

Browse files
committed
🐛 FIX: Paths + Names
1 parent 7626acb commit 042e608

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

packages/cgb-scripts/config/externals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const externals = [
4242
jquery: 'jQuery', // import $ from 'jquery' // Use the WordPress version after enqueuing it.
4343
'react-dom': 'ReactDOM',
4444
lodash: 'lodash', // Lodash is there in Gutenberg.
45-
CGB_GLOBAL: 'CGB_GLOBAL' // Add custom dynamic data to a global var.
45+
cgbGlobal: 'cgbGlobal', // import cgbGlobal from 'cgbGlobal' // Localized data.
4646
}
4747
);
4848

packages/cgb-scripts/template/src/init.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ function <% blockNamePHPLower %>_cgb_block_assets() { // phpcs:ignore
5353
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
5454
);
5555

56-
// Localise globals - plugin path and url for use in blocks.
56+
// Localised globals. Use dynamic PHP stuff in JavaScript via `cgbGlobal object.
5757
wp_localize_script(
5858
'<% blockNamePHPLower %>-cgb-block-js',
59-
'CGB_GLOBAL', // Array containing dynamic data for a JS Global.
59+
'cgbGlobal', // Array containing dynamic data for a JS Global.
6060
[
61-
'path' => plugin_dir_path( __FILE__ ),
62-
'url' => plugin_dir_url( __FILE__ ),
61+
'pluginDirPath' => plugin_dir_path( __DIR__ ),
62+
'pluginDirUrl' => plugin_dir_url( __DIR__ ),
63+
// Add more data here that you want to access from cgbGlobal object.
6364
]
6465
);
6566

0 commit comments

Comments
 (0)