Add footer comments to Latest Stories/Updates shortcodes
This commit is contained in:
parent
aec80b757b
commit
44b3489b50
@ -654,6 +654,7 @@ add_shortcode( 'fictioneer_latest_chapters', 'fictioneer_shortcode_latest_chapte
|
||||
* @param string|null $attr['footer_chapters'] Optional. Whether to show the story chapter count. Default true.
|
||||
* @param string|null $attr['footer_status'] Optional. Whether to show the story status. Default true.
|
||||
* @param string|null $attr['footer_rating'] Optional. Whether to show the story age rating. Default true.
|
||||
* @param string|null $attr['footer_comments'] Optional. Whether to show the post comment count. Default false.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
* @param string|null $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
*
|
||||
@ -667,6 +668,9 @@ function fictioneer_shortcode_latest_stories( $attr ) {
|
||||
// Type
|
||||
$type = sanitize_text_field( $attr['type'] ?? 'default' );
|
||||
|
||||
// Comments
|
||||
$args['footer_comments'] = filter_var( $attr['footer_comments'] ?? 0, FILTER_VALIDATE_BOOLEAN );
|
||||
|
||||
// Terms
|
||||
$args['terms'] = fictioneer_sanitize_query_var( $attr['terms'] ?? 0, ['inline', 'pills', 'none', 'false'], 'inline' );
|
||||
$args['max_terms'] = absint( ( $attr['max_terms'] ?? 10 ) ?: 10 );
|
||||
@ -763,6 +767,7 @@ add_shortcode( 'fictioneer_latest_stories', 'fictioneer_shortcode_latest_stories
|
||||
* @param string|null $attr['footer_chapters'] Optional. Whether to show the story chapter count. Default true.
|
||||
* @param string|null $attr['footer_status'] Optional. Whether to show the story status. Default true.
|
||||
* @param string|null $attr['footer_rating'] Optional. Whether to show the story/chapter age rating. Default true.
|
||||
* @param string|null $attr['footer_comments'] Optional. Whether to show the post comment count. Default false.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
* @param string|null $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
*
|
||||
@ -774,6 +779,9 @@ function fictioneer_shortcode_latest_story_updates( $attr ) {
|
||||
$args = fictioneer_get_default_shortcode_args( $attr, 4 );
|
||||
$args['single'] = filter_var( $attr['single'] ?? 0, FILTER_VALIDATE_BOOLEAN );
|
||||
|
||||
// Comments
|
||||
$args['footer_comments'] = filter_var( $attr['footer_comments'] ?? 0, FILTER_VALIDATE_BOOLEAN );
|
||||
|
||||
// Type
|
||||
$type = sanitize_text_field( $attr['type'] ?? 'default' );
|
||||
|
||||
|
@ -9,37 +9,38 @@
|
||||
* @since 4.0.0
|
||||
* @see fictioneer_clause_sticky_stories()
|
||||
*
|
||||
* @internal $args['uid'] Unique ID of the shortcode. Pattern: shortcode-id-{id}.
|
||||
* @internal $args['type'] Type argument passed from shortcode ('compact').
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'DESC'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['author_ids'] Array of author IDs. Default empty.
|
||||
* @internal $args['excluded_authors'] Array of author IDs to exclude. Default empty.
|
||||
* @internal $args['excluded_cats'] Array of category IDs to exclude. Default empty.
|
||||
* @internal $args['excluded_tags'] Array of tag IDs to exclude. Default empty.
|
||||
* @internal $args['ignore_protected'] Whether to ignore protected posts. Default false.
|
||||
* @internal $args['only_protected'] Whether to query only protected posts. Default false.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['source'] Whether to show the author. Default true.
|
||||
* @internal $args['vertical'] Whether to show the vertical variant.
|
||||
* @internal $args['seamless'] Whether to render the image seamless. Default false (Customizer).
|
||||
* @internal $args['aspect_ratio'] Aspect ratio for the image. Only with vertical.
|
||||
* @internal $args['lightbox'] Whether the image is opened in the lightbox. Default true.
|
||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['infobox'] Whether to show the info box and toggle. Default true.
|
||||
* @internal $args['terms'] Either inline, pills, none, or false. Default inline.
|
||||
* @internal $args['max_terms'] Maximum number of shown taxonomies. Default 10.
|
||||
* @internal $args['footer_chapters'] Whether to show the chapter count. Default true.
|
||||
* @internal $args['footer_words'] Whether to show the word count. Default true.
|
||||
* @internal $args['footer_date'] Whether to show the date. Default true.
|
||||
* @internal $args['footer_status'] Whether to show the status. Default true.
|
||||
* @internal $args['footer_rating'] Whether to show the age rating. Default true.
|
||||
* @internal $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
* @internal $args['uid'] Unique ID of the shortcode. Pattern: shortcode-id-{id}.
|
||||
* @internal $args['type'] Type argument passed from shortcode ('compact').
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'DESC'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['author_ids'] Array of author IDs. Default empty.
|
||||
* @internal $args['excluded_authors'] Array of author IDs to exclude. Default empty.
|
||||
* @internal $args['excluded_cats'] Array of category IDs to exclude. Default empty.
|
||||
* @internal $args['excluded_tags'] Array of tag IDs to exclude. Default empty.
|
||||
* @internal $args['ignore_protected'] Whether to ignore protected posts. Default false.
|
||||
* @internal $args['only_protected'] Whether to query only protected posts. Default false.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['source'] Whether to show the author. Default true.
|
||||
* @internal $args['vertical'] Whether to show the vertical variant.
|
||||
* @internal $args['seamless'] Whether to render the image seamless. Default false (Customizer).
|
||||
* @internal $args['aspect_ratio'] Aspect ratio for the image. Only with vertical.
|
||||
* @internal $args['lightbox'] Whether the image is opened in the lightbox. Default true.
|
||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['infobox'] Whether to show the info box and toggle. Default true.
|
||||
* @internal $args['terms'] Either inline, pills, none, or false. Default inline.
|
||||
* @internal $args['max_terms'] Maximum number of shown taxonomies. Default 10.
|
||||
* @internal $args['footer_chapters'] Whether to show the chapter count. Default true.
|
||||
* @internal $args['footer_words'] Whether to show the word count. Default true.
|
||||
* @internal $args['footer_date'] Whether to show the date. Default true.
|
||||
* @internal $args['footer_status'] Whether to show the status. Default true.
|
||||
* @internal $args['footer_rating'] Whether to show the age rating. Default true.
|
||||
* @internal $args['footer_comments'] Whether to show the post comment count. Default false.
|
||||
* @internal $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
*/
|
||||
|
||||
|
||||
@ -223,6 +224,10 @@ if ( $splide ) {
|
||||
$card_classes[] = '_no-footer-rating';
|
||||
}
|
||||
|
||||
if ( ! $args['footer_comments'] ) {
|
||||
$card_classes[] = '_no-footer-comments';
|
||||
}
|
||||
|
||||
if ( $splide ) {
|
||||
$card_classes[] = 'splide__slide';
|
||||
}
|
||||
@ -346,6 +351,10 @@ if ( $splide ) {
|
||||
$footer_items['words'] = '<span class="card__footer-words"><i class="card-footer-icon fa-solid fa-font" title="' . esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'] . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_comments'] ) {
|
||||
$footer_items['comments'] = '<span class="card__footer-comments"><i class="card-footer-icon fa-solid fa-message" title="' . esc_attr__( 'Comments', 'fictioneer' ) . '"></i> ' . get_comments_number( $post ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_date'] ) {
|
||||
$format = $args['date_format'] ?: FICTIONEER_LATEST_STORIES_FOOTER_DATE;
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
* @internal $args['footer_date'] Whether to show the story date. Default true.
|
||||
* @internal $args['footer_status'] Whether to show the story status. Default true.
|
||||
* @internal $args['footer_rating'] Whether to show the story age rating. Default true.
|
||||
* @internal $args['footer_comments'] Whether to show the post comment count. Default false.
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
*/
|
||||
@ -233,6 +234,10 @@ if ( $splide ) {
|
||||
$classes[] = '_no-footer-rating';
|
||||
}
|
||||
|
||||
if ( ! $args['footer_comments'] ) {
|
||||
$card_classes[] = '_no-footer-comments';
|
||||
}
|
||||
|
||||
if ( $splide ) {
|
||||
$classes[] = 'splide__slide';
|
||||
}
|
||||
@ -247,6 +252,21 @@ if ( $splide ) {
|
||||
) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_comments'] ) {
|
||||
$comment_count = get_comments_number( $post );
|
||||
|
||||
$meta['comments'] = '<span class="post-item-item__meta-comments">' . sprintf(
|
||||
_nx(
|
||||
'%1$s Comment',
|
||||
'%1$s Comments',
|
||||
$comment_count,
|
||||
'Comment count in Latest * shortcode (type: list).',
|
||||
'fictioneer'
|
||||
),
|
||||
number_format_i18n( $comment_count )
|
||||
) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_status'] ) {
|
||||
$meta['status'] = '<span class="post-item-item__meta-status _' . strtolower( $story['status'] ) . '">' . fcntr( $story['status'] ) . '</span>';
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
* @internal $args['footer_status'] Whether to show the status. Default true.
|
||||
* @internal $args['footer_rating'] Whether to show the age rating. Default true.
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['footer_comments'] Whether to show the post comment count. Default false.
|
||||
* @internal $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
*/
|
||||
|
||||
@ -214,6 +215,10 @@ if ( $splide ) {
|
||||
$card_classes[] = '_no-footer-rating';
|
||||
}
|
||||
|
||||
if ( ! $args['footer_comments'] ) {
|
||||
$card_classes[] = '_no-footer-comments';
|
||||
}
|
||||
|
||||
if ( $splide ) {
|
||||
$card_classes[] = 'splide__slide';
|
||||
}
|
||||
@ -333,6 +338,10 @@ if ( $splide ) {
|
||||
$footer_items['words'] = '<span class="card__footer-words"><i class="card-footer-icon fa-solid fa-font" title="' . esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'] . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_comments'] ) {
|
||||
$footer_items['comments'] = '<span class="card__footer-comments"><i class="card-footer-icon fa-solid fa-message" title="' . esc_attr__( 'Comments', 'fictioneer' ) . '"></i> ' . get_comments_number( $post ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_date'] ) {
|
||||
$format = $args['date_format'] ?: FICTIONEER_LATEST_STORIES_FOOTER_DATE;
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
* @internal $args['footer_date'] Whether to show the modified date. Default true.
|
||||
* @internal $args['footer_status'] Whether to show the story status. Default true.
|
||||
* @internal $args['footer_rating'] Whether to show the story age rating. Default true.
|
||||
* @internal $args['footer_comments'] Whether to show the post comment count. Default false.
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['infobox'] Whether to show the info box and toggle.
|
||||
* @internal $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
|
@ -43,6 +43,7 @@
|
||||
* @internal $args['footer_words'] Whether to show the chapter word count. Default true.
|
||||
* @internal $args['footer_date'] Whether to show the chapter date. Default true.
|
||||
* @internal $args['footer_rating'] Whether to show the story/chapter age rating. Default true.
|
||||
* @internal $args['footer_comments'] Whether to show the post comment count. Default false.
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
*/
|
||||
@ -246,6 +247,10 @@ if ( $splide ) {
|
||||
$classes[] = '_no-footer-rating';
|
||||
}
|
||||
|
||||
if ( ! $args['footer_comments'] ) {
|
||||
$card_classes[] = '_no-footer-comments';
|
||||
}
|
||||
|
||||
if ( $splide ) {
|
||||
$classes[] = 'splide__slide';
|
||||
}
|
||||
@ -289,6 +294,21 @@ if ( $splide ) {
|
||||
) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_comments'] ) {
|
||||
$comment_count = get_comments_number( $post );
|
||||
|
||||
$meta['comments'] = '<span class="post-item-item__meta-comments">' . sprintf(
|
||||
_nx(
|
||||
'%1$s Comment',
|
||||
'%1$s Comments',
|
||||
$comment_count,
|
||||
'Comment count in Latest * shortcode (type: list).',
|
||||
'fictioneer'
|
||||
),
|
||||
number_format_i18n( $comment_count )
|
||||
) . '</span>';
|
||||
}
|
||||
|
||||
if ( $story['rating'] && $args['footer_rating'] ) {
|
||||
$meta['rating'] = '<span class="post-item-item__meta-rating _' . strtolower( $story['rating'] ) . '">' . fcntr( $story['rating'] ) . '</span>';
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
* @internal $args['footer_date'] Whether to show the modified date. Default true.
|
||||
* @internal $args['footer_status'] Whether to show the story status. Default true.
|
||||
* @internal $args['footer_rating'] Whether to show the story age rating. Default true.
|
||||
* @internal $args['footer_comments'] Whether to show the post comment count. Default false.
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
||||
*/
|
||||
@ -238,6 +239,10 @@ if ( $splide ) {
|
||||
$card_classes[] = '_no-footer-rating';
|
||||
}
|
||||
|
||||
if ( ! $args['footer_comments'] ) {
|
||||
$card_classes[] = '_no-footer-comments';
|
||||
}
|
||||
|
||||
if ( $splide ) {
|
||||
$card_classes[] = 'splide__slide';
|
||||
}
|
||||
@ -453,6 +458,10 @@ if ( $splide ) {
|
||||
$footer_items['words'] = '<span class="card__footer-words"><i class="card-footer-icon fa-solid fa-font" title="' . esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'] . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_comments'] ) {
|
||||
$footer_items['comments'] = '<span class="card__footer-comments"><i class="card-footer-icon fa-solid fa-message" title="' . esc_attr__( 'Comments', 'fictioneer' ) . '"></i> ' . get_comments_number( $post ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['footer_date'] ) {
|
||||
$format = $args['date_format'] ?: FICTIONEER_LATEST_UPDATES_FOOTER_DATE;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user