has_items() ) { return; } get_template_part( 'template-parts/page-header/page-header' ); } /** * Show archive title * * @since 1.0.0 * * @return string */ public function the_archive_title( $title ) { if ( is_search() ) { $title = sprintf( esc_html__( 'Search Results for: %s', 'razzi' ), get_search_query() ); } elseif ( is_404() ) { $title = sprintf( esc_html__( 'Page Not Found', 'razzi' ) ); } elseif ( is_page() ) { $title = get_the_title(Helper::get_post_ID()); } elseif ( is_home() && is_front_page() ) { $title = esc_html__( 'The Latest Posts', 'razzi' ); } elseif ( is_home() && ! is_front_page() ) { $title = get_the_title( intval( get_option( 'page_for_posts' ) ) ); } elseif ( function_exists( 'is_shop' ) && is_shop() ) { $current_term = get_queried_object(); if ( $current_term && isset( $current_term->term_id ) && $current_term->taxonomy == 'product_cat' ) { $title = $current_term->name; } else { $title = get_the_title( intval( get_option( 'woocommerce_shop_page_id' ) ) ); } } elseif ( is_single() ) { $title = get_the_title(); } elseif ( is_tax() || is_category() ) { $title = single_term_title( '', false ); } return $title; } /** * Show page header * * @since 1.0.0 * * @return array */ public function get_items() { if ( ! isset( $this->items ) ) { $items = []; if ( is_singular('post') ) { $items = intval( Helper::get_option( 'single_post_breadcrumb' ) ) ? [ 'breadcrumb' ] : $items; } elseif ( is_singular('product') ) { $items = intval( Helper::get_option( 'single_product_page_header' ) ) ? [ 'breadcrumb' ] : $items; } elseif ( \Razzi\Helper::is_catalog() ) { $page_header = Helper::get_option( 'catalog_page_header' ); if ( ! empty( $page_header ) ) { $items = Helper::get_option( 'catalog_page_header_els' ); if ( $page_header == 'template' ) { $items['layout'] = 'template'; } elseif ( $page_header == 'layout-2' ) { $rz_page_header_bg_id = is_product_category() ? get_term_meta( get_queried_object()->term_id, 'rz_page_header_bg_id', true ) : ''; if( ! empty( $rz_page_header_bg_id ) ) { $items['bg_image'] = wp_get_attachment_image_src( $rz_page_header_bg_id, 'full' )[0]; } else { $items['bg_image'] = Helper::get_option( 'catalog_page_header_image' ); } } } } elseif ( is_page() ) { if ( intval( Helper::get_option( 'page_header' ) ) ) { $items = Helper::get_option( 'page_header_els' ); if ( Helper::get_option( 'page_header_layout' ) == 'layout-2' && in_array( get_post_meta( get_the_ID(), 'rz_page_header_layout', true ), array( 'default', 'layout-2', '' ) ) ) { if ( get_post_meta( get_the_ID(), 'rz_page_header_layout', true ) == 'layout-2' ) { $image_id = get_post_meta( get_the_ID(), 'rz_page_header_image', true ); $items['bg_image'] = wp_get_attachment_image_src( $image_id, 'full' )[0]; } else { $items['bg_image'] = Helper::get_option( 'page_header_image' ); } } } } elseif ( intval( Helper::get_option( 'page_header_blog' ) ) ) { $items = Helper::get_option( 'page_header_blog_els' ); } $items = $this->custom_items( $items ); $this->items = $items; } return apply_filters( 'razzi_get_page_header_elements', $this->items ); } /** * Check has items * * @since 1.0.0 * * @return int */ public function has_items() { return count( $this->get_items() ); } /** * Custom page header * * @since 1.0.0 * * @return array */ public function custom_items( $items ) { if ( empty( $items ) ) { return []; } $get_id = Helper::get_post_ID(); if ( get_post_meta( $get_id, 'rz_hide_page_header', true ) ) { return []; } if ( get_post_meta( $get_id, 'rz_hide_breadcrumb', true ) ) { $key = array_search( 'breadcrumb', $items ); if ( $key !== false ) { unset( $items[ $key ] ); } } if ( get_post_meta( $get_id, 'rz_hide_title', true ) ) { $key = array_search( 'title', $items ); if ( $key !== false ) { unset( $items[ $key ] ); } } return $items; } /** * Show background image * * @since 1.0.0 * * @return void */ public function show_image() { $items = $this->get_items(); if ( isset( $items['bg_image'] ) && ! empty( $items['bg_image'] ) ) { echo '
'; } } /** * Open content * * @since 1.0.0 * * @return void */ public function open_content() { $items = $this->get_items(); $container_class = 'container'; if( isset( $items['layout'] ) && $items['layout'] == 'template' ) { $container_class = ''; } if( Helper::is_catalog() && Helper::get_option('shop_catalog_layout') == 'grid' ) { if( Helper::get_option('catalog_content_width') == 'large' ) { $container_class = 'razzi-container'; } elseif( Helper::get_option('catalog_content_width') == 'wide' ) { $container_class = 'razzi-container-wide'; } } elseif( is_singular('product') ) { if( Helper::get_option('product_content_width') == 'large' ) { $container_class = 'razzi-container'; } elseif( Helper::get_option('product_content_width') == 'wide' ) { $container_class = 'razzi-container-wide'; } } echo sprintf('