';
foreach ( $terms as $term ) {
$html .= sprintf(
'%s',
esc_url( get_term_link( $term ) ),
esc_html( $term->name )
);
}
$html .= '';
return $html;
}
/**
* Render the post title (heading with permalink).
*/
protected static function el_title( $permalink, $title, $show_title, $title_level ) {
if ( 'on' !== $show_title ) {
return '';
}
$tag = in_array( $title_level, array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ), true ) ? $title_level : 'h4';
return sprintf(
'<%1$s class="dtq-post-title">%3$s%1$s>',
$tag,
$permalink,
esc_html( $title )
);
}
/**
* Render the trimmed post excerpt.
*/
protected static function el_excerpt( $show_excerpt, $content_length ) {
if ( 'on' !== $show_excerpt ) {
return '';
}
$excerpt = get_the_excerpt();
if ( empty( $excerpt ) ) {
$excerpt = get_the_content();
}
$excerpt = wp_strip_all_tags( strip_shortcodes( $excerpt ) );
if ( $content_length > 0 && dtq_strlen( $excerpt ) > $content_length ) {
$excerpt = dtq_substr( $excerpt, 0, $content_length ) . '…';
}
return sprintf( '
%s
', esc_html( $excerpt ) );
}
/**
* Render the author element. Layouts 1 and 5 render an avatar image inline;
* layouts 2/3/4 render an SVG user icon.
*/
protected static function el_author( $show_author, $layout ) {
if ( 'on' !== $show_author ) {
return '';
}
$author_name = esc_html( get_the_author() );
$author_link = esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) );
$use_avatar = in_array( $layout, array( 'layout1', 'layout5' ), true );
if ( $use_avatar ) {
$avatar = get_avatar_url( get_the_author_meta( 'ID' ), array( 'size' => 52 ) );
$img = $avatar
? sprintf( '
', esc_url( $avatar ), $author_name )
: '';
return sprintf(
'',
$img,
$author_link,
$author_name
);
}
$svg = function_exists( 'dtq_get_svg_user_icon' ) ? dtq_get_svg_user_icon() : '';
$svg = str_replace( '