Astra_Ext_Advanced_Hooks_Markup::load_markup()
Advanced Hooks markup loader
Description
Loads appropriate template file based on the style option selected in options panel.
Source
File: addons/advanced-hooks/classes/class-astra-ext-advanced-hooks-markup.php
public function load_markup() { $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 ); $header_counter = 0; $footer_counter = 0; $layout_404_counter = 0; foreach ( $result as $post_id => $post_data ) { $post_type = get_post_type(); if ( ASTRA_ADVANCED_HOOKS_POST_TYPE != $post_type ) { $action = get_post_meta( $post_id, 'ast-advanced-hook-action', true ); $layout = get_post_meta( $post_id, 'ast-advanced-hook-layout', false ); $priority = get_post_meta( $post_id, 'ast-advanced-hook-priority', true ); add_action( 'wp_enqueue_scripts', function() use ( $post_id ) { $styles = ''; // Add VC style if it is activated. $wpb_custom_css = get_post_meta( $post_id, '_wpb_shortcodes_custom_css', true ); $styles .= $wpb_custom_css; $padding = get_post_meta( $post_id, 'ast-advanced-hook-padding', true ); $padding_top = isset( $padding['top'] ) ? $padding['top'] : ''; $padding_top = is_numeric( $padding_top ) ? $padding_top . 'px' : $padding_top; $padding_bottom = isset( $padding['bottom'] ) ? $padding['bottom'] : ''; $padding_bottom = is_numeric( $padding_bottom ) ? $padding_bottom . 'px' : $padding_bottom; if ( ! ( empty( $padding_top ) && empty( $padding_bottom ) ) ) { $styles .= ' .astra-advanced-hook-' . $post_id . ' { '; if ( ! empty( $padding_top ) ) { $styles .= 'padding-top: ' . $padding_top . ';'; } if ( ! empty( $padding_bottom ) ) { $styles .= 'padding-bottom: ' . $padding_bottom . ';'; } $styles .= '}'; wp_add_inline_style( 'astra-addon-css', $styles ); } } ); if ( isset( $layout[0] ) && '404-page' == $layout[0] && 0 == $layout_404_counter ) { $this->prepare_astra_header_filter( $post_id, '404-page' ); add_action( 'astra_get_content_layout', 'astra_return_content_layout_page_builder' ); add_action( 'astra_page_layout', 'astra_return_page_layout_no_sidebar' ); $layout_404_settings = get_post_meta( $post_id, 'ast-404-page', true ); if ( isset( $layout_404_settings['disable_header'] ) && 'enabled' == $layout_404_settings['disable_header'] ) { remove_action( 'astra_header', 'astra_header_markup' ); if ( true === astra_addon_builder_helper()->is_header_footer_builder_active ) { remove_action( 'astra_header', array( Astra_Builder_Header::get_instance(), 'prepare_header_builder_markup' ) ); } } if ( isset( $layout_404_settings['disable_footer'] ) && 'enabled' == $layout_404_settings['disable_footer'] ) { remove_action( 'astra_footer', 'astra_footer_markup' ); if ( true === astra_addon_builder_helper()->is_header_footer_builder_active ) { remove_action( 'astra_footer', array( Astra_Builder_Footer::get_instance(), 'footer_markup' ) ); } } add_action( 'astra_entry_content_404_page', function() use ( $post_id ) { Astra_Ext_Advanced_Hooks_Markup::get_instance()->get_action_content( $post_id ); }, $priority ); $layout_404_counter ++; } elseif ( isset( $layout[0] ) && 'header' == $layout[0] && 0 == $header_counter ) { $this->prepare_astra_header_filter( $post_id, 'header' ); if ( true === astra_addon_builder_helper()->is_header_footer_builder_active ) { remove_action( 'astra_header', array( Astra_Builder_Header::get_instance(), 'prepare_header_builder_markup' ) ); } // 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_action_content( $post_id ); echo '</header>'; }, $priority ); $header_counter++; } elseif ( isset( $layout[0] ) && 'footer' == $layout[0] && 0 == $footer_counter ) { $this->prepare_astra_header_filter( $post_id, 'footer' ); if ( true === astra_addon_builder_helper()->is_header_footer_builder_active ) { remove_action( 'astra_footer', array( Astra_Builder_Footer::get_instance(), 'footer_markup' ) ); } $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_action_content( $post_id ); echo '</footer>'; }, $priority ); $footer_counter++; } elseif ( isset( $layout[0] ) && 'content' == $layout[0] ) { add_filter( 'render_block', function ( $content, $parsed_block ) use ( $post_id ) { return Astra_Ext_Advanced_Hooks_Markup::get_instance()->render_inside_content( $post_id, $content, $parsed_block ); }, 10, 2 ); } if ( isset( $layout[0] ) && '0' != $layout[0] && 'header' != $layout[0] && 'footer' != $layout[0] ) { // Add Action for advanced-hooks. add_action( $action, function() use ( $post_id ) { Astra_Ext_Advanced_Hooks_Markup::get_instance()->get_action_content( $post_id ); }, $priority ); } } } }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |