$link ) { $links[ $index ] = '
  • ' . $link . '
  • '; } return $links; } /** * Add body class for blog * * @param $classes * * @return array */ public function body_classes( $classes ) { $blog_layout = get_theme_mod( 'blog_layout', 'grid' ); // Blog page if ( static::is_blog() && 'grid' == $blog_layout ) { $classes[] = 'shapla-blog-grid'; } return $classes; } /** * Filters the number of words in an excerpt. * * @return int */ public function excerpt_length() { $excerpt_length = get_theme_mod( 'blog_excerpt_length', 20 ); return absint( $excerpt_length ); } /** * Filters the string in the "more" link displayed after a trimmed excerpt. * * @return string */ public function excerpt_more() { return sprintf( '%1$s %3$s', __( '...', 'shapla' ), get_permalink( get_the_ID() ), __( 'Read more', 'shapla' ) ); } /** * Get grid blog style */ public function loop_post() { $blog_layout = get_theme_mod( 'blog_layout', 'grid' ); if ( 'grid' == $blog_layout ) { $this->get_loop_post_for_grid(); return; } $this->get_default_loop_post(); } /** * Default loop post design */ public function get_default_loop_post() { ?>
    the_title_attribute( array( 'echo' => false ) ) ) ); return sprintf( '%s', esc_url( get_permalink() ), $post_thumbnail ); } /** * Get post category * * @return string */ public static function post_category() { $show_category_list = get_theme_mod( 'show_blog_category_list', true ); $html = ''; if ( ! $show_category_list ) { return $html; } $categories_list = get_the_category_list( __( ', ', 'shapla' ) ); if ( $categories_list ) { $html .= ''; } return $html; } /** * Get post tags * * @return string */ public static function post_tag() { $show_tag_list = get_theme_mod( 'show_blog_tag_list', false ); if ( ( ! is_singular() && $show_tag_list == false ) ) { return ''; } $list = get_the_tag_list(); if ( empty( $list ) || is_wp_error( $list ) || $list == false ) { return ''; } return ''; } /** * Get post title * * @return string */ public static function post_title() { return sprintf( '

    %s

    ', esc_url( get_permalink() ), get_the_title() ); } /** * Get blog entry author * * @return string */ public static function post_author() { $author_avatar = get_theme_mod( 'show_blog_author_avatar', false ); $author_name = get_theme_mod( 'show_blog_author_name', true ); $html = ''; if ( ! $author_avatar && ! $author_name ) { return $html; } $size = 32; $html .= ''; if ( $author_avatar ) { $html .= ''; $html .= get_avatar( get_the_author_meta( 'ID' ), $size ); $html .= ' '; } if ( $author_name ) { $html .= sprintf( '%s %s', esc_html__( 'by', 'shapla' ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_html( get_the_author() ) ); } $html .= ''; return $html; } /** * Get blog entry date * * @return string */ public static function post_date() { $show_date = get_theme_mod( 'show_blog_date', true ); $blog_date_format = get_theme_mod( 'blog_date_format', 'human' ); if ( ! $show_date ) { return ''; } $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } if ( $blog_date_format == 'human' ) { $created_time = sprintf( '%s ago', human_time_diff( get_the_date( 'U' ) ) ); $modified_time = sprintf( '%s ago', human_time_diff( get_the_modified_date( 'U' ) ) ); } else { $created_time = get_the_date(); $modified_time = get_the_modified_date(); } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( $created_time ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( $modified_time ) ); return sprintf( '%s', esc_url( get_permalink() ), $time_string ); } /** * Check if it is a blog page * * @return bool */ public static function is_blog() { return ( is_post_type_archive( 'post' ) || is_category() || is_tag() || is_author() || is_home() || is_search() ); } } } return Shapla_Blog::init();