This PR adds wp_localize_script in the CGB template.
Problem
You can not determine the path or URL of the plugin programatically inside the blocks. This is usually done by PHP functions plugin_dir_path() and plugin_dir_url(). However, they are not accessible inside the blocks (say if one wants to include an image locally and link to it in the src tag).
Solution
In this PR, I have added an array CGB_GLOBAL containing dynamic data for a JS Global. The globals can now be imported inside the block JS file. More useful globals can be added in the future.
This PR adds
wp_localize_script
in the CGB template.Problem You can not determine the path or URL of the plugin programatically inside the blocks. This is usually done by PHP functions plugin_dir_path() and plugin_dir_url(). However, they are not accessible inside the blocks (say if one wants to include an image locally and link to it in the src tag).
Solution In this PR, I have added an array
CGB_GLOBAL
containing dynamic data for a JS Global. The globals can now be imported inside the block JS file. More useful globals can be added in the future.