Exemplo n.º 1
0
    /**
     * Displays the page header
     *
     * @param  bool $placed whether the title has already been output
     * @param  string|null $title if set, overrides the current post title
     */
    public static function page_header($placed = false, $title = null)
    {
        if ($placed) {
            return;
        }
        global $post;
        if (is_null($title)) {
            $title = get_the_title();
        }
        $needHeaderTitle = WpvTemplates::has_page_header();
        $needButtons = WpvTemplates::has_post_siblings_buttons();
        $titleColor = WpvTemplates::page_header_title_color();
        $description = '';
        if (is_category()) {
            $description = category_description();
        } else {
            if (is_object($post)) {
                $description = get_post_meta($post->ID, 'description', true);
            }
        }
        if (has_post_format('link') && !empty($title)) {
            $title = "<a href='" . wpv_post_meta(wpv_get_the_ID(), 'wpv-post-format-link') . "' target='_blank'>{$title}</a>";
        }
        if ($needHeaderTitle || $needButtons) {
            ?>
<header class="page-header <?php 
            echo esc_attr($needButtons ? 'has-buttons' : '');
            ?>
">
				<div class="page-header-content">
					<?php 
            if ($needHeaderTitle && !empty($title)) {
                ?>
						<h1 style="<?php 
                echo esc_attr($titleColor);
                ?>
">
							<span class="title">
								<?php 
                echo wp_kses_post($title);
                ?>
								<?php 
                if (!empty($description)) {
                    ?>
									<div class="desc"><?php 
                    echo wp_kses_post($description);
                    ?>
</div>
								<?php 
                }
                ?>
							</span>
						</h1>
					<?php 
            }
            ?>
					<?php 
            if ($needButtons) {
                get_template_part('templates/post-siblings-links', $post->post_type);
            }
            ?>
				</div>
			</header><?php 
        }
    }