term_id ) ); $comma = (++$i === $numItems) ? '' : ', '; $post_category .= sprintf( ''.$category->name.'' . $comma ); } echo '
'.esc_html__('Filed under','kepler_theme').' ' . $post_category . '
'; // WPCS: XSS OK. } endif; if ( ! function_exists( 'kepler_theme_post_grid_title' ) ) : /** * Prints HTML Title for Grid. */ function kepler_theme_post_grid_title($extraClass = null, $show_all_text) { echo '

'; $limiter = 75; if($extraClass): $limiter = 90; endif; if($show_all_text): $limiter = 100; endif; echo mb_strimwidth(get_the_title(), 0, $limiter, '...'); echo '

'; } endif; if ( ! function_exists( 'kepler_theme_get_avatar' ) ) : /** * Prints Author Avatar. */ function kepler_theme_get_avatar() { echo '
'.get_avatar( get_the_author_meta( 'ID' ), 64 ).'
'; } endif; if ( ! function_exists( 'kepler_theme_author_info' ) ) : /** * Prints Author info. */ function kepler_theme_author_info($hide_profile_pic) { $avatar_string = ''; $details_string = ''; if ( 'post' === get_post_type() ) { if(!$hide_profile_pic){ $avatar_string = '
'.get_avatar( get_the_author_meta( 'ID' ), 64 ).'
'; } if(get_the_author_meta('first_name')){ $authorname = get_the_author_meta('first_name').' '.get_the_author_meta('last_name'); } else{ $authorname = get_the_author_meta('nickname'); } $bio = ""; if(get_the_author_meta('description')){ $bio = '

'.esc_html(get_the_author_meta('description')).'

'; } else { $bio .= '

@'.esc_html(get_the_author_meta('nickname')).' This is a sample bio. You can change it from WordPress Dashboard, Users → Biographical Info. Biographical Info

'; } $details_string = '
'.esc_html($authorname).'
'.$bio.'
'; } echo '
'.$avatar_string.$details_string.'
'; // WPCS: XSS OK. echo '
'; echo '

'.esc_html__('Published Date :','kepler_theme').''.esc_html(get_the_date()).'

'; echo '

'.esc_html__('Reading Time :','kepler_theme').'

