Astra_Ext_Advanced_Hooks_Markup::load_advanced_hooks_template()
Load Advanced hook markup.
Description
Return
(void)
Source
File: addons/advanced-hooks/classes/class-astra-ext-advanced-hooks-markup.php
public function load_advanced_hooks_template() {
if ( is_singular( ASTRA_ADVANCED_HOOKS_POST_TYPE ) ) {
$post_id = get_the_id();
$action = get_post_meta( $post_id, 'ast-advanced-hook-action', true );
$layout = get_post_meta( $post_id, 'ast-advanced-hook-layout', true );
$priority = get_post_meta( $post_id, 'ast-advanced-hook-priority', true );
// Exclude default p tag wrapper from the content if selected hook is from below list.
$exclude_wrapper_hooks = array( 'astra_html_before', 'astra_body_top', 'astra_head_top', 'astra_head_bottom', 'wp_head', 'astra_body_bottom', 'wp_footer' );
$with_wrapper = in_array( $action, $exclude_wrapper_hooks );
if ( $with_wrapper ) {
remove_filter( 'the_content', 'wpautop' );
}
$astra_hooks = Astra_Ext_Advanced_Hooks_Meta::$hooks;
if ( isset( $astra_hooks['content']['hooks'][ $action ] ) || isset( $astra_hooks['comment']['hooks'][ $action ] ) || isset( $astra_hooks['sidebar']['hooks'][ $action ] ) ) {
$action = 'astra_advanced_hook_template';
}
$vc_activated = Astra_Addon_Page_Builder_Compatibility::is_vc_activated( $post_id );
if ( 'astra_advanced_hook_template' == $action || $vc_activated ) {
remove_action( 'astra_advanced_hook_template', array( $this, 'template_empty_content' ) );
add_action( 'astra_advanced_hook_template', 'the_content' );
} elseif ( 'header' == $layout ) {
$this->prepare_astra_header_filter( $post_id, 'header' );
// remove default site's fixed header if sticky header is activated.
add_filter( 'astra_fixed_header_markup_enabled', '__return_false' );
$action = 'astra_custom_header';
// if astra_custom_header not exist then call astra_header.
if ( ! has_action( 'astra_custom_header' ) ) {
$action = 'astra_header';
}
add_action(
$action,
function() use ( $post_id ) {
echo '<header class="ast-custom-header" itemscope="itemscope" itemtype="https://schema.org/WPHeader">';
Astra_Ext_Advanced_Hooks_Markup::get_instance()->get_the_hook_content();
echo '</header>';
},
$priority
);
} elseif ( 'footer' == $layout ) {
$this->prepare_astra_header_filter( $post_id, 'footer' );
$action = 'astra_custom_footer';
// if astra_custom_footer not exist then call astra_footer.
if ( ! has_action( 'astra_custom_footer' ) ) {
$action = 'astra_footer';
}
// Add Action for custom header advanced-hooks.
add_action(
$action,
function() use ( $post_id ) {
echo '<footer class="ast-custom-footer" itemscope="itemscope" itemtype="https://schema.org/WPFooter">';
Astra_Ext_Advanced_Hooks_Markup::get_instance()->get_the_hook_content();
echo '</footer>';
},
$priority
);
} else {
add_action(
$action,
function() use ( $post_id ) {
Astra_Ext_Advanced_Hooks_Markup::get_instance()->get_the_hook_content();
},
$priority
);
}
}
}
Expand full source code Collapse full source code View on Trac