__( 'Right Sidebar', 'shesha' ),
'sidebar-2' => __( 'Left Sidebar', 'shesha' ),
'header' => __( 'Header', 'shesha' ),
'footer-1' => __( 'Footer Widget 1', 'shesha' ),
'footer-2' => __( 'Footer Widget 2', 'shesha' ),
'footer-3' => __( 'Footer Widget 3', 'shesha' ),
'footer-4' => __( 'Footer Widget 4', 'shesha' ),
'footer-5' => __( 'Footer Widget 5', 'shesha' ),
'footer-bar' => __( 'Footer Bar','shesha' ),
'top-bar' => __( 'Top Bar','shesha' ),
);
foreach ( $widgets as $id => $name ) {
register_sidebar( array(
'name' => $name,
'id' => $id,
'before_widget' => '',
'before_title' => apply_filters( 'shesha_start_widget_title', '
' ),
) );
}
}
}
if ( ! function_exists( 'shesha_smart_content_width' ) ) {
add_action( 'wp', 'shesha_smart_content_width' );
/**
* Set the $content_width depending on layout of current page
* Hook into "wp" so we have the correct layout setting from shesha_get_layout()
* Hooking into "after_setup_theme" doesn't get the correct layout setting
*/
function shesha_smart_content_width() {
global $content_width;
$container_width = shesha_get_setting( 'container_width' );
$right_sidebar_width = apply_filters( 'shesha_right_sidebar_width', '25' );
$left_sidebar_width = apply_filters( 'shesha_left_sidebar_width', '25' );
$layout = shesha_get_layout();
if ( 'left-sidebar' == $layout ) {
$content_width = $container_width * ( ( 100 - $left_sidebar_width ) / 100 );
} elseif ( 'right-sidebar' == $layout ) {
$content_width = $container_width * ( ( 100 - $right_sidebar_width ) / 100 );
} elseif ( 'no-sidebar' == $layout ) {
$content_width = $container_width;
} else {
$content_width = $container_width * ( ( 100 - ( $left_sidebar_width + $right_sidebar_width ) ) / 100 );
}
}
}
if ( ! function_exists( 'shesha_page_menu_args' ) ) {
add_filter( 'wp_page_menu_args', 'shesha_page_menu_args' );
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*
*
* @param array $args The existing menu args.
* @return array Menu args.
*/
function shesha_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
}
if ( ! function_exists( 'shesha_disable_title' ) ) {
add_filter( 'shesha_show_title', 'shesha_disable_title' );
/**
* Remove our title if set.
*
*
* @return bool Whether to display the content title.
*/
function shesha_disable_title() {
global $post;
$disable_headline = ( isset( $post ) ) ? get_post_meta( $post->ID, '_shesha-disable-headline', true ) : '';
if ( ! empty( $disable_headline ) && false !== $disable_headline ) {
return false;
}
return true;
}
}
if ( ! function_exists( 'shesha_resource_hints' ) ) {
add_filter( 'wp_resource_hints', 'shesha_resource_hints', 10, 2 );
/**
* Add resource hints to our Google fonts call.
*
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed.
* @return array $urls URLs to print for resource hints.
*/
function shesha_resource_hints( $urls, $relation_type ) {
if ( wp_style_is( 'shesha-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
$urls[] = array(
'href' => 'https://fonts.gstatic.com',
'crossorigin',
);
} else {
$urls[] = 'https://fonts.gstatic.com';
}
}
return $urls;
}
}
if ( ! function_exists( 'shesha_remove_caption_padding' ) ) {
add_filter( 'img_caption_shortcode_width', 'shesha_remove_caption_padding' );
/**
* Remove WordPress's default padding on images with captions
*
* @param int $width Default WP .wp-caption width (image width + 10px)
* @return int Updated width to remove 10px padding
*/
function shesha_remove_caption_padding( $width ) {
return $width - 10;
}
}
if ( ! function_exists( 'shesha_enhanced_image_navigation' ) ) {
add_filter( 'attachment_link', 'shesha_enhanced_image_navigation', 10, 2 );
/**
* Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
*/
function shesha_enhanced_image_navigation( $url, $id ) {
if ( ! is_attachment() && ! wp_attachment_is_image( $id ) ) {
return $url;
}
$image = get_post( $id );
if ( ! empty( $image->post_parent ) && $image->post_parent != $id ) {
$url .= '#main';
}
return $url;
}
}
if ( ! function_exists( 'shesha_categorized_blog' ) ) {
/**
* Determine whether blog/site has more than one category.
*
*
* @return bool True of there is more than one category, false otherwise.
*/
function shesha_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'shesha_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
'fields' => 'ids',
'hide_empty' => 1,
// 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( 'shesha_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so twentyfifteen_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so twentyfifteen_categorized_blog should return false.
return false;
}
}
}
if ( ! function_exists( 'shesha_category_transient_flusher' ) ) {
add_action( 'edit_category', 'shesha_category_transient_flusher' );
add_action( 'save_post', 'shesha_category_transient_flusher' );
/**
* Flush out the transients used in {@see shesha_categorized_blog()}.
*
*/
function shesha_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'shesha_categories' );
}
}
add_filter( 'shesha_fontawesome_essentials', 'shesha_set_font_awesome_essentials' );
/**
* Check to see if we should include the full Font Awesome library or not.
*
*
* @param bool $essentials
* @return bool
*/
function shesha_set_font_awesome_essentials( $essentials ) {
if ( shesha_get_setting( 'font_awesome_essentials' ) ) {
return true;
}
return $essentials;
}