'; } add_action('barlog_burger_dropdown_button', 'barlog_burger_dropdown_button'); } /** * Register widget area. * */ if (!function_exists('barlog_widgets_init')) { function barlog_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar', 'barlog' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Sidebar 1', 'barlog' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); if ( class_exists( 'WooCommerce' ) ) { register_sidebar( array( 'name' => esc_html__( 'WooCommerce sidebar', 'barlog' ), 'id' => 'woocommerce', 'description' => esc_html__( 'Used on WooCommerce pages', 'barlog' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } for ( $i = 1; $i <= 6; $i ++ ) { register_sidebar( array( /* translators: 1: Widget number. */ 'name' => sprintf( __( 'Footer Sidebar %d', 'barlog' ), $i ), 'id' => 'footer-' . $i, 'description' => esc_html__( 'Add widgets here.', 'barlog' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } } add_action( 'widgets_init', 'barlog_widgets_init' ); } /** * Register custom sidebars from customizer. * */ if (!function_exists('barlog_customizer_sidebars')) { function barlog_customizer_sidebars() { if(Barlog()->get_setting( 'barlog_general_sidebars') && !empty(Barlog()->get_setting( 'barlog_general_sidebars'))) { $sidebars_available = Barlog()->get_setting( 'barlog_general_sidebars'); foreach ($sidebars_available as &$value) { $id = str_replace(' ', '', $value['title']); $id_lowercase = strtolower($id); if ($id_lowercase) { register_sidebar( array( 'name' => esc_html($value['title']), 'id' => esc_html($id_lowercase), 'description' => esc_html($value['title']), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } } } } add_action( 'widgets_init', 'barlog_customizer_sidebars' ); } /* ========= BLOG CLASSES ===================================== */ if ( ! function_exists( 'barlog_blog_classes_columns' ) ) { add_filter( 'barlog_blog_classes' , 'barlog_blog_classes_columns'); function barlog_blog_classes_columns($columns) { if ( Barlog()->get_setting('barlog_blog_archive_layout') == 'no-sidebar' ) { $columns = str_replace ( 'col-md-8' , 'col-md-12' , $columns ); } return $columns; } } if ( ! function_exists( 'barlog_single_post_classes_columns' ) ) { add_filter( 'barlog_single_post_classes' , 'barlog_single_post_classes_columns'); function barlog_single_post_classes_columns($columns) { if ( Barlog()->get_setting('barlog_blog_single_layout') == 'no-sidebar' ) { $columns = str_replace ( 'col-md-8' , 'col-md-12' , $columns ); } return $columns; } } /* ========= PAGINATION ===================================== */ if ( ! function_exists( 'barlog_pagination' ) ) { function barlog_pagination($query = null) { if (!$query) { global $wp_query; $query = $wp_query; } $big = 999999999; // need an unlikely integer $current = (get_query_var('paged')) ? get_query_var('paged') : ((get_query_var('page')) ? get_query_var('page') : '1'); echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, $current ), 'total' => $query->max_num_pages, 'prev_text' => esc_html__('«','barlog'), 'next_text' => esc_html__('»','barlog'), ) ); } } /* ========= BREADCRUMBS ===================================== */ if (!function_exists('barlog_breadcrumb')) { function barlog_breadcrumb() { $delimiter = ''; //text for the 'Home' link $name = esc_html__("Home", "barlog"); if (!is_home() && !is_front_page() || is_paged()) { global $post; global $product; $home = home_url(); echo '
  • ' . esc_html($name) . '
  • ' . esc_html($delimiter) . ''; if (is_category()) { global $wp_query; $cat_obj = $wp_query->get_queried_object(); $thisCat = $cat_obj->term_id; $thisCat = get_category($thisCat); $parentCat = get_category($thisCat->parent); if ($thisCat->parent != 0) echo(get_category_parents($parentCat, true, '' . esc_html($delimiter) . '')); echo '
  • ' . esc_html(single_cat_title('', false)) . '
  • '; } elseif (is_day()) { echo '
  • ' . esc_html(get_the_time('Y')) . '
  • ' . esc_html($delimiter) . ''; echo '
  • ' . get_the_time('F') . '
  • ' . esc_html($delimiter) . ' '; echo '
  • ' . get_the_time('d') . '
  • '; } elseif (is_month()) { echo '
  • ' . get_the_time('Y') . '
  • ' . esc_html($delimiter) . ''; echo '
  • ' . get_the_time('F') . '
  • '; } elseif (is_year()) { echo '
  • ' . get_the_time('Y') . '
  • '; } elseif (is_attachment()) { echo '
  • '; the_title(); echo '
  • '; } elseif (class_exists( 'WooCommerce' ) && is_shop()) { echo '
  • '; echo esc_html__('Shop','barlog'); echo '
  • '; }elseif (class_exists('WooCommerce') && is_product()) { if (get_the_category()) { $cat = get_the_category(); $cat = $cat[0]; echo '
  • ' . get_category_parents($cat, true, ' ' . esc_html($delimiter) . '') . '
  • '; } echo '
  • '; the_title(); echo '
  • '; }elseif (class_exists('WooCommerce') && is_product_category()) { echo '
  • '; single_cat_title( '', true ); echo '
  • '; }elseif (class_exists('WooCommerce') && is_product_tag()) { echo '
  • '; single_tag_title( '', true ); echo '
  • '; } elseif (is_single()) { if (get_the_category()) { $cat = get_the_category(); $cat = $cat[0]; echo '
  • ' . get_category_parents($cat, true, ' ' . esc_html($delimiter) . '') . '
  • '; } echo '
  • '; the_title(); echo '
  • '; } elseif (is_page() && !$post->post_parent) { echo '
  • '; the_title(); echo '
  • '; } elseif (is_page() && $post->post_parent) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '
  • ' . get_the_title($page->ID) . '
  • '; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb) echo wp_kses($crumb, 'link') . ' ' . esc_html($delimiter) . ' '; echo '
  • '; the_title(); echo '
  • '; } elseif (is_search()) { echo '
  • ' . get_search_query() . '
  • '; } elseif (is_tag()) { echo '
  • ' . single_tag_title( '', false ) . '
  • '; } elseif (is_author()) { global $author; $userdata = get_userdata($author); echo '
  • ' . esc_html($userdata->display_name) . '
  • '; } elseif (is_404()) { echo '
  • ' . esc_html__('404 Not Found','barlog') . '
  • '; } if (get_query_var('paged')) { if (is_home() || is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) echo '
  • '; echo esc_html__('Page','barlog') . ' ' . get_query_var('paged'); if (is_home() || is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) echo '
  • '; } } } } /** * Returns the selected header on page (custom field) */ function barlog_get_page_header_template(){ if (is_page()) { $customizer_header = get_post_meta( get_the_ID(), 'mt_header_custom_variant', true ); if (isset($customizer_header) && !empty($customizer_header)) { return $customizer_header; }else{ return false; } }else{ return false; } } function barlog_breadcrumbs_alignment() { $alignment = Barlog()->get_setting( 'barlog_breadcrumbs_alignment' ); if ($alignment) { return 'barlog-alignment-'.esc_attr($alignment); } } add_filter( 'barlog_breadcrumbs_classes', 'barlog_breadcrumbs_alignment' ); //GET HEADER TITLE/BREADCRUMBS AREA if (!function_exists('barlog_header_title_breadcrumbs')) { function barlog_header_title_breadcrumbs(){ echo '
    '; echo '
    '; echo '
    '; if(!function_exists('bcn_display')){ echo '
    '; echo ''; echo '
    '; } else { echo '
    '; echo ''; echo '
    '; } echo '
    '; if (is_singular('post')) { echo '

    '.get_the_title().'

    '; }elseif (is_page()) { echo '

    '.get_the_title().'

    '; }elseif (is_singular('product')) { echo '

    '.esc_html__( 'Shop', 'barlog' ) . get_search_query().'

    '; }elseif (is_search()) { echo '

    '.esc_html__( 'Search Results for: ', 'barlog' ) . get_search_query().'

    '; }elseif (is_category()) { echo '

    '.esc_html__( 'Category: ', 'barlog' ).' '.single_cat_title( '', false ).'

    '; }elseif (is_tag()) { echo '

    '.esc_html__( 'Tag: ', 'barlog' ) . single_tag_title( '', false ).'

    '; }elseif (is_author() || is_archive()) { if (function_exists("is_shop") && is_shop()) { echo '

    '.esc_html__( 'Shop ', 'barlog' ).'

    '; }else{ echo '

    '.get_the_archive_title().'

    '; } }elseif (is_home()) { echo '

    '.esc_html__( 'From the Blog', 'barlog' ).'

    '; } echo'
    '; echo'
    '; echo'
    '; echo'
    '; } if (Barlog()->get_setting('barlog_enable_breadcrumbs') == 1) { // Hooks on pages, posts, cart, checkout add_action('barlog_before_main_content','barlog_header_title_breadcrumbs'); // Hooks on single product add_action('woocommerce_before_main_content','barlog_header_title_breadcrumbs'); } } function barlog_breadcrumbs_excludes(){ $breadcrumbs_on_off = get_post_meta( get_the_ID(), 'mt_breadcrumbs_on_off',true ); $classes = get_body_class(); if ( class_exists( "BuddyPress" ) || class_exists('Youzify') ) { if (in_array('buddypress',$classes) && !in_array('group-home',$classes) && !in_array('bp-user', $classes) || in_array('profile-edit', $classes)) { add_action('barlog/main/before','barlog_header_title_breadcrumbs'); } } if ( class_exists( "Tribe__Template" )) { if (in_array('post-type-archive-tribe_events',$classes) || in_array('single-tribe_events',$classes)) { add_action('barlog/main/before','barlog_header_title_breadcrumbs'); } } if (isset($breadcrumbs_on_off) && $breadcrumbs_on_off == 'no') { remove_action('barlog_before_main_content','barlog_header_title_breadcrumbs'); } } add_action('wp', 'barlog_breadcrumbs_excludes'); //* BLOG - Left Sidebar Part*// if (!function_exists('barlog_blog_left_sidebar_part')) { function barlog_blog_left_sidebar_part(){ $sidebar = "sidebar-1"; if ( Barlog()->get_setting('barlog_blog_archive_layout') == 'left-sidebar' && is_active_sidebar( $sidebar )) { echo ''; } } } add_action('barlog_before_blog_content', 'barlog_blog_left_sidebar_part'); //* BLOG - Right Sidebar Part*// if (!function_exists('barlog_blog_right_sidebar_part')) { function barlog_blog_right_sidebar_part(){ $sidebar = "sidebar-1"; if ( Barlog()->get_setting('barlog_blog_archive_layout') == 'right-sidebar' && is_active_sidebar( $sidebar )) { echo ''; } } } add_action('barlog_after_blog_pagination', 'barlog_blog_right_sidebar_part'); //* SINGLE POST - Left Sidebar Part*// if (!function_exists('barlog_post_left_sidebar_part')) { function barlog_post_left_sidebar_part(){ $sidebar = "sidebar-1"; if ( Barlog()->get_setting('barlog_blog_single_layout') == 'left-sidebar' ) { echo ''; } } } add_action('barlog_before_single_post_content', 'barlog_post_left_sidebar_part'); //* SINGLE POST - Right Sidebar Part*// if (!function_exists('barlog_post_right_sidebar_part')) { function barlog_post_right_sidebar_part(){ $class = "col-md-8 col-md-offset-2"; $sidebar = "sidebar-1"; if ( Barlog()->get_setting('barlog_blog_single_layout') == 'right-sidebar' ) { echo ''; } } } add_action('barlog_after_post_content', 'barlog_post_right_sidebar_part'); // Function to handle the thumbnail request function barlog_get_the_post_thumbnail_src($img) { return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : ''; } # Custom Comments /** * Custom comment walker for this theme. * */ if ( ! class_exists( 'Barlog_Walker_Comment' ) ) { class Barlog_Walker_Comment extends Walker_Comment { /** * Outputs a comment in the HTML5 format. * * @see wp_list_comments() * @see https://developer.wordpress.org/reference/functions/get_comment_author_url/ * @see https://developer.wordpress.org/reference/functions/get_comment_author/ * @see https://developer.wordpress.org/reference/functions/get_avatar/ * @see https://developer.wordpress.org/reference/functions/get_comment_reply_link/ * @see https://developer.wordpress.org/reference/functions/get_edit_comment_link/ * * @param WP_Comment $comment Comment to display. * @param int $depth Depth of the current comment. * @param array $args An array of arguments. */ protected function html5_comment( $comment, $depth, $args ) { $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; ?> < id="comment-" has_children ? 'parent' : '', $comment ); ?>>
    ', $comment_author_url ); echo get_avatar( $comment, $args['avatar_size'] ); } } printf( '%1$s%2$s', esc_html( $comment_author ), esc_html__( '', 'barlog' ) ); if ( ! empty( $comment_author_url ) ) { echo ''; } ?>
    comment_approved ) { ?>

    'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '', 'after' => '', ) ) ); $by_post_author = barlog_is_comment_by_post_author( $comment ); if ( $comment_reply_link || $by_post_author ) { ?>
    user_id > 0 ) { $user = get_userdata( $comment->user_id ); $post = get_post( $comment->comment_post_ID ); if ( ! empty( $user ) && ! empty( $post ) ) { return $comment->user_id === $post->post_author; } } return false; } /** * Function: Popup */ if ( !function_exists( 'barlog_popup_modal' ) ) { function barlog_popup_modal() { $user_url = get_permalink( get_option('woocommerce_myaccount_page_id') ); $img_id = get_theme_mod( 'barlog_popup_image' ); $image = Barlog()->get_media( $img_id, 'full' ); echo'
    '; } if (Barlog()->get_setting('barlog_enable_popup') == 1) { add_action('barlog/before-site-content', 'barlog_popup_modal'); } } /** * Function: Preloader */ if ( !function_exists( 'barlog_preloader' ) ) { function barlog_preloader() { $img_id = get_theme_mod( 'barlog_preloader_image' ); $image = Barlog()->get_media( $img_id, 'full' ); echo '
    '; if($image) { echo ''.esc_attr(get_bloginfo()).''; } echo '
    '; } if (Barlog()->get_setting('barlog_enable_preloader') == 1) { add_action('barlog/before-site-content', 'barlog_preloader'); } }