mirror of
https://github.com/10h30/yeuchaybo.git
synced 2026-07-11 18:56:16 +09:00
285 lines
8.3 KiB
PHP
285 lines
8.3 KiB
PHP
<?php
|
|
/**
|
|
* Child Theme Library
|
|
*
|
|
* WARNING: This file is a part of the core Child Theme Library.
|
|
* DO NOT edit this file under any circumstances. Please use
|
|
* the functions.php file to make any theme modifications.
|
|
*
|
|
* @package SEOThemes\ChildThemeLibrary\Functions
|
|
* @since 1.0.0
|
|
* @link https://github.com/seothemes/child-theme-library
|
|
* @author Thuan Bui
|
|
* @copyright Copyright © 2018 Thuan Bui
|
|
* @license GPL-2.0+
|
|
*/
|
|
|
|
add_action( 'genesis_before', 'child_theme_hero_section_setup' );
|
|
/**
|
|
* Set up hero section.
|
|
*
|
|
* Removes and repositions the title on all possible types of pages. Wrapped
|
|
* up into one function so it can easily be unhooked from genesis_before.
|
|
*
|
|
* @since 1.0.0
|
|
*
|
|
* @return void
|
|
*/
|
|
function child_theme_hero_section_setup() {
|
|
|
|
if ( ! current_theme_supports( 'hero-section' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
|
|
//remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
|
|
//remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
|
|
//remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' );
|
|
//remove_action( 'genesis_archive_title_descriptions', 'genesis_do_archive_headings_open', 5, 3 );
|
|
//remove_action( 'genesis_archive_title_descriptions', 'genesis_do_archive_headings_close', 15, 3 );
|
|
//remove_action( 'genesis_before_loop', 'genesis_do_date_archive_title' );
|
|
//remove_action( 'genesis_before_loop', 'genesis_do_blog_template_heading' );
|
|
//remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
|
|
//remove_action( 'genesis_before_loop', 'genesis_do_author_title_description', 15 );
|
|
//remove_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description' );
|
|
//remove_action( 'genesis_before_loop', 'genesis_do_search_title' );
|
|
//remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
|
|
//remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
|
|
|
|
add_filter( 'woocommerce_show_page_title', '__return_null' );
|
|
add_filter( 'genesis_search_title_output', '__return_false' );
|
|
|
|
//add_action( 'child_theme_hero_section', 'genesis_do_posts_page_heading' );
|
|
//add_action( 'child_theme_hero_section', 'genesis_do_date_archive_title' );
|
|
//add_action( 'child_theme_hero_section', 'genesis_do_taxonomy_title_description' );
|
|
//add_action( 'child_theme_hero_section', 'genesis_do_author_title_description' );
|
|
//add_action( 'child_theme_hero_section', 'genesis_do_cpt_archive_title_description' );
|
|
//add_action( 'child_theme_hero_section', 'child_theme_hero_section_title', 10 );
|
|
//add_action( 'child_theme_hero_section', 'child_theme_hero_section_excerpt', 20 );
|
|
//add_action( 'be_title_toggle_remove', 'child_theme_hero_section_title_toggle' );
|
|
//add_action( 'genesis_before_content', 'child_theme_hero_section_remove_404_title' );
|
|
//add_action( 'genesis_before_content_sidebar_wrap', 'child_theme_hero_section_display' );
|
|
add_action( 'genesis_before_content_sidebar_wrap', 'authority_featured_image', 1 );
|
|
|
|
}
|
|
|
|
/**
|
|
* Remove default title of 404 pages.
|
|
*
|
|
* @since 1.0.0
|
|
*
|
|
* @return void
|
|
*/
|
|
function child_theme_hero_section_remove_404_title() {
|
|
|
|
if ( is_404() ) {
|
|
|
|
add_filter( 'genesis_markup_entry-title_open', '__return_false' );
|
|
add_filter( 'genesis_markup_entry-title_content', '__return_false' );
|
|
add_filter( 'genesis_markup_entry-title_close', '__return_false' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Integrate with Genesis Title Toggle plugin
|
|
*
|
|
* @since 1.0.0
|
|
*
|
|
* @author Bill Erickson
|
|
* @link https://www.billerickson.net/code/genesis-title-toggle-theme-integration
|
|
*
|
|
* @return void
|
|
*/
|
|
function child_theme_hero_section_title_toggle() {
|
|
|
|
remove_action( 'child_theme_hero_section', 'child_theme_hero_section_title', 10 );
|
|
remove_action( 'child_theme_hero_section', 'child_theme_hero_section_excerpt', 20 );
|
|
|
|
}
|
|
|
|
/**
|
|
* Display title in hero section.
|
|
*
|
|
* Works out the correct title to display in the hero section on a per page
|
|
* basis. Also adds the entry title back in to the entry inside the loop.
|
|
*
|
|
* @since 1.0.0
|
|
*
|
|
* @return void
|
|
*/
|
|
function child_theme_hero_section_title() {
|
|
|
|
// Add post titles back inside posts loop.
|
|
if ( is_home() || is_archive() || is_category() || is_tag() || is_tax() || is_search() || is_page_template( 'page_blog.php' ) ) {
|
|
|
|
add_action( 'genesis_entry_header', 'genesis_do_post_title', 2 );
|
|
|
|
}
|
|
|
|
if ( class_exists( 'WooCommerce' ) && is_shop() ) {
|
|
|
|
genesis_markup( array(
|
|
'open' => '<h1 %s>',
|
|
'close' => '</h1>',
|
|
'content' => get_the_title( wc_get_page_id( 'shop' ) ),
|
|
'context' => 'entry-title',
|
|
) );
|
|
|
|
} elseif ( is_home() && 'posts' === get_option( 'show_on_front' ) ) {
|
|
|
|
genesis_markup( array(
|
|
'open' => '<h1 %s>',
|
|
'close' => '</h1>',
|
|
'content' => apply_filters( 'child_theme_latest_posts_title', __( 'Latest Posts', 'child-theme-library' ) ),
|
|
'context' => 'entry-title',
|
|
) );
|
|
|
|
} elseif ( is_404() ) {
|
|
|
|
genesis_markup( array(
|
|
'open' => '<h1 %s>',
|
|
'close' => '</h1>',
|
|
'content' => apply_filters( 'genesis_404_entry_title', __( 'Not found, error 404', 'child-theme-library' ) ),
|
|
'context' => 'entry-title',
|
|
) );
|
|
|
|
} elseif ( is_search() ) {
|
|
|
|
genesis_markup( array(
|
|
'open' => '<h1 %s>',
|
|
'close' => '</h1>',
|
|
'content' => apply_filters( 'genesis_search_title_text', __( 'Search results for: ', 'child-theme-library' ) ) . get_search_query(),
|
|
'context' => 'entry-title',
|
|
) );
|
|
|
|
} elseif ( is_page_template( 'page_blog.php' ) ) {
|
|
|
|
do_action( 'genesis_archive_title_descriptions', get_the_title(), '', 'posts-page-description' );
|
|
|
|
} elseif ( is_singular() ) {
|
|
|
|
genesis_do_post_title();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Display page excerpt.
|
|
*
|
|
* Prints the correct excerpt on a per page basis. If on the WooCommerce shop
|
|
* page then the products result count is be displayed instead of the page
|
|
* excerpt. Also, if on a single product then no excerpt will be output.
|
|
*
|
|
* @since 1.0.0
|
|
*
|
|
* @return void
|
|
*/
|
|
function child_theme_hero_section_excerpt() {
|
|
|
|
if ( class_exists( 'WooCommerce' ) && is_shop() ) {
|
|
|
|
woocommerce_result_count();
|
|
|
|
} elseif ( is_home() && 'posts' === get_option( 'show_on_front' ) ) {
|
|
|
|
printf( '<p itemprop="description">%s</p>', apply_filters( 'child_theme_latest_posts_excerpt', 'Showing the latest posts' ) );
|
|
|
|
} elseif ( is_search() ) {
|
|
|
|
$id = get_page_by_path( 'search' );
|
|
|
|
if ( has_excerpt( $id ) ) {
|
|
|
|
printf( '<p itemprop="description">%s</p>', do_shortcode( get_the_excerpt( $id ) ) );
|
|
|
|
}
|
|
} elseif ( is_404() ) {
|
|
|
|
$id = get_page_by_path( 'error' );
|
|
|
|
if ( has_excerpt( $id ) ) {
|
|
|
|
printf( '<p itemprop="description">%s</p>', do_shortcode( get_the_excerpt( $id ) ) );
|
|
|
|
}
|
|
} //elseif ( ( is_singular() ) && ! is_singular( 'product' ) && has_excerpt() ) {
|
|
|
|
//printf( '<p itemprop="description">%s</p>', do_shortcode( get_the_excerpt() ) );
|
|
|
|
//}
|
|
}
|
|
|
|
/**
|
|
* Display the hero section.
|
|
*
|
|
* Conditionally outputs the opening and closing hero section markup and runs
|
|
* the hero_section hook which all of our hero functions are hooked to.
|
|
*
|
|
* @since 1.0.0
|
|
*
|
|
* @return void
|
|
*/
|
|
function child_theme_hero_section_display() {
|
|
|
|
// Output hero section markup.
|
|
genesis_markup( array(
|
|
'open' => '<section %s><div class="wrap">',
|
|
'context' => 'hero-section',
|
|
) );
|
|
|
|
/**
|
|
* Do hero section hook.
|
|
*
|
|
* @hooked child_theme_hero_section_title - 10
|
|
* @hooked child_theme_hero_section_excerpt - 20
|
|
* @hooked genesis_do_posts_page_heading
|
|
* @hooked genesis_do_date_archive_title
|
|
* @hooked genesis_do_blog_template_heading
|
|
* @hooked genesis_do_taxonomy_title_description
|
|
* @hooked genesis_do_author_title_description
|
|
* @hooked genesis_do_cpt_archive_title_description
|
|
*/
|
|
do_action( 'child_theme_hero_section' );
|
|
|
|
// Output hero section markup.
|
|
genesis_markup( array(
|
|
'close' => '</div></section>',
|
|
'context' => 'hero-section',
|
|
) );
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Adds featured image above the entry content.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function authority_featured_image() {
|
|
|
|
//$add_single_image = get_theme_mod( 'authority_single_image_setting', authority_customizer_get_default_image_setting() );
|
|
|
|
$image = genesis_get_image(
|
|
array(
|
|
'format' => 'html',
|
|
'size' => 'hero',
|
|
'context' => '',
|
|
'attr' => array(
|
|
'alt' => the_title_attribute( 'echo=0' ),
|
|
'class' => 'yeuchaybo-single-image',
|
|
),
|
|
)
|
|
);
|
|
|
|
if ( $image && is_singular( array ('post', 'event' ) ) ){
|
|
printf( '<div class="yeuchaybo-featured-image">%s</div>', $image );
|
|
}
|
|
|
|
|
|
}
|