%2$s';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
'%s',
'' . $time_string . ''
);
}
$byline = '';
if ( true === $show_meta_author ) {
$byline = sprintf(
'%s',
''
);
}
if ( ! empty( $posted_on ) ) {
echo '' . $posted_on . '';
}
if ( ! empty( $byline ) ) {
echo '';
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
$show_meta_comment = true;
if ( true === $show_meta_comment ) {
echo '';
comments_popup_link( esc_html__( 'Leave a comment', 'business-trust' ), esc_html__( '1 Comment', 'business-trust' ), esc_html__( '% Comments', 'business-trust' ) );
echo '';
}
}
}
endif;
if ( ! function_exists( 'business_trust_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
* Package twentyseventeen
* @subpackage Business Trust
*/
function business_trust_entry_footer() {
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
$show_meta_categories = true;
if ( true === $show_meta_categories ) {
/* Translators: used between list items, there is a space after the comma. */
$categories_list = get_the_category_list( esc_html__( ', ', 'business-trust' ) );
if ( $categories_list && business_trust_categorized_blog() ) {
printf( '%1$s', $categories_list );
}
}
$show_meta_tags = true;
if ( true === $show_meta_tags ) {
/* Translators: used between list items, there is a space after the comma. */
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'business-trust' ) );
if ( $tags_list ) {
printf( '', $tags_list );
}
}
}
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function business_trust_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'business_trust_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
'fields' => 'ids',
// We only need to know if there is more than one category.
'number' => 2,
) );
// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'business_trust_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so business_trust_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so business_trust_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in business_trust_categorized_blog.
*/
function business_trust_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'business_trust_categories' );
}
add_action( 'edit_category', 'business_trust_category_transient_flusher' );
add_action( 'save_post', 'business_trust_category_transient_flusher' );
if ( ! function_exists( 'business_trust_posted_on_custom' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
* Package twentyseventeen
* @subpackage Business Trust
*/
function business_trust_posted_on_custom() {
global $post;
$time_string = '';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf( '' . $time_string . ''
);
echo '' . wp_kses_post( $posted_on ) . '';
$byline = sprintf( ''
);
echo '';
}
endif;
/**
* Basic theme functions.
*
* This file contains hook functions attached to core hooks.
*
* @package Business Trust
*/
if ( ! function_exists( 'business_trust_custom_body_class' ) ) :
/**
* Custom body class
*
* @since 1.0
*
* @param string|array $input One or more classes to add to the class list.
* @return array Array of classes.
*/
function business_trust_custom_body_class( $input ) {
// Global layout.
global $post;
$page_layout = business_trust_get_option( 'page_layout' );
$page_layout = apply_filters( 'business_trust_filter_theme_page_layout', $page_layout );
// Check if single.
if ( $post && is_singular() ) {
$post_options = get_post_meta( $post->ID, 'business_trust_theme_settings', true );
if ( isset( $post_options['post_layout'] ) && ! empty( $post_options['post_layout'] ) ) {
$page_layout = $post_options['post_layout'];
}
}
$input[] = esc_attr( $page_layout );
// Add common class for sidebar enabled condition.
if ( 'no-sidebar' !== $page_layout ) {
$input[] = 'sidebar-enabled';
}
// Overlap class.
$overlap_class = 'builder-overlap';
if ( is_front_page() && 'posts' === get_option( 'show_on_front' ) ) {
$overlap_class = '';
} else if ( is_home() && ( $blog_page_id = business_trust_get_index_page_id( 'blog' ) ) > 0 ) {
// Function is_home() specific.
$disable_overlap = absint( get_post_meta( $blog_page_id, 'business-trust-disable-overlap', true ) );
if ( 1 === $disable_overlap ) {
$overlap_class = '';
}
} else if ( $post ) {
// Post specific.
$disable_overlap = absint( get_post_meta( $post->ID, 'business-trust-disable-overlap', true ) );
if ( 1 === $disable_overlap ) {
$overlap_class = '';
}
}
if ( ! empty( $overlap_class ) ) {
$input[] = $overlap_class;
} else {
$input[] = 'builder-overlap-disabled';
}
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$input[] = 'group-blog';
}
// Add a class for typography
$typography = ( ( business_trust_get_option( 'theme_typography' ) ) == 'default' ) ? '' : ( business_trust_get_option( 'theme_typography' ) );
$input[] = esc_attr( $typography );
$body_typography = ( ( business_trust_get_option( 'body_theme_typography' ) ) == 'default' ) ? '' : ( business_trust_get_option( 'body_theme_typography' ) );
$input[] = esc_attr( $body_typography );
return $input;
}
endif;
add_filter( 'body_class', 'business_trust_custom_body_class' );
if ( ! function_exists( 'business_trust_featured_image_instruction' ) ) :
/**
* Message to show in the Featured Image Meta box.
*
* @since 1.0
*
* @param string $content Admin post thumbnail HTML markup.
* @param int $post_id Post ID.
* @return string HTML.
*/
function business_trust_featured_image_instruction( $content, $post_id ) {
$allowed = array( 'post' );
if ( in_array( get_post_type( $post_id ), $allowed ) ) {
$content .= '' . __( 'Recommended Image Size', 'business-trust' ) . ':
';
$content .= __( 'Banner Image', 'business-trust' ) . ' : 800px X 600px';
}
return $content;
}
endif;
add_filter( 'admin_post_thumbnail_html', 'business_trust_featured_image_instruction', 10, 2 );
if ( ! function_exists( 'business_trust_custom_content_width' ) ) :
/**
* Custom content width.
*
* @since 1.0
*/
function business_trust_custom_content_width() {
global $post, $content_width;
$page_layout = business_trust_get_option( 'page_layout' );
$page_layout = apply_filters( 'business_trust_filter_theme_page_layout', $page_layout );
// Check if single.
if ( $post && is_singular() ) {
$post_options = get_post_meta( $post->ID, 'business_trust_theme_settings', true );
if ( isset( $post_options['post_layout'] ) && ! empty( $post_options['post_layout'] ) ) {
$page_layout = esc_attr( $post_options['post_layout'] );
}
}
switch ( $page_layout ) {
case 'no-sidebar':
$content_width = 1170;
break;
case 'left-sidebar':
case 'right-sidebar':
$content_width = 900;
break;
default:
break;
}
}
endif;
add_action( 'template_redirect', 'business_trust_custom_content_width' );
/**
* Custom theme functions.
*
* This file contains hook functions attached to theme hooks.
*
* @package Business Trust
*/
if ( ! function_exists( 'business_trust_add_sidebar' ) ) :
/**
* Add sidebar.
*
* @since 1.0
*/
function business_trust_add_sidebar() {
global $post;
$page_layout = business_trust_get_option( 'page_layout' );
$page_layout = apply_filters( 'business_trust_filter_theme_page_layout', $page_layout );
// Check if single.
if ( $post && is_singular() ) {
$post_options = get_post_meta( $post->ID, 'business_trust_theme_settings', true );
if ( isset( $post_options['post_layout'] ) && ! empty( $post_options['post_layout'] ) ) {
$page_layout = $post_options['post_layout'];
}
}
// Include primary sidebar.
if ( 'no-sidebar' !== $page_layout ) {
get_sidebar();
}
}
endif;
add_action( 'business_trust_main_sidebar', 'business_trust_add_sidebar' );
if ( ! function_exists( 'business_trust_custom_posts_navigation' ) ) :
/**
* Posts navigation.
*
* @since 1.0
*/
function business_trust_custom_posts_navigation() {
$pagination_type = business_trust_get_option( 'pagination_type' );
switch ( $pagination_type ) {
case 'default':
the_posts_navigation();
break;
case 'numeric':
the_posts_pagination();
break;
default:
break;
}
}
endif;
add_action( 'business_trust_action_posts_navigation', 'business_trust_custom_posts_navigation' );
if ( ! function_exists( 'business_trust_add_post_image' ) ) :
/**
* Add image in single post.
*
* @since 1.0
*/
function business_trust_add_post_image() {
global $post;
// Bail if current post is built with Page Builder.
if ( true === business_trust_content_is_pagebuilder() ) {
return;
}
// Bail if checkbox Use Featured Image as Banner is enabled.
$values = get_post_meta( $post->ID, 'business_trust_theme_settings', true );
if ( isset( $values['use_featured_image_as_banner'] ) && 1 === absint( $values['use_featured_image_as_banner'] ) ) {
return;
}
if ( has_post_thumbnail() ) {
$values = get_post_meta( $post->ID, 'business_trust_theme_settings', true );
$single_image = isset( $values['single_image'] ) ? esc_attr( $values['single_image'] ) : '';
if ( ! $single_image ) {
$single_image = business_trust_get_option( 'single_image' );
}
if ( 'disable' !== $single_image ) {
$args = array(
'class' => 'aligncenter',
);
the_post_thumbnail( esc_attr( $single_image ), $args );
}
}
}
endif;
add_action( 'business_trust_single_image', 'business_trust_add_post_image' );
if( ! function_exists( 'business_trust_check_custom_header_status' ) ) :
/**
* Check status of custom header.
*
* @since 1.0
*/
function business_trust_check_custom_header_status( $input ) {
global $post;
if ( is_front_page() && 'posts' === get_option( 'show_on_front' ) ) {
$input = false;
}
else if ( is_home() && ( $blog_page_id = business_trust_get_index_page_id( 'blog' ) ) > 0 ) {
$values = get_post_meta( $blog_page_id, 'business_trust_theme_settings', true );
$disable_banner_area = isset( $values['disable_banner_area'] ) ? absint( $values['disable_banner_area'] ) : 0;
if ( 1 === $disable_banner_area ) {
$input = false;
}
}
else if ( $post ) {
if ( is_singular() ) {
$values = get_post_meta( $post->ID, 'business_trust_theme_settings', true );
$disable_banner_area = isset( $values['disable_banner_area'] ) ? absint( $values['disable_banner_area'] ) : 0;
if ( 1 === $disable_banner_area ) {
$input = false;
}
}
}
return $input;
}
endif;
add_filter( 'business_trust_filter_custom_header_status', 'business_trust_check_custom_header_status' );
if ( ! function_exists( 'business_trust_customize_page_title' ) ) :
/**
* Add title in Custom Header.
*
* @since 1.0
*
* @param string $title Title.
* @return string Modified title.
*/
function business_trust_customize_page_title( $title ) {
if ( is_home() && ( $blog_page_id = business_trust_get_index_page_id( 'blog' ) ) > 0 ) {
$title = get_the_title( $blog_page_id );
}
elseif ( is_singular() ) {
$title = get_the_title();
}
elseif ( is_archive() ) {
$title = strip_tags( get_the_archive_title() );
}
elseif ( is_search() ) {
/* translators: %s: search query input */
$title = sprintf( __( 'Search Results for: %s', 'business-trust' ), get_search_query() );
}
elseif ( is_404() ) {
$title = __( '404!', 'business-trust' );
}
return $title;
}
endif;
add_filter( 'business_trust_filter_custom_page_title', 'business_trust_customize_page_title' );
if ( ! function_exists( 'business_trust_add_image_in_custom_header' ) ) :
/**
* Add image in Custom Header.
*
* @since 1.0
*/
function business_trust_add_image_in_custom_header( $input ) {
$image_details = array();
// For is_home().
if ( is_home() && ( $blog_page_id = business_trust_get_index_page_id( 'blog' ) ) > 0 ) {
$values = get_post_meta( $blog_page_id, 'business_trust_theme_settings', true );
$use_featured_image_as_banner = isset( $values['use_featured_image_as_banner'] ) ? absint( $values['use_featured_image_as_banner'] ) : 0;
if ( 1 === $use_featured_image_as_banner ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $blog_page_id ), 'business-trust-featured-banner' );
if ( ! empty( $image ) ) {
$image_details['url'] = $image[0];
$image_details['width'] = $image[1];
$image_details['height'] = $image[2];
}
}
}
// Fetch image info if singular.
else if ( is_singular() ) {
global $post;
$values = get_post_meta( $post->ID, 'business_trust_theme_settings', true );
$use_featured_image_as_banner = isset( $values['use_featured_image_as_banner'] ) ? absint( $values['use_featured_image_as_banner'] ) : 0;
if ( 1 === $use_featured_image_as_banner ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'business-trust-featured-banner' );
if ( ! empty( $image ) ) {
$image_details['url'] = $image[0];
$image_details['width'] = $image[1];
$image_details['height'] = $image[2];
}
}
}
if ( empty( $image_details ) ) {
// Fetch from Custom Header Image.
$image = get_header_image();
if ( ! empty( $image ) ) {
$image_details['url'] = $image;
$image_details['width'] = get_custom_header()->width;
$image_details['height'] = get_custom_header()->height;
}
}
if ( ! empty( $image_details ) ) {
$input .= 'background-image:url(' . esc_url( $image_details['url'] ) . ');';
$input .= 'background-size:cover;';
}
return $input;
}
endif;
add_filter( 'business_trust_filter_custom_header_style_attribute', 'business_trust_add_image_in_custom_header' );
function business_trust_add_menu_parent_class( $items ) {
$parents = array();
foreach ( $items as $item ) {
//Check if the item is a parent item
if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
$parents[] = $item->menu_item_parent;
}
}
foreach ( $items as $item ) {
if ( in_array( $item->ID, $parents ) ) {
//Add "dropdown" class to parents
$item->classes[] = 'dropdown';
}
}
return $items;
}
/**
* Excerpt.
*/
if ( ! function_exists( 'business_trust_excerpt_length' ) ) :
/**
* excerpt length.
*
* @param int $length in words.
*
*/
function business_trust_excerpt_length( $length ) {
if ( is_admin() ) {
return $length;
}
$length = business_trust_get_option( 'excerpt_length' );
$length = ! empty( $length ) ? $length : '25';
return $length;
}
endif;
add_filter( 'excerpt_length', 'business_trust_excerpt_length', 999 );
if( ! function_exists( 'business_trust_excerpt_more' ) ) :
/**
* @param string $more.
*
* Return string
*/
function business_trust_excerpt_more( $more ) {
if ( is_admin() ) {
return $more;
}
/* translators: %s: post title */
$more = sprintf( __( ' "%s"', 'business-trust' ), get_the_title( get_the_ID() ) );
return ' … ' . $more;
}
endif;
add_filter('excerpt_more', 'business_trust_excerpt_more');
/**
* Get sidebar options.
*/
if ( ! function_exists( 'business_trust_get_sidebar_options' ) ) :
function business_trust_get_sidebar_options() {
global $wp_registered_sidebars;
$output = array();
if ( ! empty( $wp_registered_sidebars ) && is_array( $wp_registered_sidebars ) ) {
foreach ( $wp_registered_sidebars as $key => $sidebar ) {
$output[ $key ] = $sidebar['name'];
}
}
return $output;
}
endif;
if ( ! function_exists( 'business_trust_get_index_page_id' ) ) :
/**
* Get front index page ID.
*
* @param string $type Type.
* @return int Corresponding Page ID.
*/
function business_trust_get_index_page_id( $type = 'front' ) {
$page = '';
switch ( $type ) {
case 'front':
$page = get_option( 'page_on_front' );
break;
case 'blog':
$page = get_option( 'page_for_posts' );
break;
default:
break;
}
$page = absint( $page );
return $page;
}
endif;
if ( ! function_exists( 'business_trust_content_is_pagebuilder' ) ) :
/**
* SiteOrigin Page Builder Content Check.
*
* Conditionally check if the current page/post was created with
* the SiteOrigin Page Builder editor.
*
* @return bool True if builder page.
*/
function business_trust_content_is_pagebuilder() {
global $post;
// Consider empty content the WP editor.
if ( empty( $post ) ) {
return false;
}
// Does pagebuilder content exist in custom fields?
$panels_data = get_post_meta( $post->ID, 'panels_data', true );
return ( empty( $panels_data ) ) ? false : true;
}
endif;
if ( ! function_exists( 'business_trust_the_custom_logo' ) ) :
/**
* Render logo.
*/
function business_trust_the_custom_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
endif;
if ( ! function_exists( 'business_trust_add_author_bio_in_single' ) ) :
/**
* Display Author bio.
*
* @since 1.0
*/
function business_trust_add_author_bio_in_single() {
if ( is_singular( 'post' ) ) {
global $post;
if ( get_the_author_meta( 'description', $post->post_author ) ) {
get_template_part( 'template-parts/author-bio', 'single' );
}
}
}
endif;
add_action( 'business_trust_author_bio', 'business_trust_add_author_bio_in_single' );
if ( ! function_exists( 'business_trust_primary_navigation_fallback' ) ) :
/**
* Fallback for primary navigation.
*
* @since 1.0
*/
function business_trust_primary_navigation_fallback() {
echo '