' . get_the_author() . ''; } elseif ( is_year() ) { $title = get_the_date( 'Y' ); } elseif ( is_month() ) { $title = get_the_date( 'F Y' ); } elseif ( is_day() ) { $title = get_the_date( 'F j, Y' ); } elseif ( is_post_type_archive() ) { $title = post_type_archive_title( '', false ); } elseif ( is_tax() ) { $title = single_term_title( '', false ); } return $title; } /** * Get page specific layout or the customizer setting. * * @param string $layout Header layout. * * @return string */ public function get_header_layout( $layout ) { $page_id = hestia_get_current_page_id(); /** * If it's blog, default will be 'default' */ if ( is_home() ) { $layout = 'default'; } if ( get_post_type() === 'jetpack-portfolio' ) { $layout = 'default'; } /** * By default, get value from customizer. If it's cart or checkout, the default will be no-content. */ if ( class_exists( 'WooCommerce' ) ) { if ( is_cart() || is_checkout() ) { $layout = 'no-content'; } if ( is_shop() ) { $layout = 'default'; } if ( is_product() ) { return 'no-content'; } } /** * Try to get individual layout. */ $individual_layout = get_post_meta( $page_id, 'hestia_header_layout', true ); return ! empty( $individual_layout ) ? $individual_layout : $layout; } /** * The single post header. */ public function post_page_header() { $layout = apply_filters( 'hestia_header_layout', get_theme_mod( 'hestia_header_layout', 'default' ) ); if ( 'classic-blog' === $layout ) { return; } $this->display_header( $layout, 'post' ); } /** * Single post before content. * This function display the title in page if layout is not default. */ public function post_page_before_content() { $layout = apply_filters( 'hestia_header_layout', get_theme_mod( 'hestia_header_layout', 'default' ) ); if ( 'default' === $layout ) { return; } echo $this->render_header( $layout ); } /** * Display page header on single page and on full width page template. * * @param string $layout header layout. * @param string $type post / page / other. */ private function display_header( $layout, $type ) { echo ''; } /** * Decide if header should be before featured post or before content. */ public function maybe_render_header() { $hook = current_action(); if ( 'hestia_before_index_posts_loop' === $hook && false !== hestia_featured_posts_enabled() ) { $this->post_page_before_content(); } if ( 'hestia_before_index_content' === $hook && false === hestia_featured_posts_enabled() ) { $this->post_page_before_content(); } } /** * Get classic blog header class. * * @return string */ private function get_classic_header_class() { $default = hestia_get_blog_layout_default(); $sidebar_layout = apply_filters( 'hestia_sidebar_layout', get_theme_mod( 'hestia_blog_sidebar_layout', $default ) ); if ( class_exists( 'WooCommerce' ) && is_shop() ) { return 'col-md-12'; } if ( get_post_type() === 'jetpack-portfolio' ) { return 'col-md-12'; } if ( is_404() ) { return 'col-md-10 col-md-offset-2'; } if ( is_page() ) { return 'col-md-12'; } if ( is_active_sidebar( 'sidebar-1' ) ) { return 'col-md-12'; } if ( 'full-width' !== $sidebar_layout && is_customize_preview() && ! is_active_sidebar( 'sidebar-1' ) ) { return 'col-md-12'; } if ( ( 'full-width' === $sidebar_layout || ! is_active_sidebar( 'sidebar-1' ) ) && false === hestia_featured_posts_enabled() ) { return 'col-md-12'; } return 'col-md-10 col-md-offset-1'; } /** * Display header content based on layout. * * @param string $layout header layout. * * @return string */ private function render_header( $layout ) { if ( is_attachment() ) { $layout = 'default'; } $header_output = ''; if ( 'default' !== $layout ) { $header_output .= '
'; } $header_output .= $this->header_content( $layout ); $header_output .= $this->maybe_render_post_meta( $layout ); if ( 'classic-blog' === $layout ) { $header_output .= $this->add_image_in_content(); } if ( 'default' !== $layout ) { $header_output .= '
'; } if ( 'default' === $layout ) { $header_output = '
' . $header_output . '
'; } return $header_output; } /** * Add image in content for classic-blog layout. * * @return string */ private function add_image_in_content() { if ( class_exists( 'WooCommerce' ) && ( is_product() || is_cart() || is_checkout() ) ) { return ''; } $image_url = $this->get_page_background(); if ( empty( $image_url ) ) { return ''; } $image_id = attachment_url_to_postid( $image_url ); $image1_alt = ''; if ( $image_id ) { $image1_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); } $image_markup = '' . esc_attr( $image1_alt ) . ''; if ( class_exists( 'WooCommerce' ) && is_shop() ) { $image_markup = '
' . $image_markup . '
'; } return $image_markup; } /** * Header content display. * * @param string $header_layout the header layout. */ private function header_content( $header_layout ) { $title_class = 'hestia-title'; if ( 'default' !== $header_layout ) { $title_class .= ' title-in-content'; } if ( is_404() ) { $header_content_output = '

' . esc_html( 'Oops! That page can’t be found.' ) . '

'; return $header_content_output; } if ( is_archive() ) { $title = get_the_archive_title(); $header_content_output = ''; if ( ! empty( $title ) ) { $header_content_output .= '

' . $title . '

'; } $description = get_the_archive_description(); if ( $description ) { $header_content_output .= '
' . $description . '
'; } return $header_content_output; } if ( is_search() ) { $header_content_output = '

'; /* translators: search result */ $header_content_output .= sprintf( esc_html__( 'Search Results for: %s', 'hestia' ), get_search_query() ); $header_content_output .= '

'; return $header_content_output; } $disabled_frontpage = get_theme_mod( 'disable_frontpage_sections', false ); if ( is_front_page() && get_option( 'show_on_front' ) === 'page' && true === (bool) $disabled_frontpage ) { $header_content_output = '

'; $header_content_output .= single_post_title( '', false ); $header_content_output .= '

'; return $header_content_output; } if ( is_front_page() && get_option( 'show_on_front' ) === 'posts' ) { $header_content_output = '

'; $header_content_output .= get_bloginfo( 'description' ); $header_content_output .= '

'; return $header_content_output; } $entry_class = ''; if ( ! is_page() ) { $entry_class = 'entry-title'; } $header_content_output = '

' . single_post_title( '', false ) . '

'; return $header_content_output; } /** * Check if post meta should be displayed. * * @param string $header_layout the header layout. */ private function maybe_render_post_meta( $header_layout ) { if ( ! is_single() ) { return ''; } if ( class_exists( 'WooCommerce' ) ) { if ( is_product() ) { return ''; } } global $post; $post_meta_output = ''; $author_id = $post->post_author; $author_name = get_the_author_meta( 'display_name', $author_id ); $author_posts_url = get_author_posts_url( get_the_author_meta( 'ID', $author_id ) ); if ( 'default' === $header_layout ) { $post_meta_output .= '

'; } else { $post_meta_output .= '

'; } $post_meta_output .= apply_filters( 'hestia_single_post_meta', sprintf( /* translators: %1$s is Author name wrapped, %2$s is Date*/ esc_html__( 'Published by %1$s on %2$s', 'hestia' ), /* translators: %1$s is Author name, %2$s is Author link*/ sprintf( '%1$s', esc_html( $author_name ), esc_url( $author_posts_url ) ), $this->get_time_tags() ) ); if ( 'default' === $header_layout ) { $post_meta_output .= '

'; } else { $post_meta_output .= '

'; } return $post_meta_output; } /** * Get