Skip to content

Commit

Permalink
[Backport v11-branch] Add event listener for XB's.
Browse files Browse the repository at this point in the history
Merge pull request #274 from humanmade/backport-273-to-v11-branch
  • Loading branch information
robindevitt committed Nov 1, 2022
2 parents fa76923 + b414718 commit e8639df
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ function bootstrap() {
remove_filter( 'posts_clauses', 'HM\\AWS_Rekognition\\filter_query_attachment_keywords' );
}, 11 );

// Load scripts early with the analytics scripts and at as lower priority.
add_action( 'altis.analytics.enqueue_scripts', __NAMESPACE__ . '\\enqueue_assets', 20 );

// Set up global asset management.
Global_Assets\bootstrap();
}
Expand Down Expand Up @@ -95,6 +98,28 @@ function load_plugins() {
add_action( 'plugins_loaded', __NAMESPACE__ . '\\load_safe_svg', 9 );
}

/**
* Enqueue media module assets with altis-experiments.
*
* @return void
*/
function enqueue_assets() {
$config = Altis\get_config()['modules']['media'];

if ( $config['gaussholder'] ) {
wp_add_inline_script(
'altis-experiments',
sprintf(
'window.addEventListener( \'altisBlockContentChanged\', function () {' .
'if ( window.GaussHolder ) {' .
'window.GaussHolder();' .
'}' .
'} );'
)
);
}
}

/**
* Returns a callable that return true or false.
*
Expand Down

0 comments on commit e8639df

Please sign in to comment.