Astra_Posts_Structure_Markup::override_entry_header()

Override default entry header.


Description


Return

(void)


Source

File: inc/modules/posts-structures/class-astra-posts-structure-markup.php

	public function override_entry_header() {
		global $post;
		if ( is_null( $post ) ) {
			return;
		}

		$post_type = $post->post_type;
		$type      = is_singular( $post_type ) ? 'single' : 'archive';

		$supported_post_types = Astra_Posts_Structure_Loader::get_supported_post_types();
		if ( ! in_array( $post_type, $supported_post_types ) ) {
			return;
		}

		$layout_type = ( 'single' === $type ) ? astra_get_option( 'ast-dynamic-single-' . $post_type . '-layout', 'layout-1' ) : astra_get_option( 'ast-dynamic-archive-' . $post_type . '-layout', 'layout-1' );

		// If banner title section is disabled then halt further processing.
		if ( 'single' === $type ) {
			if ( false === astra_get_option( 'ast-single-' . $post_type . '-title', ( class_exists( 'WooCommerce' ) && 'product' === $post_type ) ? false : true ) ) {
				add_filter( 'astra_single_layout_one_banner_visibility', '__return_false' );
				return;
			}
		} else {
			// If layout-1 is set then no need to process further.
			if ( false === astra_get_option( 'ast-archive-' . $post_type . '-title', ( class_exists( 'WooCommerce' ) && 'product' === $post_type ) ? false : true ) ) {
				add_filter( 'astra_the_title_enabled', '__return_false' );
				return;
			}
			if ( 'layout-1' === $layout_type ) {
				// WooCommerce specific compatibility - As layout-1 support needs to add externally.
				if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() ) ) {
					$this->astra_woocommerce_banner_layout_1_compatibility();
					add_action( 'astra_primary_content_top', array( $this, 'astra_force_render_banner_layout_1' ) );
				}
				return;
			}

			add_filter( 'astra_the_title_enabled', '__return_false' );
		}

		if ( 'single' === $type && 'layout-2' === $layout_type ) {
			do_action( 'astra_before_single_' . $post_type . '_banner_content' );

			get_template_part( 'template-parts/single-banner' );

			do_action( 'astra_after_single_' . $post_type . '_banner_content' );

			add_filter( 'astra_remove_entry_header_content', '__return_true' );
			add_filter( 'astra_single_layout_one_banner_visibility', '__return_false' );
		} elseif ( ( is_front_page() && is_home() ) || ( is_home() ) ) {
			if ( true === astra_get_option( 'ast-dynamic-archive-post-banner-on-blog', false ) ) {
				// For latest posts page.
				add_filter( 'astra_the_default_home_page_title', array( $this, 'astra_archive_custom_title' ) );

				// For blog page.
				add_filter( 'astra_the_blog_home_page_title', array( $this, 'astra_archive_custom_title' ) );

				do_action( 'astra_before_archive_' . $post_type . '_banner_content' );

				get_template_part( 'template-parts/archive-banner' );

				do_action( 'astra_after_archive_' . $post_type . '_banner_content' );

				remove_filter( 'astra_the_default_home_page_title', array( $this, 'astra_archive_custom_title' ) );

				remove_filter( 'astra_the_blog_home_page_title', array( $this, 'astra_archive_custom_title' ) );
			}
		} elseif ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() ) ) {
			$this->astra_woocommerce_banner_layout_1_compatibility();

			do_action( 'astra_before_archive_' . $post_type . '_banner_content' );

			get_template_part( 'template-parts/archive-banner' );

			do_action( 'astra_after_archive_' . $post_type . '_banner_content' );

			if ( is_shop() ) {
				remove_filter( 'woocommerce_page_title', array( $this, 'astra_archive_custom_title' ) );
			}
		} elseif ( class_exists( 'WooCommerce' ) && 'single' === $type && 'product' === $post_type && 'layout-1' === $layout_type ) {
			// Adding layout 1 support to Product post type for single layout.
			add_action( 'astra_primary_content_top', array( $this, 'astra_force_render_banner_layout_1' ) );
		} elseif ( 'archive' === $type ) {
			$is_post_type_archive = is_post_type_archive( $post_type ) ? true : false;

			if ( $is_post_type_archive ) {
				add_filter( 'get_the_archive_title', array( $this, 'astra_archive_custom_title' ) );
			}

			do_action( 'astra_before_archive_' . $post_type . '_banner_content' );

			get_template_part( 'template-parts/archive-banner' );

			do_action( 'astra_after_archive_' . $post_type . '_banner_content' );

			if ( $is_post_type_archive ) {
				remove_filter( 'get_the_archive_title', array( $this, 'astra_archive_custom_title' ) );
			}
		}
	}

Changelog

Changelog
Version Description
4.0.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.