/** * Display breadcrumbs */ public function display() { if (Habakiri::get('is_displaying_bread_crumb') === 'false') { return; } global $wp_query; // Set to home $home_label = $this->get_home_label(); $this->set($home_label, home_url('/')); // Set to blog $post_type = $this->get_post_type(); if (is_category() || is_tag() || is_date() || is_author() || is_single() && $post_type === 'post') { $show_on_front = get_option('show_on_front'); $page_for_posts = get_option('page_for_posts'); if ($show_on_front === 'page' && $page_for_posts) { $this->set(get_the_title($page_for_posts), get_permalink($page_for_posts)); } } // Set current and ancestors if (is_404()) { $this->set_for_404(); } elseif (is_search()) { $this->set_for_search(); } elseif (is_tax()) { $this->set_for_tax(); } elseif (is_attachment()) { $this->set_for_attachment(); } elseif (is_page() && !is_front_page()) { $this->set_for_page(); } elseif (is_post_type_archive()) { $this->set_for_post_type_archive(); } elseif (is_single()) { $this->set_for_single(); } elseif (is_category()) { $this->set_for_category(); } elseif (is_tag()) { $this->set_for_tag(); } elseif (is_author()) { $this->set_for_author(); } elseif (is_day()) { $this->set_for_day(); } elseif (is_month()) { $this->set_for_month(); } elseif (is_year()) { $this->set_for_year(); } elseif (is_home() && !is_front_page()) { $this->set_for_blog(); } $bread_crumb = array(); $last_item = array_pop($this->bread_crumb); foreach ($this->bread_crumb as $_bread_crumb) { if (!empty($_bread_crumb['link'])) { $bread_crumb[] = sprintf('<a href="%s">%s</a>', esc_url($_bread_crumb['link']), esc_html($_bread_crumb['title'])); } else { $bread_crumb[] = esc_html($_bread_crumb['title']); } } $bread_crumb[] = sprintf('<strong>%s</strong>', $last_item['title']); printf('<div class="breadcrumbs">%s</div>', implode(' > ', apply_filters('habakiri_bread_crumb', $bread_crumb))); }
/** * Get slider items in theme customizer. * * @return array */ public function get_saved_items() { $slider = array(); for ($i = 1; $i <= $this->max; $i++) { if (!Habakiri::get('slider_image_' . $i)) { continue; } $slider[] = array('image' => Habakiri::get('slider_image_' . $i), 'content' => Habakiri::get('slider_content_' . $i), 'url' => Habakiri::get('slider_url_' . $i), 'target' => Habakiri::get('slider_target_' . $i)); } return $slider; }
/** * Display excerpt */ protected function the_excerpt() { global $post; $is_displaying_page_header_lead = Habakiri::get('is_displaying_page_header_lead'); if (is_page() && !empty($post->post_excerpt) && $is_displaying_page_header_lead !== 'false') { ?> <div class="page-header__description"> <?php the_excerpt(); ?> <!-- end .page-header__description --></div> <?php } }
/** * 関連記事を表示 */ public function display() { if (Habakiri::get('is_displaying_related_posts') === 'false') { return; } $post_type = get_post_type(); $tax_query = $this->get_tax_query($post_type); if ($tax_query) { $posts = $this->get_related_posts($tax_query); } if (empty($posts)) { return; } global $post, $wp_query; $default_query = clone $wp_query; $wp_query->is_single = false; $wp_query->is_page = false; $wp_query->is_singular = false; ?> <div class="related-posts"> <h2 class="related-posts__title h3"><?php _e('Related posts', 'habakiri'); ?> </h2> <div class="entries entries--related-posts entries-related-posts"> <?php foreach ($posts as $post) { setup_postdata($post); get_template_part('content'); } wp_reset_postdata(); ?> </div> </div> <?php $wp_query = $default_query; }
comments_template('', true); } ?> </article> <?php } else { ?> <article <?php post_class(array('article')); ?> > <?php if (Habakiri::get('is_displaying_thumbnail') === 'false') { ?> <div class="entry"> <?php Habakiri::the_title(); ?> <div class="entry__summary entry-summary"> <?php the_excerpt(); ?> <!-- end .entry-summary --></div> <?php Habakiri::the_entry_meta(); ?> <!-- end .entry --></div>
<?php /** * Version : 1.1.0 * Author : inc2734 * Author URI : http://2inc.org * Created : April 17, 2015 * Modified : August 30, 2015 * License : GPLv2 or later * License URI: license.txt */ get_header(); ?> <?php get_template_part('modules/page-header'); ?> <div class="sub-page-contents"> <?php get_template_part('blog_templates/archive/' . Habakiri::get('blog_template')); ?> <!-- end .sub-page-contents --></div> <?php get_footer();
<?php /** * Version : 1.0.0 * Author : inc2734 * Author URI : http://2inc.org * Created : April 17, 2015 * Modified : * License : GPLv2 or later * License URI: license.txt */ get_header(); ?> <?php $show_on_front = get_option('show_on_front'); $page_for_posts = get_option('page_for_posts'); if ($show_on_front === 'page' && $page_for_posts) { Habakiri::the_page_header($page_for_posts); } else { printf('<div class="no-page-header"></div>'); } ?> <?php get_template_part('blog_templates/single/' . Habakiri::get('blog_template')); ?> <?php get_footer();
</head> <body <?php body_class(); ?> > <?php do_action('habakiri_before_container'); ?> <div id="container"> <?php /** * backward compatible * @since 1.2.0 */ $header = Habakiri::get('header'); $header_fixed = Habakiri::get('header_fixed'); $header_classes[] = $header; $header_classes[] = $header_fixed; foreach ($header_classes as $header_class) { if (preg_match('/^header\\--[^\\-]/', trim($header_class))) { $header_classes[] = preg_replace('/^(header)\\-\\-([^\\-]+)/', '$1-$2', $header_class); } } ?> <header id="header" class="header <?php echo esc_attr(implode(' ', $header_classes)); ?> "> <?php do_action('habakiri_before_header_content'); ?>
/** * Return the breakpoint when switching responsive_nav <> offcanvas_nav * * @return int */ public static function get_gnav_breakpoint() { $breakpoint = null; $gnav_breakpoint = Habakiri::get('gnav_breakpoint'); switch ($gnav_breakpoint) { case 'md': $breakpoint = 992; break; case 'lg': $breakpoint = 1200; break; } return $breakpoint; }
<?php /** * Version : 1.0.0 * Author : inc2734 * Author URI : http://2inc.org * Created : August 30, 2015 * Modified : * License : GPLv2 or later * License URI: license.txt */ $header_logo = Habakiri::get('logo'); if ($header_logo) { $header_logo = sprintf('<img src="%s" alt="%s" class="site-branding__logo" />', esc_url($header_logo), get_bloginfo('name')); } else { $header_logo = get_bloginfo('name'); } printf('<a href="%s" rel="home">%s</a>', esc_url(home_url('/')), $header_logo);
/** * Register styles */ public function register_styles() { $rgb_header_bg_color = $this->hex_to_rgb(Habakiri::get('header_bg_color')); $this->Customizer_Framework->register_styles('a', sprintf('color: %s', Habakiri::get('link_color'))); $this->Customizer_Framework->register_styles(array('a:focus', 'a:active', 'a:hover'), array(sprintf('color: %s', Habakiri::get('link_hover_color')))); $this->Customizer_Framework->register_styles(array('.site-branding a'), array(sprintf('color: %s', Habakiri::get('logo_text_color')))); $this->Customizer_Framework->register_styles(array('.responsive-nav a'), array(sprintf('color: %s', Habakiri::get('gnav_link_color')), sprintf('font-size: %spx', Habakiri::get('gnav_fontsize')))); $this->Customizer_Framework->register_styles(array('.responsive-nav a small'), array(sprintf('color: %s', Habakiri::get('gnav_sub_label_color')), sprintf('font-size: %spx', Habakiri::get('gnav_sub_label_fontsize')))); $this->Customizer_Framework->register_styles(array('.responsive-nav a:hover small', '.responsive-nav a:active small', '.responsive-nav .current-menu-item small', '.responsive-nav .current-menu-ancestor small', '.responsive-nav .current-menu-parent small', '.responsive-nav .current_page_item small', '.responsive-nav .current_page_parent small'), array(sprintf('color: %s', Habakiri::get('gnav_sub_label_hover_color')))); $gnav_link_bg_color = Habakiri::get('gnav_link_bg_color'); if ($this->hex_to_rgb($gnav_link_bg_color) == $rgb_header_bg_color) { $gnav_link_bg_color = 'transparent'; } $this->Customizer_Framework->register_styles(array('.responsive-nav .menu>.menu-item>a', '.header--transparency.header--fixed--is_scrolled .responsive-nav .menu>.menu-item>a'), array(sprintf('background-color: %s', $gnav_link_bg_color), sprintf('padding: %dpx %dpx', Habakiri::get('gnav_link_vertical_padding'), Habakiri::get('gnav_link_horizontal_padding')))); $gnav_link_bg_hover_color = Habakiri::get('gnav_link_bg_hover_color'); if ($this->hex_to_rgb($gnav_link_bg_hover_color) == $rgb_header_bg_color) { $gnav_link_bg_hover_color = 'transparent'; } $this->Customizer_Framework->register_styles(array('.responsive-nav .menu>.menu-item>a:hover', '.responsive-nav .menu>.menu-item>a:active', '.responsive-nav .menu>.current-menu-item>a', '.responsive-nav .menu>.current-menu-ancestor>a', '.responsive-nav .menu>.current-menu-parent>a', '.responsive-nav .menu>.current_page_item>a', '.responsive-nav .menu>.current_page_parent>a', '.header--transparency.header--fixed--is_scrolled .responsive-nav .menu>.menu-item>a:hover', '.header--transparency.header--fixed--is_scrolled .responsive-nav .menu>.menu-item>a:active', '.header--transparency.header--fixed--is_scrolled .responsive-nav .menu>.current-menu-item>a', '.header--transparency.header--fixed--is_scrolled .responsive-nav .menu>.current-menu-ancestor>a', '.header--transparency.header--fixed--is_scrolled .responsive-nav .menu>.current-menu-parent>a', '.header--transparency.header--fixed--is_scrolled .responsive-nav .menu>.current_page_item>a', '.header--transparency.header--fixed--is_scrolled .responsive-nav .menu>.current_page_parent>a'), array(sprintf('background-color: %s', $gnav_link_bg_hover_color), sprintf('color: %s', Habakiri::get('gnav_link_hover_color')))); $this->Customizer_Framework->register_styles(array('.responsive-nav .sub-menu a'), array(sprintf('background-color: %s', Habakiri::get('gnav_pulldown_bg_color')), sprintf('color: %s', Habakiri::get('gnav_pulldown_link_color')))); $this->Customizer_Framework->register_styles(array('.responsive-nav .sub-menu a:hover', '.responsive-nav .sub-menu a:active', '.responsive-nav .sub-menu .current-menu-item a', '.responsive-nav .sub-menu .current-menu-ancestor a', '.responsive-nav .sub-menu .current-menu-parent a', '.responsive-nav .sub-menu .current_page_item a', '.responsive-nav .sub-menu .current_page_parent a'), array(sprintf('background-color: %s', Habakiri::get('gnav_pulldown_bg_hover_color')), sprintf('color: %s', Habakiri::get('gnav_pulldown_link_hover_color')))); $this->Customizer_Framework->register_styles(array('.off-canvas-nav'), array(sprintf('font-size: %spx', Habakiri::get('offcanvas_nav_fontsize')))); $gnav_bg_color = Habakiri::get('gnav_bg_color'); if ($this->hex_to_rgb($gnav_bg_color) == $rgb_header_bg_color) { $gnav_bg_color = 'transparent'; } $this->Customizer_Framework->register_styles(array('.responsive-nav', '.header--transparency.header--fixed--is_scrolled .responsive-nav'), array(sprintf('background-color: %s', $gnav_bg_color))); $hamburger_btn_bg_color = Habakiri::get('hamburger_btn_bg_color'); $hamburger_btn_border_color = Habakiri::get('hamburger_btn_border_color'); $hamburger_btn_bg_hover_color = Habakiri::get('hamburger_btn_bg_hover_color'); $hamburger_btn_border_hover_color = Habakiri::get('hamburger_btn_border_hover_color'); if ($this->hex_to_rgb($hamburger_btn_bg_color) == $rgb_header_bg_color) { $hamburger_btn_bg_color = 'transparent'; } if ($this->hex_to_rgb($hamburger_btn_border_color) == $rgb_header_bg_color) { $hamburger_btn_border_color = 'transparent'; } if ($this->hex_to_rgb($hamburger_btn_bg_hover_color) == $rgb_header_bg_color) { $hamburger_btn_bg_hover_color = 'transparent'; } if ($this->hex_to_rgb($hamburger_btn_border_hover_color) == $rgb_header_bg_color) { $hamburger_btn_border_hover_color = 'transparent'; } $this->Customizer_Framework->register_styles(array('#responsive-btn'), array(sprintf('background-color: %s', $hamburger_btn_bg_color), sprintf('border-color: %s', $hamburger_btn_border_color), sprintf('color: %s', Habakiri::get('hamburger_btn_text_color')))); $this->Customizer_Framework->register_styles(array('#responsive-btn:hover'), array(sprintf('background-color: %s', $hamburger_btn_bg_hover_color), sprintf('border-color: %s', $hamburger_btn_border_hover_color), sprintf('color: %s', Habakiri::get('hamburger_btn_text_hover_color')))); $this->Customizer_Framework->register_styles(array('.habakiri-slider__transparent-layer'), array(sprintf('background-color: rgba( %s, %s )', implode(',', $this->hex_to_rgb(Habakiri::get('slider_option_overlay_color'))), 1 - Habakiri::get('slider_option_overlay_opacity') / 100))); if (Habakiri::get('slider_option_height')) { $this->Customizer_Framework->register_styles(array('.habakiri-slider', '.habakiri-slider__item'), array(sprintf('height: %spx', Habakiri::get('slider_option_height')), 'overflow: hidden')); } $this->Customizer_Framework->register_styles(array('.page-header'), array(sprintf('background-color: %s', Habakiri::get('page_header_bg_color')), sprintf('color: %s', Habakiri::get('page_header_text_color')))); $this->Customizer_Framework->register_styles(array('.pagination>li>a'), array(sprintf('color: %s', Habakiri::get('link_color')))); $this->Customizer_Framework->register_styles(array('.pagination>li>span'), array(sprintf('background-color: %s', Habakiri::get('link_color')), sprintf('border-color: %s', Habakiri::get('link_color')))); $this->Customizer_Framework->register_styles(array('.pagination>li>a:focus', '.pagination>li>a:hover', '.pagination>li>span:focus', '.pagination>li>span:hover'), array(sprintf('color: %s', Habakiri::get('link_hover_color')))); $this->Customizer_Framework->register_styles(array('.header'), array(sprintf('background-color: %s', Habakiri::get('header_bg_color')))); $this->Customizer_Framework->register_styles(array('.header--transparency.header--fixed--is_scrolled'), array(sprintf('background-color: %s !important', Habakiri::get('header_bg_color')))); $this->Customizer_Framework->register_styles(array('.footer'), array(sprintf('background-color: %s', Habakiri::get('footer_bg_color')))); $this->Customizer_Framework->register_styles(array('.footer-widget-area a'), array(sprintf('color: %s', Habakiri::get('footer_link_color')))); $this->Customizer_Framework->register_styles(array('.footer-widget-area', '.footer-widget-area .widget_calendar #wp-calendar caption'), array(sprintf('color: %s', Habakiri::get('footer_text_color')))); $this->Customizer_Framework->register_styles(array('.footer-widget-area .widget_calendar #wp-calendar', '.footer-widget-area .widget_calendar #wp-calendar *'), array(sprintf('border-color: %s', Habakiri::get('footer_text_color')))); if ($gnav_breakpoint = Habakiri::get_gnav_breakpoint()) { $this->Customizer_Framework->register_styles(array('.responsive-nav'), array('display: block'), '', $gnav_breakpoint); $this->Customizer_Framework->register_styles(array('.off-canvas-nav', '#responsive-btn'), array('display: none !important'), '', $gnav_breakpoint); $this->Customizer_Framework->register_styles(array('.header--2row'), array('padding-bottom: 0'), '', $gnav_breakpoint); $this->Customizer_Framework->register_styles(array('.header--2row .header__col', '.header--center .header__col'), array('display: block'), '', $gnav_breakpoint); $this->Customizer_Framework->register_styles(array('.header--2row .responsive-nav', '.header--center .responsive-nav'), array('margin-right: -1000px', 'margin-left: -1000px', 'padding-right: 1000px', 'padding-left: 1000px'), '', $gnav_breakpoint); if ($gnav_bg_color == 'transparent' && $gnav_link_bg_color == 'transparent' && $gnav_link_bg_hover_color == 'transparent') { $this->Customizer_Framework->register_styles(array('.header--2row .site-branding', '.header--center .site-branding'), array('padding-bottom: 0'), '', $gnav_breakpoint); } $this->Customizer_Framework->register_styles(array('.header--center .site-branding'), array('text-align: center'), '', $gnav_breakpoint); } }
* Version : 1.3.0 * Author : inc2734 * Author URI : http://2inc.org * Created : April 17, 2015 * Modified : August 28, 2015 * License : GPLv2 or later * License URI: license.txt */ ?> <article <?php post_class(array('article', 'article--page')); ?> > <div class="entry"> <?php if (Habakiri::get('is_displaying_page_header') === 'false') { Habakiri::the_title(); } ?> <?php do_action('habakiri_before_entry_content'); ?> <div class="entry__content"> <?php the_content(); ?> <!-- end .entry__content --></div> <?php do_action('habakiri_after_entry_content'); ?> <!-- end .entry --></div>
/** * ページヘッダーを表示 * * @param int $post_id */ public static function the_page_header($post_id = null) { if (Habakiri::get('is_displaying_page_header') === 'false') { return; } global $post; $title = get_the_title($post_id); if (is_404()) { $title = __('Woops! Page not found.', 'habakiri'); } elseif (is_search()) { $title = sprintf(__('Search Results for: %s', 'habakiri'), get_search_query()); } $class = ''; if (!is_single()) { $class = 'entry-title'; } $class = apply_filters('habakiri_title_class_in_page_header', $class); ?> <div class="page-header text-center" <?php if (get_header_image()) { ?> style="background-image: url( <?php header_image(); ?> )"<?php } ?> > <div class="container"> <h1 class="page-header__title <?php echo !empty($class) ? esc_attr($class) : ''; ?> "> <?php echo apply_filters('habakiri_title_in_page_header', esc_html($title)); ?> </h1> <?php while (have_posts()) { the_post(); ?> <?php if (is_page() && get_the_excerpt() && !empty($post->post_excerpt) && Habakiri::get('is_displaying_page_header_lead') !== 'false') { ?> <div class="page-header__description page-header-description"> <?php the_excerpt(); ?> <!-- end .page-description --></div> <?php } ?> <?php } ?> <!-- end .container --></div> <!-- end .page-header --></div> <?php }
<?php /** * Version : 1.0.0 * Author : inc2734 * Author URI : http://2inc.org * Created : August 30, 2015 * Modified : * License : GPLv2 or later * License URI: license.txt */ if (Habakiri::get('is_displaying_related_posts') === 'false') { return; } $RelatedPosts = new Habakiri_Related_Posts(); $RelatedPosts->display();
/** * CSS を出力 */ public function customize_css() { ?> <style> a { color: <?php echo esc_html(Habakiri::get('link_color')); ?> ; } a:focus, a:active, a:hover { color: <?php echo esc_html(Habakiri::get('link_hover_color')); ?> ; } .site-branding a { color: <?php echo esc_html(Habakiri::get('logo_text_color')); ?> ; } .global-nav a { color: <?php echo esc_html(Habakiri::get('gnav_link_color')); ?> ; } .global-nav a:hover, .global-nav a:active, .global-nav ul li.current-menu-item > a, .global-nav ul li.current-menu-ancestor > a, .global-nav ul li.current-menu-parent > a, .global-nav ul li.current_page_item > a, .global-nav ul li.current_page_parent > a { color: <?php echo esc_html(Habakiri::get('gnav_link_hover_color')); ?> ; } .global-nav .sub-menu a, .global-nav .children a { background-color: <?php echo esc_html(Habakiri::get('gnav_pulldown_bg_color')); ?> ; color: <?php echo esc_html(Habakiri::get('gnav_pulldown_link_color')); ?> ; } .global-nav .sub-menu a:hover, .global-nav .children a:active, .global-nav .children .current-menu-item, .global-nav .children .current-menu-ancestor, .global-nav .children .current-menu-parent, .global-nav .children .current_page_item, .global-nav .children .current_page_parent { background-color: <?php echo esc_html(Habakiri::get('gnav_pulldown_bg_hover_color')); ?> ; } .entry--has_media__link--text { background-color: <?php echo esc_html(Habakiri::get('link_color')); ?> ; } .page-header { background-color: <?php echo esc_html(Habakiri::get('page_header_bg_color')); ?> ; color: <?php echo esc_html(Habakiri::get('page_header_text_color')); ?> ; } .pagination>li>a { color: <?php echo esc_html(Habakiri::get('link_color')); ?> ; } .pagination>li>span { background-color: <?php echo esc_html(Habakiri::get('link_color')); ?> ; border-color: <?php echo esc_html(Habakiri::get('link_color')); ?> ; } .pagination>li>a:focus, .pagination>li>a:hover, .pagination>li>span:focus, .pagination>li>span:hover { color: <?php echo esc_html(Habakiri::get('link_hover_color')); ?> ; } #header { background-color: <?php echo esc_html(Habakiri::get('header_bg_color')); ?> ; } #footer { background-color: <?php echo esc_html(Habakiri::get('footer_bg_color')); ?> ; } #footer .footer-widget-area, #footer .footer-widget-area .widget_calendar #wp-calendar caption { color: <?php echo esc_html(Habakiri::get('footer_text_color')); ?> ; } #footer .footer-widget-area a { color: <?php echo esc_html(Habakiri::get('footer_link_color')); ?> ; } #footer .footer-widget-area .widget_calendar #wp-calendar, #footer .footer-widget-area .widget_calendar #wp-calendar * { border-color: <?php echo esc_html(Habakiri::get('footer_text_color')); ?> ; } </style> <?php }