';
}
}
add_action( 'wp_head', 'hero_pingback_header' );
if ( ! function_exists( 'hero_title' ) ) :
/**
* Customize header title.
*
* @since 1.0.0
*
* @param string $title Title.
* @return string Modified title.
*/
function hero_title( $title ) {
if ( is_home() ) {
$title = get_theme_mod('hero_blog_title');
} elseif ( is_singular() ) {
$title = single_post_title( '', false );
} elseif ( is_category() || is_tag() ) {
$title = single_term_title( '', false );
} elseif ( is_archive() ) {
$title = strip_tags( get_the_archive_title() );
} elseif ( is_search() ) {
$title = sprintf( esc_html__( 'Search Results for: %s', 'hero' ), get_search_query() );
} elseif ( is_404() ) {
$title = esc_html__( '404!', 'hero' );
}
return $title;
}
endif;
add_filter( 'hero_filter_title', 'hero_title' );
if ( ! function_exists( 'hero_excerpt_length' ) ) :
/**
* hero Excerpt Length
*
* @since hero 1.0
*/
function hero_excerpt_length( $length ) {
if ( ! is_admin() ) {
return 30;
}
}
endif;
add_filter( 'excerpt_length', 'hero_excerpt_length' );
function hero_auto_excerpt_more( $more ) {
if ( ! is_admin() ) {
return ' …' ;
}
}
add_filter( 'excerpt_more', 'hero_auto_excerpt_more' );
if ( ! function_exists( 'hero_primary_navigation_fallback' ) ) :
/**
* Fallback for primary navigation.
*
* @since 1.0.0
*/
function hero_primary_navigation_fallback() {
echo '
';
echo '- ' . esc_html__( 'Home', 'hero' ) . '
';
$args = array(
'posts_per_page' => 5,
'post_type' => 'page',
'orderby' => 'name',
'order' => 'ASC',
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
the_title( '- ', '
' );
}
wp_reset_postdata();
}
echo '
';
}
endif;
if ( ! function_exists( 'hero_get_the_excerpt' ) ) :
/**
* Fetch excerpt from the post.
*
* @since 1.0.0
*
* @param int $length Excerpt length.
* @param WP_Post $post_object WP_Post instance.
* @return string Excerpt content.
*/
function hero_get_the_excerpt( $length, $post_object = null ) {
global $post;
if ( is_null( $post_object ) ) {
$post_object = $post;
}
$length = absint( $length );
if ( 0 === $length ) {
return;
}
$source_content = $post_object->post_content;
if ( ! empty( $post_object->post_excerpt ) ) {
$source_content = $post_object->post_excerpt;
}
$source_content = strip_shortcodes( $source_content );
$trimmed_content = wp_trim_words( $source_content, $length, '…' );
return $trimmed_content;
}
endif;
if ( ! function_exists( 'hero_helper_the_excerpt' ) ) :
/**
* Generate excerpt.
*
* @since 1.0.0
*
* @param int $length Excerpt length in words.
* @param WP_Post $post_obj WP_Post instance (Optional).
* @return string Excerpt.
*/
function hero_helper_the_excerpt( $length = 40, $post_obj = null ) {
global $post;
if ( is_null( $post_obj ) ) {
$post_obj = $post;
}
$length = absint( $length );
if ( $length < 1 ) {
$length = 40;
}
$source_content = $post_obj->post_content;
if ( ! empty( $post_obj->post_excerpt ) ) {
$source_content = $post_obj->post_excerpt;
}
$source_content = preg_replace( '`\[[^\]]*\]`', '', $source_content );
$trimmed_content = wp_trim_words( $source_content, $length, '...' );
return $trimmed_content;
}
endif;
if( !function_exists('hero_home_section') ){
function hero_home_section(){
$defaults = apply_filters('hero_home_sections',
array(
'hero_sliderbar_section',
'hero_about_section'
)
);
$sections = get_theme_mod('hero_frontpage_sections', $defaults);
return $sections;
}
}