Skip to content

Instantly share code, notes, and snippets.

@Nikschavan
Created June 24, 2019 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikschavan/208891eec65c621f333de1d79781c1e5 to your computer and use it in GitHub Desktop.
Save Nikschavan/208891eec65c621f333de1d79781c1e5 to your computer and use it in GitHub Desktop.
Load CSS in <head> for the Astra Custom layouts built using Beaver Builder.
<?php
/**
* Enqueue styles
*/
function astra_bb_custom_layout_styles_in_head() {
if ( ! is_callable( 'FLBuilder::enqueue_layout_styles_scripts_by_id' ) ) {
return;
}
if ( ! is_callable( 'Astra_Target_Rules_Fields::get_instance' ) ) {
return;
}
$option = array(
'location' => 'ast-advanced-hook-location',
'exclusion' => 'ast-advanced-hook-exclusion',
'users' => 'ast-advanced-hook-users',
);
$result = Astra_Target_Rules_Fields::get_instance()->get_posts_by_conditions( ASTRA_ADVANCED_HOOKS_POST_TYPE, $option );
$custom_layouts = array_keys( $result );
foreach ( $custom_layouts as $custom_layout ) {
// Enqueue styles and scripts for this post.
FLBuilder::enqueue_layout_styles_scripts_by_id( $custom_layout );
}
}
add_action( 'wp_enqueue_scripts', 'astra_bb_custom_layout_styles_in_head', 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment