Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.