'with-sidebar',
'main' => 'column-main',
'aside' => 'column-aside',
);
//SUPPORTED PLUGINS START
//check for WooCommerce
if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) :
if ( is_product() ) {
$exs_shop_sidebar_position_option = exs_option( 'product_sidebar_position', 'right' );
}
if ( is_shop() || is_product_taxonomy() ) {
$exs_shop_sidebar_position_option = exs_option( 'shop_sidebar_position', 'right' );
}
//if empty sidebar or disabled in customizer - removing aside
if ( ! is_active_sidebar( 'shop' ) || 'no' === $exs_shop_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
} //is_active_sidebar( 'shop' )
//left sidebar
if ( 'left' === $exs_shop_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
return $exs_return;
//default - right sidebar
} else {
return $exs_return;
}
endif; //is_woocommerce()
//check for EDD
//only for single product for now
if ( is_singular( 'download' ) ) {
return $exs_return;
}
//EDD downloads archive
if ( exs_is_downloads() ) :
$exs_downloads_sidebar_position_option = exs_option( 'downloads_sidebar_position', '' );
//if empty sidebar or disabled in customizer - removing aside
if ( ! is_active_sidebar( 'sidebar-downloads' ) || 'no' === $exs_downloads_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
} //is_active_sidebar( 'sidebar-downloads' )
//left sidebar
if ( 'left' === $exs_downloads_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
return $exs_return;
//default - right sidebar
} else {
return $exs_return;
}
endif; //EDD downloads archive
//bbPress
if ( exs_is_bbpress() ) :
$exs_bbpress_sidebar_position_option = exs_option( 'bbpress_sidebar_position', '' );
//if empty sidebar or disabled in customizer - removing aside
if ( ! is_active_sidebar( 'sidebar-bbpress' ) || 'no' === $exs_bbpress_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
} //is_active_sidebar( 'sidebar-bbpress' )
//if is page and one of page templates without sidebar is used:
//pages
if ( is_page() ) {
//no sidebar
if (
exs_check_is_page_has_sidebar()
) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
}
}//is_page()
//left sidebar
if ( 'left' === $exs_bbpress_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
return $exs_return;
//default - right sidebar
} else {
return $exs_return;
}
endif; //bbPress
//BuddyPress
if ( exs_is_buddypress() ) :
$exs_buddypress_sidebar_position_option = exs_option( 'buddypress_sidebar_position', '' );
//if empty sidebar or disabled in customizer - removing aside
if ( ! is_active_sidebar( 'sidebar-buddypress' ) || 'no' === $exs_buddypress_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
} //is_active_sidebar( 'sidebar-buddypress' )
//if is page and one of page templates without sidebar is used:
//pages
if ( is_page() ) {
//no sidebar
if (
exs_check_is_page_has_sidebar()
) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
}
}//is_page()
//left sidebar
if ( 'left' === $exs_buddypress_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
return $exs_return;
//default - right sidebar
} else {
return $exs_return;
}
endif; //BuddyPress
//WP Job Manager
if ( exs_is_wpjm() ) :
$exs_wpjm_sidebar_position_option = exs_option( 'wpjm_sidebar_position', '' );
//if empty sidebar or disabled in customizer - removing aside
if ( ! is_active_sidebar( 'sidebar-wpjm' ) || 'no' === $exs_wpjm_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
} //is_active_sidebar( 'sidebar-wpjm' )
//if is page and one of page templates without sidebar is used:
//pages
if ( is_page() ) {
//no sidebar
if (
exs_check_is_page_has_sidebar()
) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
}
}//is_page()
//left sidebar
if ( 'left' === $exs_wpjm_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
return $exs_return;
//default - right sidebar
} else {
return $exs_return;
}
endif; //WP Job Manager
//The Events Calendar
if ( exs_is_events() ) :
$exs_events_sidebar_position_option = is_singular() ? exs_option( 'event_sidebar_position', '' ) : exs_option( 'events_sidebar_position', '' );
//if empty sidebar or disabled in customizer - removing aside
if ( ! is_active_sidebar( 'sidebar-events' ) || 'no' === $exs_events_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
} //is_active_sidebar( 'sidebar-events' )
//if is page and one of page templates without sidebar is used:
//pages
if ( is_page() ) {
//no sidebar
if (
exs_check_is_page_has_sidebar()
) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
}
}//is_page()
//left sidebar
if ( 'left' === $exs_events_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
return $exs_return;
//default - right sidebar
} else {
return $exs_return;
}
endif; //The Events Calendar
//LearnPress Archive
if ( exs_is_learnpress_archive() ) :
$exs_courses_sidebar_position_option = exs_option( 'courses_sidebar_position', '' );
//if empty sidebar or disabled in customizer - removing aside
if ( ! is_active_sidebar( 'sidebar-courses' ) || 'no' === $exs_courses_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
} //is_active_sidebar( 'sidebar-courses' )
//if is page and one of page templates without sidebar is used:
//pages
if ( is_page() ) {
//no sidebar
if (
exs_check_is_page_has_sidebar()
) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
}
}//is_page()
//left sidebar
if ( 'left' === $exs_courses_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
return $exs_return;
//default - right sidebar
} else {
return $exs_return;
}
endif; //exs_is_learnpress_archive
//LearnPress Course
if ( exs_is_learnpress_course() ) :
$exs_course_sidebar_position_option = exs_option( 'course_sidebar_position', '' );
//if empty sidebar or disabled in customizer - removing aside
if ( ! is_active_sidebar( 'sidebar-course' ) || 'no' === $exs_course_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
} //is_active_sidebar( 'sidebar-course' )
//if is page and one of page templates without sidebar is used:
//pages
if ( is_page() ) {
//no sidebar
if (
exs_check_is_page_has_sidebar()
) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
}
}//is_page()
//left sidebar
if ( 'left' === $exs_course_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
return $exs_return;
//default - right sidebar
} else {
return $exs_return;
}
endif; //exs_is_learnpress_archive
//SUPPORTED PLUGINS END
//if category has meta - overriding default customizer option
if ( is_category() ) {
$exs_sidebar_position_option = exs_get_category_sidebar_position();
} else {
if ( ! is_single() ) {
if ( is_search() ) {
$exs_sidebar_position_option = exs_option( 'search_sidebar_position', 'no' );
} else {
$exs_sidebar_position_option = exs_option( 'blog_sidebar_position', 'right' );
}
} else {
$exs_sidebar_position_option = exs_option( 'blog_single_sidebar_position', 'right' );
}
} //is_category
//since 2.3.0
//CPT new Customizer options support
if ( 'post' !== $post_type && 'page' !== $post_type ) :
$cpt_option_name_prefix = is_singular() ? $post_type . '_single' : $post_type . '';
$exs_sidebar_position_option =
! empty( exs_option( $cpt_option_name_prefix . '_sidebar_position' ) )
? exs_option( $cpt_option_name_prefix . '_sidebar_position' )
: $exs_sidebar_position_option;
$exs_sidebar_main_id =
! empty( exs_option( $cpt_option_name_prefix . '_sidebar_selected_main' ) )
? exs_option( $cpt_option_name_prefix . '_sidebar_selected_main' )
: 'sidebar-1';
$exs_sidebar_main_opposite_id =
! empty( exs_option( $cpt_option_name_prefix . '_sidebar_selected_main_opposite' ) )
? exs_option( $cpt_option_name_prefix . '_sidebar_selected_main_opposite' )
: 'sidebar-1-opposite';
if ( ! is_active_sidebar( $exs_sidebar_main_id ) || 'no' === $exs_sidebar_position_option ) {
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
}
if ( 'left' === $exs_sidebar_position_option ) {
$exs_return['body'] .= ' sidebar-left';
}
$exs_return['sidebar-id'] = $exs_sidebar_main_id;
$exs_return['sidebar-opposite-id'] = $exs_sidebar_main_opposite_id;
return $exs_return;
endif;
//CPT END
if ( ! is_page_template( 'page-templates/home.php' ) ) {
$exs_sidebar_main_id = 'sidebar-1';
if ( is_front_page() && is_active_sidebar( 'sidebar-home-main' ) ) {
$exs_sidebar_main_id = 'sidebar-home-main';
}
//if empty sidebar - removing aside
if ( ! is_active_sidebar( $exs_sidebar_main_id ) ) {
if ( ! is_singular( 'post' ) || '2' !== exs_option( 'blog_single_toc_after_first_p' ) ) :
$exs_return['body'] = 'no-sidebar';
$exs_return['aside'] = false;
return $exs_return;
else:
if ( false === stripos( get_the_content(), 'term_id;
//if is special category
$exs_special_cats = exs_get_special_categories_from_options();
foreach ( $exs_special_cats as $exs_special_cat_name => $exs_special_cat_id ) {
if ( $exs_term_id === $exs_special_cat_id || cat_is_ancestor_of( $exs_special_cat_id, $exs_term_id ) ) {
$exs_layout = exs_option( 'category_' . $exs_special_cat_name . '_layout', '' );
break;
}
}
//if layout is overridden for category in admin panel
$exs_term_metas_layout = get_term_meta( $exs_term_id, 'layout', true );
if ( ! empty( $exs_term_metas_layout ) ) {
$exs_layout = $exs_term_metas_layout;
}
//if category layout not specified - getting default layout
if ( empty( $exs_layout ) ) {
$exs_layout = exs_option( 'blog_layout', '' ) ? exs_option( 'blog_layout', '' ) : 'default';
}
return $exs_layout;
}
endif;
//get category layout gap based on category meta with global blog option as fallback
if ( ! function_exists( 'exs_get_category_layout_gap' ) ) :
function exs_get_category_layout_gap() {
$exs_layout_gap = '';
$exs_queried_object = get_queried_object();
$exs_term_id = $exs_queried_object->term_id;
//if is special category
$exs_special_cats = exs_get_special_categories_from_options();
foreach ( $exs_special_cats as $exs_special_cat_name => $exs_special_cat_id ) {
if ( $exs_term_id === $exs_special_cat_id || cat_is_ancestor_of( $exs_special_cat_id, $exs_term_id ) ) {
$exs_layout_gap = exs_option( 'category_' . $exs_special_cat_name . '_layout_gap', '' );
break;
}
}
//if layout is overridden for category in admin panel
$exs_term_metas_layout = get_term_meta( $exs_term_id, 'gap', true );
if ( ! empty( $exs_term_metas_layout ) ) {
$exs_layout_gap = $exs_term_metas_layout;
}
//if category layout not specified - getting default layout
if ( empty( $exs_layout_gap ) ) {
$exs_layout_gap = exs_option( 'blog_layout_gap', '' ) ? exs_option( 'blog_layout_gap', '' ) : '';
}
return $exs_layout_gap;
}
endif;
//get feed shot_title
if ( ! function_exists( 'exs_get_feed_shot_title' ) ) :
function exs_get_feed_shot_title() {
if ( is_category() ) {
$exs_show_title = ! exs_option( 'title_show_title', '' );
} else {
$exs_show_title = ! exs_option( 'title_show_title', '' ) && ! is_front_page();
}
return $exs_show_title;
}
endif;
//get feed layout
if ( ! function_exists( 'exs_get_feed_layout' ) ) :
function exs_get_feed_layout( $exs_post_type = 'post' ) {
if ( is_category() ) {
$exs_layout = exs_get_category_layout();
} else {
$exs_layout = exs_option( 'blog_layout', '' ) ? exs_option( 'blog_layout', '' ) : 'default';
}
//override option for demo purposes
if ( isset( $_GET['blog_layout'] ) ) {
$exs_layout_id = absint( $_GET['blog_layout'] );
$exs_layouts = array_keys( exs_get_feed_layout_options() );
$exs_layout = ! empty( $exs_layouts[ $exs_layout_id ] ) ? $exs_layouts[ $exs_layout_id ] : $exs_layout;
}
//since 2.3.0 - new Customizer option for Custom Post Types - use blank HTML markup
if ( 'post' !== $exs_post_type && exs_option( 'cpt_' . $exs_post_type . '_layout_archive' ) ) {
return 'custom-' . exs_option( 'cpt_' . $exs_post_type . '_layout_archive' );
}
return $exs_layout;
}
endif;
//get feed gap
if ( ! function_exists( 'exs_get_feed_gap' ) ) :
function exs_get_feed_gap( $exs_post_type = 'post' ) {
if ( is_category() ) {
$exs_layout_gap = exs_get_category_layout_gap();
} else {
$exs_layout_gap = exs_option( 'blog_layout_gap', '' ) ? exs_option( 'blog_layout_gap', '' ) : '';
}
//override option for demo purposes
if ( isset( $_GET['blog_layout_gap'] ) ) {
$exs_layout_gap_id = absint( $_GET['blog_layout_gap'] );
$exs_layout_gaps = array_keys( exs_get_feed_layout_gap_options() );
$exs_layout_gap = ! empty( $exs_layout_gaps[ $exs_layout_gap_id ] ) ? $exs_layout_gaps[ $exs_layout_gap_id ] : $exs_layout_gap;
}
//since 2.3.0 - new Customizer option for Custom Post Types - use blank HTML markup
if ( 'post' !== $exs_post_type && exs_option( 'cpt_' . $exs_post_type . '_layout_gap' ) ) {
return exs_option( 'cpt_' . $exs_post_type . '_layout_gap' );
}
return $exs_layout_gap;
}
endif;
//get category sidebar_position based on category meta with global blog option as fallback
if ( ! function_exists( 'exs_get_category_sidebar_position' ) ) :
function exs_get_category_sidebar_position() {
$exs_sidebar_position = '';
$exs_queried_object = get_queried_object();
$exs_term_id = $exs_queried_object->term_id;
//if is special category
$exs_special_cats = exs_get_special_categories_from_options();
foreach ( $exs_special_cats as $exs_special_cat_name => $exs_special_cat_id ) {
if ( $exs_term_id === $exs_special_cat_id || cat_is_ancestor_of( $exs_special_cat_id, $exs_term_id ) ) {
$exs_sidebar_position = exs_option( 'category_' . $exs_special_cat_name . '_sidebar_position', 'no' );
break;
}
}
//term metas from category options has higher priority than customizer option for special categories
$exs_term_metas = get_term_meta( $exs_term_id, 'sidebar_position', true );
if ( ! empty( $exs_term_metas ) ) {
$exs_sidebar_position = $exs_term_metas;
}
//if category sidebar_position not specified - getting default sidebar_position
if ( empty( $exs_sidebar_position ) ) {
$exs_sidebar_position = exs_option( 'blog_sidebar_position', '' ) ? exs_option( 'blog_sidebar_position', '' ) : 'right';
}
return $exs_sidebar_position;
}
endif;
//get single post layout based on blog post option
if ( ! function_exists( 'exs_get_post_layout' ) ) :
function exs_get_post_layout() {
$exs_layout = exs_option( 'blog_single_layout', '' ) ? exs_option( 'blog_single_layout', '' ) : 'default';
//override option for demo purposes
if ( isset( $_GET['blog_single_layout'] ) ) {
$exs_layout_id = absint( $_GET['blog_single_layout'] );
$exs_layouts = array_keys( exs_get_post_layout_options() );
$exs_layout = ! empty( $exs_layouts[ $exs_layout_id ] ) ? $exs_layouts[ $exs_layout_id ] : $exs_layout;
}
return $exs_layout;
}
endif;
if ( ! function_exists( 'exs_body_classes' ) ) :
/**
* Adds custom classes to the array of body classes.
*
* @param array $exs_classes Classes for the body element.
*
* @return array
*/
function exs_body_classes( $exs_classes ) {
//header-empty
if ( is_page_template( 'page-templates/empty-page.php' ) ) {
$exs_classes[] = 'header-empty';
}
//header sticky
if ( has_nav_menu( 'side' ) || is_active_sidebar( 'sidebar-side' ) ) {
$exs_classes[] = 'has-side-nav';
$exs_classes[] = exs_option( 'side_nav_position', '' ) ? 'side-nav-right' : 'side-nav-left';
$exs_classes[] = exs_option( 'side_nav_sticked', '' ) ? 'side-nav-sticked' : '';
$exs_classes[] = exs_option( 'side_nav_header_overlap', '' ) ? 'side-nav-header-overlap' : '';
}
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$exs_classes[] = 'hfeed';
} else {
//add 'singular' class for single post or page or any other post type
$exs_classes[] = 'singular';
}
//Adds a sidebar classes
$exs_css_classes = exs_get_layout_css_classes();
$exs_classes[] = $exs_css_classes['body'];
//Add icons in meta classes
//single post
if ( is_singular() ) {
$exs_hide_meta_icons = exs_option( 'blog_single_hide_meta_icons', false );
//blog loop
} else {
$exs_hide_meta_icons = exs_option( 'blog_hide_meta_icons', false );
}
if ( $exs_hide_meta_icons ) {
$exs_classes[] = 'meta-icons-hidden';
}
//special category
if ( is_category() ) {
$exs_special_category_slug = exs_get_post_special_category_slug();
if ( ! empty( $exs_special_category_slug ) ) {
$exs_classes[] = 'special-category';
}
}
//button classes
//buttons_uppercase
//buttons_bold
//buttons_big
//buttons_colormain
//buttons_outline
//buttons_radius
if ( exs_option( 'buttons_uppercase', false ) ) {
$exs_classes[] = 'btns-uppercase';
}
if ( exs_option( 'buttons_bold', false ) ) {
$exs_classes[] = 'btns-bold';
}
if ( exs_option( 'buttons_big', false ) ) {
$exs_classes[] = 'btns-big';
}
if ( exs_option( 'buttons_colormain', false ) ) {
$exs_classes[] = 'btns-colormain';
}
if ( exs_option( 'buttons_outline', false ) ) {
$exs_classes[] = 'btns-outline';
}
$exs_buttons_radius = exs_option( 'buttons_radius', '' );
if ( $exs_buttons_radius ) {
$exs_classes[] = esc_attr( $exs_buttons_radius );
}
//meta icons color class
$exs_meta_icons_color = exs_option( 'color_meta_icons', '' );
if ( $exs_meta_icons_color ) {
$exs_classes[] = esc_attr( $exs_meta_icons_color );
}
//meta text color class
$exs_meta_icons_color = exs_option( 'color_meta_text', '' );
if ( $exs_meta_icons_color ) {
$exs_classes[] = esc_attr( $exs_meta_icons_color );
}
//shop class
if ( class_exists( 'WooCommerce' ) ) {
$exs_classes[] = 'woo woocommerce';
}
//header class
if ( 'always-sticky' === exs_option( 'header_sticky', '' ) ) {
$exs_classes[] = 'header-sticky';
}
if ( exs_option( 'header_menu_bold', false ) ) {
$exs_classes[] = 'menu-bold';
}
if ( exs_option( 'header_menu_uppercase', false ) ) {
$exs_classes[] = 'menu-uppercase';
}
if ( exs_option( 'post_thumbnails_fullwidth', false ) ) {
$exs_classes[] = 'thumbnail-fullwidth';
}
//animation enabled
$exs_animation = exs_option( 'animation_enabled', '' );
if ( ! empty( $exs_animation ) && ! is_customize_preview() ) {
$exs_classes[] = 'animation-enabled';
}
//title section enabled
$exs_title = exs_is_title_section_is_shown();
if ( empty( $exs_title ) ) {
$exs_classes[] = 'title-hidden';
}
return $exs_classes;
}
endif;
add_filter( 'body_class', 'exs_body_classes' );
//wrap each word in span - for date over featured image
if ( ! function_exists( 'exs_wrap_each_word_in_span' ) ) :
function exs_wrap_each_word_in_span( $string ) {
//date dividers temporary replace
$string = str_replace( '-', '{{-}} ', $string );
$string = str_replace( '/', '{{/}} ', $string );
$string = str_replace( ',', '{{,}} ', $string );
$string = str_replace( '.', '{{.}} ', $string );
//wrap each word in span
$array = explode( ' ', $string );
$return_string = '';
foreach ( $array as $key => $value ) {
$return_string .= '' . $value . '' . ' ';
}
//wrap date dividers in span
$return_string = str_replace( '{{-}} ', '-', $return_string );
$return_string = str_replace( '{{/}} ', '/', $return_string );
$return_string = str_replace( '{{,}}', ',', $return_string );
$return_string = str_replace( '{{.}} ', '.', $return_string );
return $return_string;
}
endif;
//markup for animated page elements
if ( ! function_exists( 'exs_animated_elements_markup' ) ) :
function exs_animated_elements_markup() {
if ( empty( EXS_EXTRA ) ) {
return;
}
$exs_animation = exs_option( 'animation_enabled', '' );
if ( empty( $exs_animation ) ) {
return;
}
//get animations array from customizer. Keys - selectors
$exs_animations = array(
'.column-aside .widget' => exs_option( 'animation_sidebar_widgets', '' ),
'.footer-widgets .widget' => exs_option( 'animation_footer_widgets', '' ),
'.hfeed article.post' => exs_option( 'animation_feed_posts', '' ),
'.hfeed .post .post-thumbnail img' => exs_option( 'animation_feed_posts_thumbnail', '' ),
);
$exs_animations = array_filter( $exs_animations );
if ( ! empty( $exs_animations ) && ! is_customize_preview() ) :
?>
data-animate=''
'' . esc_html__( 'Pages: ', 'exs' ) . '',
'after' => '
',
'link_before' => '',
'link_after' => '',
)
);
}
endif;
//arguments for link pages
if ( ! function_exists( 'exs_get_the_posts_pagination_atts' ) ) :
function exs_get_the_posts_pagination_atts() {
return array(
'mid_size' => 5,
'prev_text' => '' . esc_html__( 'Previous page', 'exs' ) . '' . exs_icon( 'chevron-left', true ) . '',
'next_text' => '' . esc_html__( 'Next page', 'exs' ) . '' . exs_icon( 'chevron-right', true ) . '',
);
}
endif;
//get top level menu items count
if ( ! function_exists( 'exs_get_menu_top_level_items_count' ) ) :
function exs_get_menu_top_level_items_count( $exs_menu_name ) {
$exs_locations = get_nav_menu_locations();
$exs_menu_id = ! empty ( $exs_locations[ $exs_menu_name ] ) ? $exs_locations[ $exs_menu_name ] : false;
if ( empty( $exs_menu_id ) ) {
return '-1';
}
$exs_menu_object = wp_get_nav_menu_object( $exs_menu_id );
if ( empty( $exs_menu_object ) ) {
return '-1';
}
$exs_menu_items = wp_get_nav_menu_items( $exs_menu_object->term_id );
$exs_menu_items_count = 0;
foreach ( (array) $exs_menu_items as $exs_key => $exs_menu_item ) {
if ( '0' === $exs_menu_item->menu_item_parent ) {
$exs_menu_items_count ++;
}
}
return $exs_menu_items_count;
}
endif;
//get menu class depending on menu top level items count
if ( ! function_exists( 'exs_get_menu_class_based_on_top_items_count' ) ) :
function exs_get_menu_class_based_on_top_items_count( $exs_menu_name ) {
$exs_menu_items_count = exs_get_menu_top_level_items_count( $exs_menu_name );
if ( '-1' === $exs_menu_items_count || 0 === $exs_menu_items_count ) {
return 'menu-empty';
}
$exs_css_class = 'menu-low-items';
if ( $exs_menu_items_count > 6 ) {
$exs_css_class = 'menu-many-items';
}
return $exs_css_class;
}
endif;
//print svg icon
if ( ! function_exists( 'exs_icon' ) ) :
function exs_icon( $exs_name, $exs_return = false, $exs_container_css_class = 'svg-icon', $exs_style_string = '' ) {
//in the future we'll add option for this
$exs_icons_pack = exs_option( 'theme_icons', 'google' );
if ( $exs_return ) {
ob_start();
}
echo '';
$founded = get_template_part( '/template-parts/svg/' . $exs_icons_pack . '/' . $exs_name, null, array( $exs_style_string ) );
//load default 'google' template if no template exists in provided icon pack
if ( false === $founded ) {
$exs_icons_pack = 'google';
get_template_part( '/template-parts/svg/' . $exs_icons_pack . '/' . $exs_name, null, array( $exs_style_string ) );
}
echo '';
if ( $exs_return ) {
return ob_get_clean();
}
}
endif;
//print social link
if ( ! function_exists( 'exs_social_link' ) ) :
function exs_social_link( $exs_name, $exs_url, $exs_style_string='' ) {
$blank = exs_option( 'meta_social_blank', '' ) ? ' target="_' . 'blank' . '"' : '';
echo '';
exs_icon( $exs_name, false, 'svg-icon', $exs_style_string );
echo '' . esc_html( $exs_name ) . '';
echo '';
}
endif;
//meta
//get meta array
if ( ! function_exists( 'exs_get_theme_meta' ) ) :
function exs_get_theme_meta( $exs_meta_names = array() ) {
/*
customizer options with meta are:
'meta_email'
'meta_email_label'
'meta_phone'
'meta_phone_label'
'meta_address'
'meta_address_label'
'meta_opening_hours'
'meta_opening_hours_label'
*/
//if no names specified - using all meta
if ( empty( $exs_meta_names ) ) :
$exs_meta_names = array(
'email',
'phone',
'address',
'opening_hours',
);
endif;
$exs_theme_meta = array();
//meta values
foreach ( $exs_meta_names as $exs_meta_name ) {
$exs_value = exs_option( 'meta_' . $exs_meta_name );
if ( ! empty( $exs_value ) ) {
$exs_theme_meta[ $exs_meta_name ] = $exs_value;
}
}
//labels for meta if it is not empty
if ( ! empty( $exs_theme_meta ) ) {
foreach ( $exs_theme_meta as $exs_meta_name => $exs_meta_value ) {
$exs_label = exs_option( 'meta_' . $exs_meta_name . '_label' );
if ( ! empty( $exs_label ) ) {
$exs_theme_meta[ $exs_meta_name . '_label' ] = $exs_label;
}
}
}
return $exs_theme_meta;
}
endif;
//print all social links based on theme_meta from Customizer
if ( ! function_exists( 'exs_social_links' ) ) :
function exs_social_links() {
$exs_facebook = exs_option( 'meta_facebook' );
$exs_twitter = exs_option( 'meta_twitter' );
$exs_youtube = exs_option( 'meta_youtube' );
$exs_instagram = exs_option( 'meta_instagram' );
$exs_pinterest = exs_option( 'meta_pinterest' );
$exs_linkedin = exs_option( 'meta_linkedin' );
$exs_github = exs_option( 'meta_github' );
$exs_tiktok = exs_option( 'meta_tiktok' );
$exs_telegram = exs_option( 'meta_telegram' );
$exs_mastodon = exs_option( 'meta_mastodon' );
if (
! empty( $exs_facebook )
||
! empty( $exs_twitter )
||
! empty( $exs_youtube )
||
! empty( $exs_instagram )
||
! empty( $exs_pinterest )
||
! empty( $exs_linkedin )
||
! empty( $exs_github )
||
! empty( $exs_tiktok )
||
! empty( $exs_telegram )
||
! empty( $exs_mastodon )
) :
$exs_social_style_string = '';
$exs_social_buttons_social = exs_option( 'buttons_social', '' );
switch ( $exs_social_buttons_social ):
case( '1' ):
$exs_social_style_string = 'fill:var(--c-';
break;
case( '2' ):
$exs_social_style_string = 'width:40px;height:40px;max-width:40px;max-height:40px;padding:8px;fill:#fff;background:var(--c-';
break;
case( '3' ):
$exs_social_style_string = 'border-radius:6px;width:40px;height:40px;max-width:40px;max-height:40px;padding:8px;fill:#fff;background:var(--c-';
break;
case( '4' ):
$exs_social_style_string = 'border-radius:50%;width:40px;height:40px;max-width:40px;max-height:40px;padding:8px;fill:#fff;background:var(--c-';
break;
endswitch;
echo '';
if ( ! empty( $exs_facebook ) ) :
exs_social_link( 'facebook', $exs_facebook, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'facebook)' : '' );
endif;
if ( ! empty( $exs_twitter ) ) :
exs_social_link( 'twitter', $exs_twitter, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'twitter)' : '' );
endif;
if ( ! empty( $exs_youtube ) ) :
exs_social_link( 'youtube', $exs_youtube, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'youtube)' : '' );
endif;
if ( ! empty( $exs_instagram ) ) :
exs_social_link( 'instagram', $exs_instagram, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'instagram)' : '' );
endif;
if ( ! empty( $exs_pinterest ) ) :
exs_social_link( 'pinterest', $exs_pinterest, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'pinterest)' : '' );
endif;
if ( ! empty( $exs_linkedin ) ) :
exs_social_link( 'linkedin', $exs_linkedin, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'linkedin)' : '' );
endif;
if ( ! empty( $exs_github ) ) :
exs_social_link( 'github-circle', $exs_github, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'github)' : '' );
endif;
if ( ! empty( $exs_tiktok ) ) :
exs_social_link( 'tiktok', $exs_tiktok, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'tiktok)' : '' );
endif;
if ( ! empty( $exs_telegram ) ) :
exs_social_link( 'telegram', $exs_telegram, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'telegram)' : '' );
endif;
if ( ! empty( $exs_mastodon ) ) :
exs_social_link( 'mastodon', $exs_mastodon, ! empty( $exs_social_style_string ) ? $exs_social_style_string . 'mastodon)' : '' );
endif;
echo '';
endif;
}
endif;
//get html for all social links based on theme_meta from Customizer
if ( ! function_exists( 'exs_social_links_html' ) ) :
function exs_social_links_html() {
ob_start();
exs_social_links();
return ob_get_clean();
}
endif;
if ( ! function_exists( 'exs_post_thumbnail_file_exists' ) ) :
/**
* Check if post thumbnail file exists and thumbnail not loading from the external source
*/
function exs_post_thumbnail_file_exists( $exs_id = false ) {
if ( empty( $exs_id ) ) {
$exs_id = get_the_ID();
}
$file = get_attached_file( get_post_thumbnail_id( $exs_id ) );
//if is url - return exists
if ( strpos( $file, 'http' ) === 0 ) {
return true;
}
return file_exists( $file );
}
endif;
if ( ! function_exists( 'exs_has_post_thumbnail' ) ) :
/**
* Check if has post thumbnail and thumbnail file exists
*/
function exs_has_post_thumbnail( $exs_id = false ) {
if ( empty( $exs_id ) ) {
$exs_id = get_the_ID();
}
return ! (
post_password_required( $exs_id )
||
is_attachment()
||
! has_post_thumbnail( $exs_id )
//this line will prevent loads featured images from the external resources
||
! exs_post_thumbnail_file_exists( $exs_id )
);
}
endif;
if ( ! function_exists( 'exs_post_thumbnail' ) ) :
/**
* Displays an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index views, or a div
* element when on single views.
*/
function exs_post_thumbnail( $exs_size = 'post-thumbnail', $exs_css_class = '', $title_section = false ) {
if (
! exs_has_post_thumbnail()
) {
return;
}
$post_thumbnails_centered = ! empty( exs_option( 'post_thumbnails_centered', '' ) ) ? 'text-center' : '';
if ( is_singular() ) :
//since 2.0.4 - displaying featured image in the 'title-6' section layout
//if it was shown in the title section - no double print it in the content
static $shown = 0;
if ( $shown ) {
return;
}
if ( $title_section ) {
$shown++;
}
$full_width_featured = exs_option( 'blog_single_fullwidth_featured' );
if ( ! empty( $full_width_featured ) ) {
$exs_css_class .= ' alignfull';
}
$oembed_url = false;
$oembed_post_thumbnail = false;
$enable_oembed_for_thumbnail_option = exs_option( 'blog_single_first_embed_featured', '' );
//only video post format
if ( ( 'video' === get_post_format() ) && ( 'video' === $enable_oembed_for_thumbnail_option ) ) {
$oembed_post_thumbnail = true;
}
//all posts
if ( 'all' === $enable_oembed_for_thumbnail_option ) {
$oembed_post_thumbnail = true;
}
if ( is_single() && $oembed_post_thumbnail ) {
$post_content = get_the_content();
//get oEmbed URL
$reg = preg_match('|^\s*(https?://[^\s"]+)\s*$|im', $post_content, $matches );
$oembed_url = ! empty( $reg ) ? trim( $matches[0] ) : false;
//if no youtube, trying to find self hosted
$first_self_hosted = '';
$embeds = array();
if ( empty( $oembed_url ) ) {
$post_content = apply_filters( 'the_content', $post_content );
$embeds = get_media_embedded_in_content( $post_content );
}
}
if ( $enable_oembed_for_thumbnail_option && ( $oembed_url || ! empty( $embeds[0] ) ) ) :
//if youtube
if( $oembed_url ) :
add_filter( 'the_content', function ( $content ) use ( $oembed_url ) {
//remove embed
$content = str_replace( $oembed_url, '', $content );
//hide embed wrapper
$pos = strpos( $content, 'class="wp-block-embed' );
if ($pos !== false) {
$content = substr_replace( $content, 'class="d-none wp-block-embed', $pos, strlen( 'class="wp-block-embed' ) );
}
return $content;
//1 - to run early
}, 1 );
?>
';
$exs_author_id = get_the_author_meta( 'ID' );
$exs_custom_image_url = get_the_author_meta( 'custom_profile_image', $exs_author_id );
if ( ! empty( $exs_custom_image_url ) ) {
echo '';
} else {
echo get_avatar( $exs_author_id, 100 );
}
echo '';
endif; //$exs_author_avatar
?>
post_author;
echo '';
$user = get_userdata( $author_id );
echo esc_html( $user->user_nicename );
echo '';
endif;
?>
', 'rel="author" itemprop="url">', $exs_link );
$exs_link = str_replace( '', '', $exs_link );
return $exs_link;
}
endif;
if ( ! function_exists( 'exs_the_date' ) ) :
/**
* Prints date HTML with the post link on blog.
*/
function exs_the_date( $exs_human_diff = null, $title_section_options = false ) {
$css_class = '';
//options
//single post
if ( is_singular() ) {
$prefix = ! empty( $title_section_options ) ? 'title_' : '';
$exs_show_date = exs_option( $prefix . 'blog_single_show_date', true );
$exs_date_word = exs_option( $prefix . 'blog_single_before_date_word', '' );
$exs_date_diff = exs_option( $prefix . 'blog_single_show_human_date', '' );
$exs_show_icons = ! exs_option( $prefix . 'blog_single_hide_meta_icons', false );
//new options since 1.9.5
$css_class .= exs_option( 'blog_single_meta_bold' ) ? ' fw-700' : '';
$css_class .= exs_option( 'blog_single_meta_uppercase' ) ? ' text-uppercase' : '';
$css_class .= exs_option( 'blog_single_meta_font_size' ) ? ' fs-' . (int) exs_option( 'blog_single_meta_font_size' ) : '';
//new date modified since 1.9.9
$exs_date_type = exs_option( $prefix . 'blog_single_show_date_type', 'publish' );
$exs_date_modify_word = exs_option( $prefix . 'blog_single_before_date_modify_word', '' );
//blog loop
} else {
if ( is_search() ) {
$exs_show_date = exs_option( 'search_show_date', true );
$exs_date_word = exs_option( 'search_before_date_word', '' );
$exs_date_diff = exs_option( 'search_show_human_date', '' );
$exs_show_icons = ! exs_option( 'search_hide_meta_icons', false );
//new options since 1.9.5
$css_class .= exs_option( 'search_meta_bold' ) ? ' fw-700' : '';
$css_class .= exs_option( 'search_meta_uppercase' ) ? ' text-uppercase' : '';
$css_class .= exs_option( 'search_meta_font_size' ) ? ' fs-' . (int) exs_option( 'search_meta_font_size' ) : '';
//new date modified since 1.9.9
$exs_date_type = exs_option( 'search_show_date_type', 'publish' );
$exs_date_modify_word = exs_option( 'search_before_date_modify_word', '' );
} else {
$exs_show_date = exs_option( 'blog_show_date', true );
$exs_date_word = exs_option( 'blog_before_date_word', '' );
$exs_date_diff = exs_option( 'blog_show_human_date', '' );
$exs_show_icons = ! exs_option( 'blog_hide_meta_icons', false );
//new options since 1.9.5
$css_class .= exs_option( 'blog_meta_bold' ) ? ' fw-700' : '';
$css_class .= exs_option( 'blog_meta_uppercase' ) ? ' text-uppercase' : '';
$css_class .= exs_option( 'blog_meta_font_size' ) ? ' fs-' . (int) exs_option( 'blog_meta_font_size' ) : '';
//new date modified since 1.9.9
$exs_date_type = exs_option( 'blog_show_date_type', 'publish' );
$exs_date_modify_word = exs_option( 'blog_before_date_modify_word', '' );
}
}
//override diff if it passed to function
if ( null !== $exs_human_diff && empty( $title_section_options ) ) {
$exs_date_diff = $exs_human_diff;
}
if ( ! empty( $exs_show_date ) ) :
//date-wrapper
?>
' ) );
?>
', ' ', '' ) );
?>
', 'exs' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
)
);
?>
post_parent ) : get_adjacent_post( false, $exs_exluded_special_cats, true );
$exs_next = get_adjacent_post( false, $exs_exluded_special_cats, false );
if ( ! $exs_next && ! $exs_previous ) {
return;
}
$exs_word_prev = exs_option( 'blog_single_post_nav_word_prev', esc_html__( 'Prev', 'exs' ) );
$exs_word_next = exs_option( 'blog_single_post_nav_word_next', esc_html__( 'Next', 'exs' ) );
?>
get_the_post_thumbnail_url( get_the_ID(), 'full' ),
'class' => 'i post-thumbnail-background background-cover cover-center background-fixed background-overlay overlay-dark',
'overlay' => '',
);
}
endif;
endif; //is_single
//for page with feature image - override default header_image
if ( 'header_image' === $exs_section ) {
$exs_image = get_header_image();
//for page with feature image - override default image
if ( is_page() ) {
if ( has_post_thumbnail() ) {
$exs_image = get_the_post_thumbnail_url();
}
}
} else {
$exs_image = exs_option( $exs_section . '_background_image', '' );
// override title background if page featured image is set
if ( 'title' === $exs_section && $exs_image ) {
//for page with feature image - override default image
if ( is_page() ) {
if ( has_post_thumbnail() ) {
$exs_image = get_the_post_thumbnail_url();
}
}
}
}
$exs_return = array(
'url' => $exs_image,
'class' => '',
'overlay' => '',
);
if ( empty( $exs_image ) && empty( $exs_empty_image ) ) {
return $exs_return;
}
$exs_cover = exs_option( $exs_section . '_background_image_cover', '' );
$exs_fixed = exs_option( $exs_section . '_background_image_fixed', '' );
$exs_overlay = exs_option( $exs_section . '_background_image_overlay', '' );
$exs_opacity = exs_option( $exs_section . '_background_image_overlay_opacity', '' );
if ( ! empty( $exs_cover ) ) {
$exs_return['class'] .= 'background-cover cover-center';
}
if ( ! empty( $exs_fixed ) ) {
$exs_return['class'] .= ' background-fixed';
}
if ( ! empty( $exs_overlay ) ) {
$exs_return['class'] .= ' background-overlay ' . $exs_overlay;
if ( ! empty( $exs_opacity ) ) {
$opacity = ( int ) $exs_opacity / 100;
$exs_return['overlay'] = '--' . $exs_overlay . ':' . $opacity;
}
}
return $exs_return;
}
endif;
/////////////
//Read More//
/////////////
// Read more markup inside link for excertp and the_content
if ( ! function_exists( 'exs_read_more_inside_link_markup' ) ) :
function exs_read_more_inside_link_markup( $exs_read_more_text = '' ) {
if ( empty( $exs_read_more_text ) ) {
$exs_read_more_text = is_search() ? exs_option( 'search_read_more_text', '' ) : exs_option( 'blog_read_more_text', '' );
}
if ( empty( $exs_read_more_text ) ) {
return '';
}
return sprintf(
wp_kses(
$exs_read_more_text . ' "%s"',
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
);
}
endif;
//generated excerpt ending...
if ( ! function_exists( 'exs_excerpt_more' ) ) :
function exs_excerpt_more( $exs_more ) {
if ( is_admin() && ! wp_doing_ajax() ) {
return $exs_more;
}
if ( empty( exs_option( 'blog_excerpt_length' ) ) ) {
return '';
}
return '...';
}
endif;
add_filter( 'excerpt_more', 'exs_excerpt_more', 21 );
//read more for excerpt
if ( ! function_exists( 'exs_read_more_markup_excerpt' ) ) :
function exs_read_more_markup_excerpt() {
global $post;
$exs_read_more_style = is_search() ? exs_option( 'search_read_more_style', '' ) : exs_option( 'blog_read_more_style', '' );
$exs_read_more_block = is_search() ? exs_option( 'search_read_more_block', '' ) : exs_option( 'blog_read_more_block', '' );
$d_block = $exs_read_more_block ? ' d-block' : '';
switch ( $exs_read_more_style ) :
case 'button':
$a_class = ' wp-block-button__link icon-inline';
$d_block .= ' mt-15';
break;
case 'button-arrow':
$a_class = ' wp-block-button__link';
$d_block .= ' mt-15 is-style-arrow';
break;
default:
$d_block .= $exs_read_more_block ? ' mt-05' : '';
$a_class = '';
endswitch;
$exs_markup = ' ' .
exs_read_more_inside_link_markup() .
'';
return $exs_markup;
}
endif;
//putting read more text inside excerpt if text is not empty
if ( ! function_exists( 'exs_read_more_in_excerpt' ) ) :
function exs_read_more_in_excerpt( $exs_excerpt ) {
$exs_read_more_text = is_search() ? exs_option( 'search_read_more_text', '' ) : exs_option( 'blog_read_more_text', '' );
$exs_excerpt_length = is_search() ? exs_option( 'search_excerpt_length', '' ) : exs_option( 'blog_excerpt_length', '' );
//if excerpt length set to 0 manually and no 'read more' - return empty string
if ( '0' === $exs_excerpt_length && empty( $exs_read_more_text ) ) {
return '';
}
//if excerpt length set to 0 manually and 'read more' not empty - return empty string
if ( '0' === $exs_excerpt_length && ! empty( $exs_read_more_text ) ) {
return exs_read_more_markup_excerpt();
}
if ( empty( $exs_read_more_text ) || 'post' !== get_post_type() ) {
return $exs_excerpt;
}
$exs_excerpt = str_replace( '
', exs_read_more_markup_excerpt() . '', $exs_excerpt );
return $exs_excerpt;
}
endif;
add_filter( 'the_excerpt', 'exs_read_more_in_excerpt', 21 );
//Filter the except length
if ( ! function_exists( 'exs_excerpt_custom_length' ) ) :
function exs_excerpt_custom_length( $exs_length ) {
if ( is_admin() && ! wp_doing_ajax() ) {
return $exs_length;
}
$exs_excerpt_length = is_search() ? exs_option( 'search_excerpt_length', '' ) : exs_option( 'blog_excerpt_length', '' );
return absint( $exs_excerpt_length );
}
endif;
add_filter( 'excerpt_length', 'exs_excerpt_custom_length', 999 );
//home page intro teasers
if ( ! function_exists( 'exs_get_intro_teasers' ) ) :
function exs_get_intro_teasers() {
$exs_teasers = array();
for ( $exs_i = 1; $exs_i < 5; $exs_i ++ ) {
/*
reeatable options:
intro_teaser_image_
intro_teaser_title_
intro_teaser_text_
intro_teaser_link_
intro_teaser_button_text_
*/
$exs_teasers[ $exs_i ] = array_filter(
array(
'image' => exs_option( 'intro_teaser_image_' . $exs_i, '' ),
'title' => exs_option( 'intro_teaser_title_' . $exs_i, '' ),
'text' => exs_option( 'intro_teaser_text_' . $exs_i, '' ),
'link' => exs_option( 'intro_teaser_link_' . $exs_i, '' ),
'button' => exs_option( 'intro_teaser_button_text_' . $exs_i, '' ),
)
);
}
return array_filter( $exs_teasers );
}
endif;
//related posts
if ( ! function_exists( 'exs_related_posts' ) ) :
function exs_related_posts( $exs_id ) {
$exs_layout = exs_option( 'blog_single_related_posts', '' );
if ( empty( $exs_layout ) ) {
return;
}
//tags, cats or author based related posts
$related_base = exs_option( 'blog_single_related_posts_base', '' );
//tags by default
if ( empty( $related_base ) ) {
$exs_related_meta = wp_get_post_tags( $exs_id, array( 'fields' => 'ids' ) );
}
if ( 'cat' === $related_base ) {
$exs_related_meta = wp_get_post_categories( $exs_id, array( 'fields' => 'ids' ) );
}
if ( 'author' === $related_base ) {
$exs_related_meta = get_the_author_meta( 'ID' );
}
if ( ! empty( $exs_related_meta ) ) :
//list
//list-thumbnails
//grid
//num of posts
$exs_posts_number = absint( exs_option( 'blog_single_related_posts_number', 3 ) );
if ( empty( $exs_posts_number ) ) {
$exs_posts_number = 3;
}
//tags by default
$exs_args = array(
'tag__in' => $exs_related_meta,
'post__not_in' => array( $exs_id ),
'posts_per_page' => $exs_posts_number,
);
if ( 'cat' === $related_base ) {
$exs_args = array(
'category__in' => $exs_related_meta,
'post__not_in' => array( $exs_id ),
'posts_per_page' => $exs_posts_number,
);
}
if ( 'author' === $related_base ) {
$exs_args = array(
'author' => $exs_related_meta,
'post__not_in' => array( $exs_id ),
'posts_per_page' => $exs_posts_number,
);
}
$exs_query = new WP_Query( $exs_args );
if ( $exs_query->have_posts() ) :
$exs_related_title = exs_option( 'blog_single_related_posts_title', esc_html__( 'Related Posts', 'exs' ) );
$hidden_class = exs_option( 'blog_single_related_posts_hidden', '' );
$show_date = exs_option( 'blog_single_related_show_date', '' );
$readmore_text = exs_option( 'blog_single_related_posts_readmore_text', '' );
$image_size = exs_option( 'blog_single_related_posts_image_size', '' );
//new since v1.9.5
$mt = exs_option( 'blog_single_related_posts_mt' );
$mb = exs_option( 'blog_single_related_posts_mb' );
$bg = exs_option( 'blog_single_related_posts_background' );
$section = exs_option( 'blog_single_related_posts_section' ) ? 'section' : '';
if ( $bg && ! $section ) {
$bg .= ' extra-padding';
}
$pt = exs_option( 'blog_single_related_posts_pt' );
$pb = exs_option( 'blog_single_related_posts_pb' );
$alignfull = exs_option( 'blog_single_related_posts_fullwidth' ) ? 'alignfull' : '';
?>
post_count < 3 ) {
$exs_wrapper_class = 'layout-cols-' . $exs_query->post_count;
}
?>
have_posts() ) :
$exs_query->the_post();
?>
have_posts() ) :
$exs_query->the_post();
?>
have_posts() ) :
$exs_query->the_post();
?>
have_posts() ) :
$exs_query->the_post();
?>
have_posts() ) :
$exs_query->the_post();
?>
have_posts() ) :
$exs_query->the_post();
?>
-
have_posts() ) :
$exs_query->the_post();
?>
have_posts() ) :
$exs_query->the_post();
?>
-
'',
);
ob_start();
the_widget( $exs_widget_class, $exs_instance, $exs_args );
return ob_get_clean();
}
endif;
//count widgets in sidebar
if ( ! function_exists( 'exs_get_sidebar_widgets_count' ) ) :
function exs_get_sidebar_widgets_count( $sidebar_id ) {
$widgets = get_option( 'sidebars_widgets' );
return count( $widgets[ $sidebar_id ] );
}
endif;
//detect shop - handy for sidebar and breadcrumbs
if ( ! function_exists( 'exs_is_shop' ) ) :
function exs_is_shop() {
$exs_return = false;
if ( function_exists( 'is_woocommerce' ) ) {
if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {
$exs_return = true;
}
}
if ( function_exists( 'yith_wcwl_is_wishlist_page' ) ) {
if ( yith_wcwl_is_wishlist_page() ) {
$exs_return = true;
}
}
return $exs_return;
}
endif;
//detect EDD downloads archive - handy for sidebar and breadcrumbs
if ( ! function_exists( 'exs_is_downloads' ) ) :
function exs_is_downloads() {
$exs_return = false;
if ( is_post_type_archive( 'download' ) || is_tax( 'download_category' ) || is_tax( 'download_tag' ) ) {
$exs_return = true;
}
return $exs_return;
}
endif;
//detect bbPress - handy for sidebar and breadcrumbs
if ( ! function_exists( 'exs_is_bbpress' ) ) :
function exs_is_bbpress() {
$exs_return = false;
if ( function_exists( 'is_bbpress' ) ) {
if ( is_bbpress() ) {
$exs_return = true;
}
}
return $exs_return;
}
endif;
//detect BuddyPress - handy for sidebar and breadcrumbs
if ( ! function_exists( 'exs_is_buddypress' ) ) :
function exs_is_buddypress() {
$exs_return = false;
if ( function_exists( 'is_buddypress' ) ) {
if ( is_buddypress() ) {
$exs_return = true;
}
}
return $exs_return;
}
endif;
//detect BuddyPress - handy for sidebar and breadcrumbs
if ( ! function_exists( 'exs_is_wpjm' ) ) :
function exs_is_wpjm() {
$exs_return = false;
if ( function_exists( 'is_wpjm' ) ) {
if ( is_wpjm() ) {
$exs_return = true;
}
}
return $exs_return;
}
endif;
//detect The Events Calendar - handy for sidebar and breadcrumbs
if ( ! function_exists( 'exs_is_events' ) ) :
function exs_is_events() {
$exs_return = false;
if ( function_exists( 'tribe_is_event_query' ) ) {
if ( tribe_is_event_query() ) {
$exs_return = true;
}
}
return $exs_return;
}
endif;
//detect LearnPress archive - handy for sidebar and breadcrumbs
if ( ! function_exists( 'exs_is_learnpress_archive' ) ) :
function exs_is_learnpress_archive() {
$exs_return = false;
if ( function_exists( 'is_learnpress' ) ) {
if ( is_learnpress() && ! is_singular() ) {
$exs_return = true;
}
}
return $exs_return;
}
endif;
//detect LearnPress Course - handy for sidebar and breadcrumbs
if ( ! function_exists( 'exs_is_learnpress_course' ) ) :
function exs_is_learnpress_course() {
$exs_return = false;
if ( function_exists( 'learn_press_is_course' ) ) {
if ( learn_press_is_course() ) {
$exs_return = true;
}
}
return $exs_return;
}
endif;
//echo breadcrumbs markup
if ( ! function_exists( 'exs_breadcrumbs' ) ) :
function exs_breadcrumbs() {
$exs_args = array(
'before' => '',
);
$exs_seo_options = get_option( 'wpseo_titles' );
$exs_args['delimiter'] = ! empty( $exs_seo_options['breadcrumbs-sep'] ) ? $exs_seo_options['breadcrumbs-sep'] : '/';
if ( exs_is_shop() ) :
woocommerce_breadcrumb(
array(
'wrap_before' => $exs_args['before'] . '',
'wrap_after' => '' . $exs_args['after'],
'before' => '',
'after' => '',
'delimiter' => ' ' . $exs_args['delimiter'] . ' ',
)
);
elseif ( function_exists( 'learn_press_breadcrumb' ) && is_learnpress() ) :
$args = array(
'delimiter' => ' / ',
'wrap_before' => '',
'before' => '',
'after' => '',
);
learn_press_breadcrumb( $args );
elseif ( function_exists( 'yoast_breadcrumb' ) ) :
yoast_breadcrumb( '' );
elseif ( function_exists( 'rank_math_the_breadcrumbs' ) ) :
$args = array(
'delimiter' => ' / ',
'wrap_before' => '',
'before' => '',
'after' => '',
);
rank_math_the_breadcrumbs( $args );
endif;
}
endif;
//check if breadcrumbs are enabled and plugins to show them are active
if ( ! function_exists( 'exs_breadcrumbs_enabled' ) ) :
function exs_breadcrumbs_enabled() {
$exs_return = exs_option( 'title_show_breadcrumbs', true );
if ( exs_is_shop() && $exs_return ) {
return $exs_return;
} elseif ( function_exists( 'learn_press_breadcrumb' ) && is_learnpress() && $exs_return ) {
return $exs_return;
} elseif ( function_exists( 'yoast_breadcrumb' ) && $exs_return ) {
return $exs_return;
} elseif ( function_exists( 'rank_math_the_breadcrumbs' ) && $exs_return ) {
return $exs_return;
} else {
return false;
}
}
endif;
//copyright text - year
if ( ! function_exists( 'exs_get_copyright_text' ) ) :
function exs_get_copyright_text( $exs_text = '' ) {
$exs_text = str_replace( '[year]', '' . date( 'Y' ) . '', $exs_text );
return $exs_text;
}
endif;
//detect is_front_page and not is paged
if ( ! function_exists( 'exs_is_front_page' ) ) :
function exs_is_front_page() {
return is_front_page() && ! is_paged();
}
endif;
//detect for displaying title section
if ( ! function_exists( 'exs_is_title_section_is_shown' ) ) :
function exs_is_title_section_is_shown() {
if ( is_page_template( 'page-templates/no-sidebar-no-title.php' ) || is_page_template( 'page-templates/header-overlap.php' ) || is_page_template( 'page-templates/header-overlap-full-width.php' ) ) {
return false;
}
$exs_show_title = exs_option( 'title_show_title', '' );
$exs_show_search = exs_option( 'title_show_search', '' );
$exs_show_breadcrumbs = exs_breadcrumbs_enabled();
$exs_is_front_page = exs_is_front_page();
if ( ! empty( $exs_is_front_page ) && empty( $exs_show_search ) ) {
return false;
}
if ( empty( $exs_show_title ) && empty( $exs_show_breadcrumbs ) && empty( $exs_show_search ) ) {
return false;
} else {
return true;
}
}
endif;
//based on the WooCommerce wc_hex_is_light
if ( ! function_exists( 'exs_hex_is_light' ) ) {
/**
* Determine whether a hex color is light.
*
* @param mixed $color Color.
* @return bool True if a light color.
*/
function exs_hex_is_light( $color ) {
$hex = str_replace( '#', '', $color );
//hex is 6 signs
if ( 6 === strlen( $hex ) ) {
$c_r = hexdec( substr( $hex, 0, 2 ) );
$c_g = hexdec( substr( $hex, 2, 2 ) );
$c_b = hexdec( substr( $hex, 4, 2 ) );
//hex is 3 signs
} elseif ( 3 === strlen( $hex ) ) {
$c_r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
$c_g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
$c_b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
} else {
//light is default is color is failure
return true;
}
$brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
$return = $brightness > 155;
return $return;
}
}
//if inverse background
if ( ! function_exists( 'exs_is_inverse_background' ) ) {
/**
* Determine whether background class has "i" as a first letter
*
* @param string $class string.
* @return bool True if a reverse section.
*/
function exs_is_inverse_background( $class ) {
return 0 === strpos( $class, 'i' );
}
}
//if inverse background
if ( ! function_exists( 'exs_get_transparent_class' ) ) {
function exs_get_transparent_class( $class ) {
$is_inverse = exs_is_inverse_background( $class );
$header_bg_hex = exs_option( exs_get_color_name_based_on_bg_class( $class ) );
$is_light = exs_hex_is_light( $header_bg_hex );
$return = 'i';
if ( $is_inverse ) {
if ( $is_light ) {
$return = 'header-inverse l';
}
} else {
if ( ! $is_light ) {
$return = 'header-inverse l';
}
}
return $return;
}
}
//inverse color scheme switcher
if ( ! function_exists( 'exs_print_inverse_color_scheme_switcher' ) ) {
function exs_print_inverse_color_scheme_switcher() {
if ( exs_option( 'colors_inverse_enabled' ) ) :
$hide_switch_class = exs_option( 'colors_inverse_hide_switcher' ) ? 'switch-hidden' : '';
$btn_inverse_class = ! empty ( $_COOKIE['exs-color-inverse'] ) ? 'active' : '';
?>