'; echo '
'; } endif; if ( ! function_exists( 'kepler_theme_author_grid' ) ) : /** * Prints Author info in grid with category info */ function kepler_theme_author_grid() { $avatar_string = ''; $details_string = ''; //Get Categories $post_category = ''; $categories_list = get_the_category(); $numItems = count($categories_list); $i = 0; foreach($categories_list as $category){ $link = esc_url( get_category_link( $category->term_id ) ); $comma = (++$i === $numItems) ? '' : ', '; $post_category .= sprintf( ''.$category->name.'' . $comma ); } if ( 'post' === get_post_type() ) { $avatar_string = '
'.get_avatar( get_the_author_meta( 'ID' ), 32 ).'
'; if(get_the_author_meta('first_name')){ $authorname = get_the_author_meta('first_name').' '.get_the_author_meta('last_name'); } else{ $authorname = get_the_author_meta('nickname'); } $details_string = '
'.esc_html($authorname).' '.__("in ","kepler_theme").$post_category.'
'; } echo '
'.$avatar_string.$details_string.'
'; // WPCS: XSS OK. } endif; if ( ! function_exists( 'kepler_theme_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function kepler_theme_posted_on() { $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( esc_html__( 'Posted on %s', 'kepler_theme' ), '' . $time_string . '' ); $byline = sprintf( esc_html__( 'by %s', 'kepler_theme' ), '' . esc_html( get_the_author() ) . '' ); echo '' . $posted_on . ' ' . $byline . ''; // WPCS: XSS OK. } endif; if ( ! function_exists( 'kepler_theme_limit_content' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function kepler_theme_limit_content($content) { // Take the existing content and return a subset of it return wp_trim_words($content, 40,'...' ); } endif; if ( ! function_exists( 'kepler_theme_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function kepler_theme_entry_footer() { // Hide category and tag text for pages. echo '
'; if ( 'post' === get_post_type() ) { /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list( esc_html__( ',', 'kepler_theme' ) ); if ( $categories_list && kepler_theme_categorized_blog() ) { printf( '' . esc_html__( 'Posted in %1$s', 'kepler_theme' ) . '', $categories_list ); // WPCS: XSS OK. } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ' ', 'kepler_theme' ) ); if ( $tags_list ) { printf( '' . esc_html__( '%1$s', 'kepler_theme' ) . '', $tags_list ); // WPCS: XSS OK. } } if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; /* translators: %s: post title */ comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment on %s', 'kepler_theme' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) ); echo ''; } echo '
'; } endif; if ( ! function_exists( 'kepler_theme_post_navigation' ) ) : /** * Custom HTML to Print Post Navigation * @link https://codex.wordpress.org/Next_and_Previous_Links */ function kepler_theme_post_navigation() { echo '
'; /* next link: wrap with div */ next_post_link('%link','Next',true); /* previous link: wrap with div */ previous_post_link( '%link','Previous',true ); echo '
'; } endif; if ( ! function_exists( 'kepler_theme_tags' ) ) : /** * Prints HTML post tags */ function kepler_theme_tags() { // Hide category and tag text for pages. echo '
'; if ( 'post' === get_post_type() ) { /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__(' ', 'kepler_theme' ) ); if ( $tags_list ) { printf( '' . esc_html__( '%1$s', 'kepler_theme' ) . '', $tags_list ); // WPCS: XSS OK. } } echo '
'; } endif; if ( ! function_exists( 'kepler_theme_post_social_share' ) ) : /** * Display social media links */ function kepler_theme_post_social_share() { // Hide category and tag text for pages. if ( 'post' === get_post_type() ) { /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list( esc_html__( ', ', 'kepler_theme' ) ); if ( $categories_list && kepler_theme_categorized_blog() ) { printf( '' . esc_html__( 'Posted in %1$s', 'kepler_theme' ) . '', $categories_list ); // WPCS: XSS OK. } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ' ', 'kepler_theme' ) ); if ( $tags_list ) { printf( '' . esc_html__( '%1$s', 'kepler_theme' ) . '', $tags_list ); // WPCS: XSS OK. } } } endif; if ( ! function_exists( 'kepler_theme_comment_form' ) ) : /** * Prints Comments Forms with User Avatar. */ function kepler_theme_comment_form() { /* Logged in user */ $user_identity = $aria_req = $commenter = $req = ""; if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); // If Logout button needed : $avatar = '
'.get_avatar( $current_user->ID, 40 ).'
'.$user_identity.'
'; } else $avatar = '

'; $comment_author = ($commenter != "") ? $commenter['comment_author'] : ""; $comment_author_email = ($commenter != "") ? $commenter['comment_author_email'] : ""; $comment_author_url = ($commenter != "") ? $commenter['comment_author_url'] : ""; //Custom Template for non logged in users $customFields = array( 'author' =>'
' .'Profile photo

' .''. ( $req ? '*' : '' ) . '

' , 'email' => '

' . ' ' . '' . ( $req ? '*' : '' ) . '

', 'url' => '

' . '' . ' ' . '

