Add words and date params to Latest Updates shortcode
This commit is contained in:
parent
767f8250c5
commit
8034df2614
@ -1043,6 +1043,8 @@ Renders a multi-column grid of small cards, showing the latest four updated stor
|
|||||||
* **thumbnail:** Whether to show the thumbnail/cover image. Default `true` (Customizer setting).
|
* **thumbnail:** Whether to show the thumbnail/cover image. Default `true` (Customizer setting).
|
||||||
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
|
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
|
||||||
* **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`.
|
* **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`.
|
||||||
|
* **words:** Whether to show the word count of chapter items. Default `true`.
|
||||||
|
* **date:** Whether to show the date of chapter items. Default `true`.
|
||||||
* **class:** Additional CSS classes, separated by whitespace.
|
* **class:** Additional CSS classes, separated by whitespace.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -201,6 +201,8 @@ function fictioneer_get_default_shortcode_args( $attr, $def_count = -1 ) {
|
|||||||
'aspect_ratio' => sanitize_css_aspect_ratio( $attr['aspect_ratio'] ?? '' ),
|
'aspect_ratio' => sanitize_css_aspect_ratio( $attr['aspect_ratio'] ?? '' ),
|
||||||
'thumbnail' => filter_var( $attr['thumbnail'] ?? $thumbnail_default, FILTER_VALIDATE_BOOLEAN ),
|
'thumbnail' => filter_var( $attr['thumbnail'] ?? $thumbnail_default, FILTER_VALIDATE_BOOLEAN ),
|
||||||
'lightbox' => filter_var( $attr['lightbox'] ?? 1, FILTER_VALIDATE_BOOLEAN ),
|
'lightbox' => filter_var( $attr['lightbox'] ?? 1, FILTER_VALIDATE_BOOLEAN ),
|
||||||
|
'words' => filter_var( $attr['words'] ?? 1, FILTER_VALIDATE_BOOLEAN ),
|
||||||
|
'date' => filter_var( $attr['date'] ?? 1, FILTER_VALIDATE_BOOLEAN ),
|
||||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -628,6 +630,8 @@ add_shortcode( 'fictioneer_story_cards', 'fictioneer_shortcode_latest_stories' )
|
|||||||
* @param string|null $attr['aspect_ratio'] Optional. Aspect ratio for the image. Only with vertical.
|
* @param string|null $attr['aspect_ratio'] Optional. Aspect ratio for the image. Only with vertical.
|
||||||
* @param string|null $attr['lightbox'] Optional. Whether the thumbnail is opened in the lightbox. Default true.
|
* @param string|null $attr['lightbox'] Optional. Whether the thumbnail is opened in the lightbox. Default true.
|
||||||
* @param string|null $attr['thumbnail'] Optional. Whether to show the thumbnail. Default true (Customizer).
|
* @param string|null $attr['thumbnail'] Optional. Whether to show the thumbnail. Default true (Customizer).
|
||||||
|
* @param string|null $attr['words'] Optional. Whether to show the word count of chapter items. Default true.
|
||||||
|
* @param string|null $attr['date'] Optional. Whether to show the date of chapter items. Default true.
|
||||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||||
*
|
*
|
||||||
* @return string The captured shortcode HTML.
|
* @return string The captured shortcode HTML.
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
* @internal $args['aspect_ratio'] Aspect ratio for the image. Only with vertical.
|
* @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['lightbox'] Whether the image is opened in the lightbox. Default true.
|
||||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
||||||
|
* @internal $args['words'] Whether to show the word count of chapter items. Default true.
|
||||||
|
* @internal $args['date'] Whether to show the date of chapter items. Default true.
|
||||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -160,6 +162,14 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
$card_classes[] = '_seamless';
|
$card_classes[] = '_seamless';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! $args['words'] ) {
|
||||||
|
$card_classes[] = '_no-chapter-words';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $args['date'] ) {
|
||||||
|
$card_classes[] = '_no-chapter-dates';
|
||||||
|
}
|
||||||
|
|
||||||
// Search for viable chapters...
|
// Search for viable chapters...
|
||||||
$search_list = array_reverse( $story['chapter_ids'] );
|
$search_list = array_reverse( $story['chapter_ids'] );
|
||||||
|
|
||||||
@ -285,9 +295,19 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
</div>
|
</div>
|
||||||
<div class="card__right">
|
<div class="card__right">
|
||||||
<?php
|
<?php
|
||||||
echo fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) );
|
if ( $args['words'] ) {
|
||||||
echo '<span class="separator-dot"> • </span>';
|
echo '<span class="words">' .
|
||||||
echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter->ID )
|
fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) ) . '</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $args['words'] && $args['date'] ) {
|
||||||
|
echo '<span class="separator-dot"> • </span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $args['date'] ) {
|
||||||
|
echo '<span class="date">' .
|
||||||
|
get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter->ID ) . '</span>';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
* @internal $args['aspect_ratio'] Aspect ratio for the image. Only with vertical.
|
* @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['lightbox'] Whether the image is opened in the lightbox. Default true.
|
||||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
||||||
|
* @internal $args['words'] Whether to show the word count of chapter items. Default true.
|
||||||
|
* @internal $args['date'] Whether to show the date of chapter items. Default true.
|
||||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -164,6 +166,14 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
$card_classes[] = '_seamless';
|
$card_classes[] = '_seamless';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! $args['words'] ) {
|
||||||
|
$card_classes[] = '_no-chapter-words';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $args['date'] ) {
|
||||||
|
$card_classes[] = '_no-chapter-dates';
|
||||||
|
}
|
||||||
|
|
||||||
// Search for viable chapters...
|
// Search for viable chapters...
|
||||||
$search_list = array_reverse( $story['chapter_ids'] );
|
$search_list = array_reverse( $story['chapter_ids'] );
|
||||||
|
|
||||||
@ -291,13 +301,25 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
echo $chapter_title;
|
echo $chapter_title;
|
||||||
?></a>
|
?></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="card__right">
|
<?php if ( $args['words'] || $args['date'] ) : ?>
|
||||||
<?php
|
<div class="card__right">
|
||||||
echo fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) );
|
<?php
|
||||||
echo '<span class="separator-dot"> • </span>';
|
if ( $args['words'] ) {
|
||||||
echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter->ID )
|
echo '<span class="words">' .
|
||||||
?>
|
fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) ) . '</span>';
|
||||||
</div>
|
}
|
||||||
|
|
||||||
|
if ( $args['words'] && $args['date'] ) {
|
||||||
|
echo '<span class="separator-dot"> • </span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $args['date'] ) {
|
||||||
|
echo '<span class="date">' .
|
||||||
|
get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter->ID ) . '</span>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ol>
|
</ol>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user