$font ):
if ( $slug != 'system' && $slug != 'system-font-wordpress-default' ):
$key = sanitize_title_with_dashes( $font['family'] );
$bx_font_simple_array[$key] = esc_html( $font['family'] );
$bx_font_array[$key]['family'] = esc_html( $font['family'] );
$bx_font_array[$key]['variants'] = $font['variants'];
endif;
endforeach;
set_transient( 'bx_google_fonts', $bx_font_array, 86400 );
if ( $type == 'simple' ):
return $bx_font_simple_array;
else:
return $bx_font_array;
endif;
endif;
return $bx_font_array;
}
// get_header_image_tag callback
function bx_get_header_image_tag( $html, $header, $attr ) {
return '
';
};
add_filter( 'get_header_image_tag', 'bx_get_header_image_tag', 10, 3 );
function bx_get_custom_logo( $html, $blog_id ){
$html = '';
$switched_blog = false;
if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
switch_to_blog( $blog_id );
$switched_blog = true;
}
$custom_logo_id = get_theme_mod( 'custom_logo' );
// We have a logo. Logo is go.
if ( $custom_logo_id ) {
$logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
$logo_height = $logo[2] / 2; $logo_pos = $logo_height / 2;
$html = sprintf( '%2$s',
esc_url( home_url( '/' ) ),
wp_get_attachment_image( $custom_logo_id, 'full', false, array(
'class' => 'custom-logo',
'itemprop' => 'logo',
) )
);
}
// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
elseif ( is_customize_preview() ) {
$html = '';
$html = sprintf( '
',
esc_url( home_url( '/' ) )
);
}
if ( $switched_blog ) {
restore_current_blog();
}
return $html;
}
add_filter( 'get_custom_logo', 'bx_get_custom_logo', 10, 2 );
/**
* Header Markup (to support WP 4.6 and lower)
*/
function bx_custom_header_markup(){
if ( get_header_image() ):
$custom_markup = '';
return $custom_markup;
else:
return false;
endif;
}
/**
* Theme Path DIR (_theme)
*/
function bx_theme_file_path( $file_path ){
if ( function_exists('get_theme_file_path') ):
return get_theme_file_path( '_theme/' . $file_path );
else:
return BX_THEME_DIR . $file_path;
endif;
}
/**
* Theme Path DIR (_theme)
*/
function bx_fw_file_path( $file_path ){
if ( function_exists('get_theme_file_path') ):
return get_theme_file_path( '_framework/' . $file_path );
else:
return BX_FW_DIR . $file_path;
endif;
}
/**
* Theme Path URL (_theme)
*/
function bx_theme_file_uri( $file_path ){
if ( function_exists('get_theme_file_uri') ):
return get_theme_file_uri( '_theme/' . $file_path );
else:
return BX_THEME_URL . $file_path;
endif;
}
/**
* Framework Path URL (_framework)
*/
function bx_fw_file_uri( $file_path ){
if ( function_exists('get_theme_file_uri') ):
return get_theme_file_uri( '_framework/' . $file_path );
else:
return BX_FW_URL . $file_path;
endif;
}
/**
* Social Icons
*/
function bx_social_icons() {
global $bx_options;
foreach ( $bx_options as $id => $value ):
if ( $value && strpos($id, 'bx_socials') !== false ):
$id = explode( '_', $id );
$id = $id[2];
echo '';
endif;
endforeach;
}
/**
* Add Item to Menu
*/
function bx_custom_nav_menu_item( $title, $url, $order = 0, $parent = 0, $classes = array() ){
$item = new stdClass();
$item->ID = 1000000 + $order + $parent;
$item->db_id = $item->ID;
$item->title = $title;
$item->url = $url;
$item->menu_order = $order;
$item->menu_item_parent = $parent;
$item->type = '';
$item->object = '';
$item->object_id = '';
$item->classes = $classes;
$item->target = '';
$item->attr_title = '';
$item->description = '';
$item->xfn = '';
$item->status = '';
return $item;
}
/**
* Post Thumbnail
*/
function bx_post_thumbnail( $thumb_name = false ){
$thumb_name = !$thumb_name ? 'post-thumbnail' : $thumb_name;
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
ob_start();
the_post_thumbnail( $thumb_name, array( 'title' => the_title_attribute( 'echo=0' ) ) );
return ob_get_clean();
}
/**
* Post Thumbnail URL
*/
function bx_post_thumbnail_url( $thumb_name = false ){
$thumb_name = !$thumb_name ? 'post-thumbnail' : $thumb_name;
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
$thumbnail_url = get_the_post_thumbnail_url( null, $thumb_name );
return $thumbnail_url;
}
/**
* Breadcrumbs
*/
function bx_breadcrumbs() {
// Get the query & post information
global $post,$wp_query,$bx_options;
if ( !empty($post) ):
$bx_page_settings = get_post_meta( $post->ID, '_boxytheme_page_settings', true);
else:
$bx_page_settings = false;
endif;
$default_option = ( isset( $bx_options['boxytheme_breadcrumbs'] ) ? $bx_options['boxytheme_breadcrumbs'] : 'enabled' );
$crumbs_setting = apply_filters( 'boxy_crumbs_setting', ( isset( $bx_page_settings['breadcrumbs'] ) && $bx_page_settings['breadcrumbs'] ? $bx_page_settings['breadcrumbs'] : false ), $post->ID );
if ( $crumbs_setting == 'enabled' || !$crumbs_setting && $default_option == 'enabled' ):
// Settings
$separator = '';
$breadcrums_id = 'bx-breadcrumbs';
$breadcrums_class = 'bx-breadcrumbs';
$home_title = esc_html_x('Home','Home Breadcrumb','boxy-studio');
// If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat)
$custom_taxonomy = 'product_cat';
// Build the breadcrums
echo '';
// Home page
echo '- ' . $home_title . '
';
echo '- ' . $separator . '
';
if ( is_archive() && !is_tax() && !is_category() && !is_tag() ) {
//echo '- ' . post_type_archive_title(false,false) . '
';
} else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) {
// If post is a custom post type
$post_type = get_post_type();
// If it is a custom post type display name and link
if($post_type != 'post') {
$post_type_object = get_post_type_object($post_type);
$post_type_archive = get_post_type_archive_link($post_type);
echo '- ' . $post_type_object->labels->name . '
';
echo '- ' . $separator . '
';
}
$custom_tax_name = get_queried_object()->name;
//echo '- ' . $custom_tax_name . '
';
} else if ( is_single() ) {
// If post is a custom post type
$post_type = get_post_type();
// If it is a custom post type display name and link
if($post_type != 'post') {
$post_type_object = get_post_type_object($post_type);
$post_type_archive = get_post_type_archive_link($post_type);
echo '- ' . $post_type_object->labels->name . '
';
echo '- ' . $separator . '
';
}
// Get post category info
$category = get_the_category();
if(!empty($category)) {
// Get last category post is in
$cat_array_vals = array_values($category);
$last_category = end( $cat_array_vals );
// Get parent any categories and create array
$get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','),',');
$cat_parents = explode(',',$get_cat_parents);
// Loop through parent categories and store in variable $cat_display
$cat_display = '';
foreach($cat_parents as $parents) {
$cat_display .= '- ' . $parents . '
';
$cat_display .= '- ' . $separator . '
';
}
}
// If it's a custom post type within a custom taxonomy
$taxonomy_exists = taxonomy_exists($custom_taxonomy);
if(empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) {
$taxonomy_terms = get_the_terms( $post->ID, $custom_taxonomy );
if ( $taxonomy_terms ):
$cat_id = $taxonomy_terms[0]->term_id;
$cat_nicename = $taxonomy_terms[0]->slug;
$cat_link = get_term_link($taxonomy_terms[0]->term_id, $custom_taxonomy);
$cat_name = $taxonomy_terms[0]->name;
endif;
}
// Check if the post is in a category
if(!empty($last_category)) {
echo $cat_display;
//echo '- ' . get_the_title() . '
';
// Else if post is in a custom taxonomy
} else if(!empty($cat_id)) {
echo '- ' . $cat_name . '
';
echo '- ' . $separator . '
';
//echo '- ' . get_the_title() . '
';
} else {
//echo '- ' . get_the_title() . '
';
}
} else if ( is_category() ) {
// Category page
//echo '- ' . single_cat_title('', false) . '
';
} else if ( is_page() ) {
// Standard page
if( $post->post_parent ){
// If child page, get parents
$anc = get_post_ancestors( $post->ID );
// Get parents in the right order
$anc = array_reverse($anc);
// Parent page loop
if ( !isset( $parents ) ) $parents = null;
foreach ( $anc as $ancestor ) {
$parents .= '- ' . get_the_title($ancestor) . '
';
$parents .= '- ' . $separator . '
';
}
// Display parent pages
echo $parents;
// Current page
//echo '- ' . get_the_title() . '
';
} else {
// Just display current page if not parents
//echo '- ' . get_the_title() . '
';
}
} else if ( is_tag() ) {
// Tag page
// Get tag information
$term_id = get_query_var('tag_id');
$taxonomy = 'post_tag';
$args = 'include=' . $term_id;
$terms = get_terms( $taxonomy, $args );
$get_term_id = $terms[0]->term_id;
$get_term_slug = $terms[0]->slug;
$get_term_name = $terms[0]->name;
// Display the tag name
//echo '- ' . $get_term_name . '
';
} elseif ( is_day() ) {
// Day archive
// Year link
echo '- ' . sprintf( esc_html__( '%s Archives', 'boxy-studio' ), get_the_time('Y') ) . '
';
echo '- ' . $separator . '
';
// Month link
echo '- ' . sprintf( esc_html__( '%s Archives', 'boxy-studio' ), get_the_time('M') ) . '
';
echo '- ' . $separator . '
';
// Day display
// echo '- ' . sprintf( esc_html__( '%s Archives', 'boxy-studio' ), get_the_time('jS') . ' ' . get_the_time('M') ) . '
';
} else if ( is_month() ) {
// Month Archive
// Year link
echo '- ' . sprintf( esc_html__( '%s Archives', 'boxy-studio' ), get_the_time('Y') ) . '
';
echo '- ' . $separator . '
';
// Month display
echo '- ' . sprintf( esc_html__( '%s Archives', 'boxy-studio' ), get_the_time('M') ) . '
';
} else if ( is_year() ) {
// Display year archive
//echo '- ' . sprintf( esc_html__( '%s Archives', 'boxy-studio' ), get_the_time('Y') ) . '
';
} else if ( is_author() ) {
// Auhor archive
// Get the author information
global $author;
$userdata = get_userdata( $author );
// Display author name
//echo '- ' . sprintf( esc_html__( 'Author: %s', 'boxy-studio' ), $userdata->display_name ) . '
';
} else if ( get_query_var('paged') ) {
// Paginated archives
//echo '- ' . sprintf( esc_html__( 'Page %s', 'boxy-studio' ), get_query_var('paged') ) . '
';
} else if ( is_search() ) {
// Search results page
echo '- ' . sprintf( esc_html__( 'Search results for: "%s"', 'boxy-studio' ), get_search_query() ) . '
';
} elseif ( is_404() ) {
// 404 page
}
echo '
';
endif;
return false;
}
function bx_comments(){
if ( comments_open() || get_comments_number() ) {
comments_template();
the_comments_pagination();
}
}