' ); $cancelIcon = kepler_theme_get_icon('kp_icon_close'); comment_form( array( 'title_reply' => '', 'cancel_reply_link' => $cancelIcon, 'comment_notes_after' => '', 'comment_notes_before' => '', 'logged_in_as' => '', 'class_submit' => 'btn', 'fields' => apply_filters('comment_form_default_fields', $customFields), 'comment_field' => $avatar, ) ); } endif; /** * Returns true if a blog has more than 1 category. * * @return bool */ function kepler_theme_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'kepler_theme_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( 'kepler_theme_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so kepler_theme_categorized_blog should return true. return true; } else { // This blog has only 1 category so kepler_theme_categorized_blog should return false. return false; } } if( ! function_exists( 'kepler_theme_comment_block' ) ): function kepler_theme_comment_block($comment, $args, $depth) { ?>
  • id="li-comment-">
  • '; $disable_comment .= kepler_theme_get_icon('kp_icon_info'); $disable_comment .= ''; $disable_comment .= esc_html__('Comments are disabled for this post', 'kepler_theme'); $disable_comment .= ''; return $disable_comment; } add_action( 'edit_category', 'kepler_theme_category_transient_flusher' ); add_action( 'save_post', 'kepler_theme_category_transient_flusher' ); /** * Truncates content of a grid post and appends trailing ... */ function kepler_theme_get_truncated_body($contentLimit, $length) { //Limit Content from overflowing $words = wp_trim_words( get_the_content(), $contentLimit, ' ...' ); $body = do_shortcode(mb_strimwidth($words, 0, $length, ' ...')); if(get_the_title() == "") { $body = ''.$body.''; } return $body; } /** * Get kepler_theme svg icons based on class name */ function kepler_theme_get_icon($icon_name) { //$icon_name = esc_html__($icon_name); $iconStyle = get_site_option("kepler_style_kit_icons"); if($iconStyle == '') { $iconStyle = 'Rounded'; } $url = get_template_directory_uri(); $icon = '
    '; $icon .='
    '; $icon .='
    '; return $icon; } /** * Get kepler_theme hero-container */ function kepler_theme_get_hero($image,$showTooltip,$getColor,$extraClass) { if($showTooltip){ $html = '
    '; }else{ $html = '
    '; } if($getColor){ $html .= 'dummy-image'; }else{ $html .= '
    '; $html .= 'dummy-image'; } $html .= '
    '; $html .= '
    '; $html .= __("Read","kepler_theme"); $html .= '
    '; $html .= '
    '; return $html; } /** * Breadcrumbs for kepler_theme */ function kepler_theme_breadcrumb() { $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $delimiter = kepler_theme_get_icon("kp_icon_chevron_right"); // delimiter between crumbs $home = 'Home'; // text for the 'Home' link $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show $before = ''; // tag before the current crumb $after = ''; // tag after the current crumb $allowed_html = array ( 'span' => array ( 'class' => array(), ), 'a' => array ( 'href' => array(), 'class' => array(), ), ); global $post; $homeLink = home_url(); if (is_home() || is_front_page()) { if ($showOnHome == 1) { echo ''; } } else { echo ''; } } // end the_breadcrumb() /* * Get 'Blog pages to show at most' value and round it * to the nearest multiple of 3 to fit the grid design */ function kepler_theme_get_posts_per_page() { $posts_per_page = (int)get_option('posts_per_page'); if($posts_per_page == 3) { return 3; } else { return floor($posts_per_page/3.0) * 3; } } /* * Get Read time for articles */ function kepler_theme_get_article_read_time() { $content = get_the_content(); $word_count = str_word_count( strip_tags($content)); $readTime = ceil($word_count/ 200); if($readTime == 0){ $readTime = 1; } return $readTime; } /* * Get List of authors in category */ function kepler_theme_list_author_in_this_cat ($with) { if (is_category()) { $current_category = get_query_var('cat'); $args = array( 'numberposts' => -1, 'category' => $current_category, 'orderby' => 'author', 'order' => 'ASC' ); } else { $tag_id = get_query_var('tag_id'); $args = array( 'numberposts' => -1, 'tag__in' => $tag_id, 'orderby' => 'author', 'order' => 'ASC' ); } $cat_posts = get_posts($args); $author_id_array = array(); $user_posts = array(); foreach( $cat_posts as $cat_post ): $user_posts[$cat_post->post_author][] = $cat_post->ID; endforeach; foreach( $user_posts as $key => $user_post ): $user_post = array_unique($user_post); $count_user_posts[$key] = count($user_post); if ($count_user_posts[$key] >= $with) { $author_id_array[] = $key; } endforeach; return $author_id_array; }