Enqueues Item Submission block extra scripts only when necessary.
This commit is contained in:
parent
f4ae150261
commit
6765a310ef
|
@ -1,3 +1,3 @@
|
||||||
export default function() {
|
export default function() {
|
||||||
return null
|
return null
|
||||||
};
|
}
|
|
@ -249,14 +249,16 @@ function tainacan_blocks_add_common_theme_scripts() {
|
||||||
wp_localize_script( 'tainacan-blocks-common-scripts', 'tainacan_blocks', $block_settings);
|
wp_localize_script( 'tainacan-blocks-common-scripts', 'tainacan_blocks', $block_settings);
|
||||||
wp_localize_script( 'tainacan-blocks-common-scripts', 'tainacan_plugin', $plugin_settings);
|
wp_localize_script( 'tainacan-blocks-common-scripts', 'tainacan_plugin', $plugin_settings);
|
||||||
|
|
||||||
// Necessary while we don't have a better way to do this only
|
// Necessary do this only when the item submission block is present
|
||||||
// when item submission block is present
|
function tainacan_enqueue_extra_item_submission_assets() {
|
||||||
|
if ( has_block( 'tainacan/item-submission-form', get_the_ID() ) )
|
||||||
tainacan_blocks_add_extra_item_submission_assets();
|
tainacan_blocks_add_extra_item_submission_assets();
|
||||||
|
}
|
||||||
|
add_action('wp', 'tainacan_enqueue_extra_item_submission_assets');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the extra scripts necessary for item submission block,
|
* Registers the extra scripts necessary for item submission block
|
||||||
* even on theme side :/
|
|
||||||
*/
|
*/
|
||||||
function tainacan_blocks_add_extra_item_submission_assets() {
|
function tainacan_blocks_add_extra_item_submission_assets() {
|
||||||
|
|
||||||
|
@ -266,6 +268,7 @@ function tainacan_blocks_add_extra_item_submission_assets() {
|
||||||
'https://www.google.com/recaptcha/api.js',
|
'https://www.google.com/recaptcha/api.js',
|
||||||
[], false, true
|
[], false, true
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_enqueue_script('tainacan-google-recaptcha-script');
|
wp_enqueue_script('tainacan-google-recaptcha-script');
|
||||||
|
|
||||||
// Registers extra metadata type forms
|
// Registers extra metadata type forms
|
||||||
|
|
Loading…
Reference in New Issue