Server : Apache System : Linux server.lienzindia.com 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64 User : plutus ( 1007) PHP Version : 7.4.33 Disable Function : NONE Directory : /home/plutus/public_html/wp-content/themes/vrm/inc/page/ |
Upload File : |
<?php namespace TotalTheme\Page; use TotalTheme\Error_404; use TotalTheme\Replace_Vars; use TotalTheme\Theme_Builder; \defined( 'ABSPATH' ) || exit; /** * Page Header Class. */ class Header { /** * Is the page header is enabled or not. */ protected static $is_enabled; /** * The page header style. */ protected static $style; /** * Stores the subheading to prevent extra db checks. */ protected static $subheading; /** * Returns the globally set style. */ public static function global_style() { return \get_theme_mod( 'page_header_style' ); } /** * Checks if the current style is the same as the global style. */ public static function is_global_style() { return ( self::global_style() === self::style() || 'default' === self::style() ); } /** * Checks if the header is enabled or not. */ public static function style() { if ( ! \is_null( self::$style ) ) { return self::$style; } $post_id = \wpex_get_current_post_id(); $style = self::global_style(); if ( WPEX_PTU_ACTIVE ) { if ( \is_singular() ) { $post_type = \get_post_type(); if ( 'wpex_templates' === $post_type && 'single' === \totaltheme_get_dynamic_template_type( $post_id ) ) { $template_single_type = Theme_Builder::instance()->get_post_type_from_template_id( $post_id ); if ( $template_single_type ) { $post_type = $template_single_type; } } $custom_style = \wpex_get_ptu_type_mod( $post_type, 'page_header_title_style' ); if ( $custom_style ) { $style = $custom_style; } } elseif ( \is_post_type_archive() ) { $custom_style = \wpex_get_ptu_type_mod( \get_query_var( 'post_type' ), 'archive_page_header_title_style' ); if ( $custom_style ) { $style = $custom_style; } } elseif ( \is_tax() ) { $custom_style = \wpex_get_ptu_tax_mod( \get_query_var( 'taxonomy' ), 'page_header_title_style' ); if ( $custom_style ) { $style = $custom_style; } } } if ( $post_id && $meta = \get_post_meta( $post_id, 'wpex_post_title_style', true ) ) { $style = $meta; } /** * Filters the page header style. * * @param string $style */ $style = \apply_filters( 'totaltheme/page/header/style', $style ); /*** deprecated ***/ $style = (string) \apply_filters( 'wpex_page_header_style', $style ); if ( empty( $style ) ) { $style = 'default'; } self::$style = $style; return self::$style; } /** * Checks if the header is enabled or not. */ public static function is_enabled() { if ( ! \is_null( self::$is_enabled ) ) { return self::$is_enabled; } $check = \get_theme_mod( 'enable_page_header', true ); $is_singular = \is_singular(); // Hide by default if style is set to hidden. if ( 'hidden' === self::style() ) { $check = false; } // Check on/off switches to see if the title is disabled for particular parts. if ( ! $is_singular && $check ) { if ( \wpex_is_blog_query() ) { $check = \get_theme_mod( 'blog_archive_has_page_header', $check ); } elseif ( \is_post_type_archive() ) { $check = \get_theme_mod( get_query_var( 'post_type' ) . '_archive_has_page_header', $check ); } elseif ( \wpex_is_staff_tax() ) { $check = \get_theme_mod( 'staff_archive_has_page_header', $check ); } elseif ( \wpex_is_portfolio_tax() ) { $check = \get_theme_mod( 'portfolio_archive_has_page_header', $check ); } elseif ( \wpex_is_testimonials_tax() ) { $check = \get_theme_mod( 'testimonials_archive_has_page_header', $check ); } elseif ( \is_search() ) { // @todo rename mod to search_archive_has_page_header for consistency. $check = \get_theme_mod( 'search_has_page_header', $check ); } } // Custom 404. if ( \is_404() ) { $check = Error_404::instance()->is_page_header_enabled(); } // Woo Checks. if ( \defined( 'WPEX_WOOCOMMERCE_ACTIVE' ) && \WPEX_WOOCOMMERCE_ACTIVE && $check ) { if ( \wpex_is_woo_tax() ) { if ( ! \get_theme_mod( 'woo_archive_has_page_header', true ) ) { $check = false; } } elseif ( \wpex_is_woo_shop() ) { if ( ! \get_theme_mod( 'woo_shop_title', true ) ) { $check = false; } } } /** * Filters whether if the page header is enabled. * Runs before meta checks to ensure meta always overrides. * * @param bool $check */ $check = (bool) \apply_filters( 'wpex_has_page_header', $check ); // Single post checks. if ( $post_id = \wpex_get_current_post_id() ) { if ( $is_singular && $check ) { if ( \function_exists( 'is_product' ) && \is_product() ) { $check = \get_theme_mod( 'woo_product_has_page_header', $check ); } else { $post_type = \get_post_type(); if ( 'wpex_templates' === $post_type ) { $template_type = \totaltheme_get_dynamic_template_type( $post_id ); switch ( $template_type ) { case 'error_404': $check = Error_404::instance()->is_page_header_enabled(); break; case 'archive': // @todo can we reverse check archives. break; case 'single': $template_single_type = Theme_Builder::instance()->get_post_type_from_template_id( $post_id ); if ( $template_single_type ) { $check = \get_theme_mod( "{$template_single_type}_singular_page_title", $check ); } break; } } else { $check = \get_theme_mod( "{$post_type}_singular_page_title", $check ); } } } // Get page meta setting - MUST CHECK LAST. // @todo add new better meta field named something like wpex_has_title. $meta = \get_post_meta( $post_id, 'wpex_disable_title', true ); if ( 'enable' === $meta ) { $check = true; } elseif ( 'on' === $meta ) { // Allow for a background-image page header style with the title disabled (so it only shows the image). if ( 'background-image' !== \get_post_meta( $post_id, 'wpex_post_title_style', true ) ) { $check = false; } } } /** * Filters if the page header is enabled. * * @param bool $check */ $check = \apply_filters( 'totaltheme/page/header/is_enabled', $check ); /*** deprecated ***/ $check = (bool) apply_filters( 'wpex_display_page_header', $check ); self::$is_enabled = $check; return self::$is_enabled; } /** * Returns the page header breakpoint. */ public static function breakpoint(): string { $bk = \wpex_get_mod( 'page_header_breakpoint', 'md', true ); /** * Filters the page header breakpoint. * * @param string $bk */ $bk = \apply_filters( 'totaltheme/page/header/breakpoint', $bk ); /*** deprecated ***/ $bk = (string) apply_filters( 'wpex_page_header_breakpoint', $bk ); return $bk; } /** * Checks if the page header has a title. */ public static function has_title(): bool { $check = true; $post_id = \wpex_get_current_post_id(); if ( $post_id && 'on' === \get_post_meta( $post_id, 'wpex_disable_title', true ) ) { $check = false; } /** * Filters whether the page title displays the title or not. * * @param bool $check */ $check = \apply_filters( 'totaltheme/page/header/has_title', $check ); /*** deprecated ***/ $check = (bool) \apply_filters( 'wpex_has_page_header_title', $check ); return $check; } /** * Checks if the page header has a subheading. */ public static function has_subheading(): bool { $check = (bool) self::get_subheading(); /** * Filters whether the page header has a subheading or not. * * @param string $check */ $check = \apply_filters( 'totaltheme/page/header/has_subheading', $check ); /*** deprecated ***/ $check = (bool) \apply_filters( 'wpex_page_header_has_subheading', $check ); return $check; } /** * Returns the subheading. */ public static function get_subheading(): string { if ( ! \is_null( self::$subheading ) ) { return self::$subheading; } $subheading = ''; if ( $post_id = \wpex_get_current_post_id() ) { if ( $meta = \get_post_meta( $post_id, 'wpex_post_subheading', true ) ) { $subheading = $meta; } } elseif ( \is_category() || \is_tag() ) { $position = \get_theme_mod( 'category_description_position' ); $position = $position ?: 'under_title'; if ( 'under_title' === $position ) { $subheading = \term_description(); } } elseif ( \is_author() ) { $subheading = \sprintf( \esc_html__( 'This author has written %s articles', 'total' ), \get_the_author_posts() ); } elseif ( $tax = \is_tax() ) { if ( ! \wpex_has_term_description_above_loop() ) { $subheading = \term_description(); // note: get_the_archive_description makes extra check to is_author() which isn't needed } } /** * Filters the page header subheading * * @param string $subheading */ $subheading = \apply_filters( 'totaltheme/page/header/subheading', $subheading ); /*** deprecated ***/ $subheading = (string) \apply_filters( 'wpex_post_subheading', $subheading, null ); if ( $subheading ) { $subheading = (new Replace_Vars)->replace( $subheading ); } self::$subheading = $subheading; return self::$subheading; } }