Add filter for shortcode term nodes
This commit is contained in:
parent
dcc00ee411
commit
27823c7f8c
11
FILTERS.md
11
FILTERS.md
@ -1263,6 +1263,17 @@ Filters the intermediate output array for the meta row in list-type shortcode pa
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_shortcode_{type}_terms', $terms, $post, $args, $story_data )`
|
||||
Filters the intermediate output array of term HTML nodes (tags, genres, fandoms, etc.) in shortcodes before it is imploded and rendered, with the term IDs as keys. Type can be `latest_stories`, `latest_updates`, `latest_recommendations`, or `article_cards`. You can use `$args['type']` to further differentiate between shortcode variants.
|
||||
|
||||
**Parameters**
|
||||
* $terms (array) – Associative array of HTML nodes to be rendered.
|
||||
* $post (WP_Post) – The current post object.
|
||||
* $args (array) – Arguments passed to the shortcode.
|
||||
* $story_data (array|null) – Collection of story post data. Unsafe.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_shortcode_list_attributes', $attributes, $post, $context )`
|
||||
Filters the intermediate output array of HTML attributes inside list-type shortcodes before they are rendered. The keys are used as attribute names. Make sure to account for already existing attributes.
|
||||
|
||||
|
@ -225,34 +225,36 @@ $pag_args = array(
|
||||
|
||||
if ( $categories ) {
|
||||
foreach ( $categories as $cat ) {
|
||||
$terms[] = '<a href="' . get_category_link( $cat ) . '" class="tag-pill _inline _category">' . get_category( $cat )->name . '</a>';
|
||||
$terms[ $cat ] = '<a href="' . get_category_link( $cat ) . '" class="tag-pill _inline _category">' . get_category( $cat )->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $fandoms ) {
|
||||
foreach ( $fandoms as $fandom ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $genres ) {
|
||||
foreach ( $genres as $genre ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $characters ) {
|
||||
foreach ( $characters as $character ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_article_cards_terms', $terms, $post, $args, null );
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-recommendations' ), $terms );
|
||||
?>
|
||||
|
@ -208,28 +208,30 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
if ( $fandoms ) {
|
||||
foreach ( $fandoms as $fandom ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $genres ) {
|
||||
foreach ( $genres as $genre ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $characters ) {
|
||||
foreach ( $characters as $character ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_recommendations_terms', $terms, $post, $args, null );
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-recommendations' ), $terms );
|
||||
} else {
|
||||
|
@ -224,28 +224,30 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
if ( $fandoms ) {
|
||||
foreach ( $fandoms as $fandom ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $genres ) {
|
||||
foreach ( $genres as $genre ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $characters ) {
|
||||
foreach ( $characters as $character ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_recommendations_terms', $terms, $post, $args, null );
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-recommendations' ), $terms );
|
||||
} else {
|
||||
|
@ -270,28 +270,30 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
if ( $story['fandoms'] ) {
|
||||
foreach ( $story['fandoms'] as $fandom ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['genres'] ) {
|
||||
foreach ( $story['genres'] as $genre ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['characters'] ) {
|
||||
foreach ( $story['characters'] as $character ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_stories_terms', $terms, $post, $args, $story );
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-recommendations' ), $terms );
|
||||
} else {
|
||||
|
@ -305,7 +305,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_stories_terms', $terms, $story, $args );
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_stories_terms', $terms, $post, $args, $story );
|
||||
|
||||
echo implode( ' ', array_slice( $terms, 0, $args['max_terms'] ) );
|
||||
?></div>
|
||||
|
@ -254,29 +254,29 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
if ( $story['fandoms'] ) {
|
||||
foreach ( $story['fandoms'] as $fandom ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['genres'] ) {
|
||||
foreach ( $story['genres'] as $genre ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['characters'] ) {
|
||||
foreach ( $story['characters'] as $character ) {
|
||||
$terms[] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_stories_terms', $terms, $story, $args );
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_stories_terms', $terms, $post, $args, $story );
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-stories' ), $terms );
|
||||
|
@ -341,7 +341,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_updates_terms', $terms, $story, $args );
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_updates_terms', $terms, $post, $args, $story );
|
||||
|
||||
echo implode( ' ', array_slice( $terms, 0, $args['max_terms'] ) );
|
||||
?></div>
|
||||
|
@ -399,7 +399,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_updates_terms', $terms, $story, $args );
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_updates_terms', $terms, $post, $args, $story );
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-updates' ), $terms );
|
||||
|
Loading…
x
Reference in New Issue
Block a user