is_blog() && 'grid' == $blog_layout ) {
$classes[] = 'blog-grid';
}
return $classes;
}
public function excerpt_length() {
$excerpt_length = get_theme_mod( 'blog_excerpt_length', 20 );
return absint( $excerpt_length );
}
public function excerpt_more() {
return sprintf( ' %2$s',
get_permalink( get_the_ID() ),
__( '...', 'shapla' )
);
}
public function blog() {
$show_author_avatar = get_theme_mod( 'show_blog_author_avatar', true );
$show_tag_list = get_theme_mod( 'show_blog_tag_list', true );
$show_comments_link = get_theme_mod( 'show_blog_comments_link', true );
$blog_layout = get_theme_mod( 'blog_layout', 'grid' );
if ( 'grid' != $blog_layout ) {
return;
}
remove_action( 'shapla_loop_post', 'shapla_post_thumbnail', 10 );
remove_action( 'shapla_loop_post', 'shapla_post_header', 10 );
remove_action( 'shapla_loop_post', 'shapla_post_meta', 20 );
remove_action( 'shapla_loop_post', 'shapla_post_content', 30 );
?>
post_thumbnail(); ?>
post_tag(); ?>
the_title_attribute( 'echo=0' ) )
);
$_thumbnail = sprintf( '%s',
esc_url( get_permalink() ),
$post_thumbnail
);
if ( ! $echo ) {
return $_thumbnail;
}
echo $_thumbnail;
}
public function post_category( $echo = true ) {
$show_category_list = get_theme_mod( 'show_blog_category_list', true );
if ( $show_category_list ) {
$categories_list = get_the_category_list( esc_html__( ', ', 'shapla' ) );
if ( $categories_list ) {
echo '' . $categories_list . '
';
}
}
}
public function post_tag( $echo = true ) {
$show_tag_list = get_theme_mod( 'show_blog_tag_list', false );
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'shapla' ) );
$html = '';
if ( $show_tag_list && $tags_list ) {
$html .= '';
$html .= $tags_list;
$html .= '
';
}
if ( ! $echo ) {
return $html;
}
echo $html;
}
/**
* @param bool $echo
*
* @return string
*/
public function post_title( $echo = true ) {
$title = sprintf(
'',
esc_url( get_permalink() ),
get_the_title()
);
if ( ! $echo ) {
return $title;
}
echo $title;
}
/**
* Get blog entry author
*
* @param bool $echo
*
* @return string
*/
public function post_author( $echo = true ) {
$_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 .= '';
if ( $_author_avatar ) {
$html .= '' . get_avatar( get_the_author_meta( 'ID' ), 20 ) . ' ';
}
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 .= '';
if ( ! $echo ) {
return $html;
}
echo $html;
}
/**
* Get blog entry date
*
* @param bool $echo
*
* @return string
*/
public function post_date( $echo = true ) {
$show_date = get_theme_mod( 'show_blog_date', true );
$blog_date_format = get_theme_mod( 'blog_date_format', 'human' );
if ( $show_date ) {
$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 )
);
$date_string = sprintf(
'%s',
esc_url( get_permalink() ),
$time_string
);
if ( ! $echo ) {
return $date_string;
}
echo $date_string;
}
}
/**
* Check if it is a blog page
*
* @return bool
*/
private function is_blog() {
return (
is_archive() ||
is_author() ||
is_category() ||
is_home() ||
is_search() ||
is_tag()
) &&
'post' == get_post_type();
}
}
endif;
return new Shapla_Blog();