Created
June 24, 2019 10:51
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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