Add filter for taxonomy pills groups

This commit is contained in:
Tetrakern 2023-11-30 20:53:35 +01:00
parent c3af1d6890
commit 7cba8b32a0
9 changed files with 29 additions and 10 deletions

View File

@ -1251,6 +1251,18 @@ Filters the intermediate output array of the `fictioneer_get_subscribe_options(
---
### `apply_filters( 'fictioneer_filter_taxonomy_pills_group', $group, $key, $context )`
Filters the groups passed to `fictioneer_get_taxonomy_pills(...)` before they are looped and rendered, allowing you to limit the number of taxonomies or randomize the order, for example.
Filters the source array of selected translation strings used in the theme, see `fcntr( $key, $escape )` function in `includes/functions/_utility.php`. You cannot translate the whole theme with this, but give it a personal touch.
**Parameters:**
* $group (array) Array of WP_Term objects.
* $key (string) The group type (tags, fandoms, genres, characters, or warnings).
* $context (string) The render context or location. Can be empty.
---
### `apply_filters( 'fictioneer_filter_translations', $strings )`
Filters the source array of selected translation strings used in the theme, see `fcntr( $key, $escape )` function in `includes/functions/_utility.php`. You cannot translate the whole theme with this, but give it a personal touch.

View File

@ -1082,12 +1082,13 @@ if ( ! function_exists( 'fictioneer_get_taxonomy_pills' ) ) {
* @link https://developer.wordpress.org/reference/classes/wp_term/
*
* @param array $taxonomy_groups Arrays of WP_Term objects.
* @param string $classes Additional CSS classes.
* @param string $context Optional. The render context or location.
* @param string $classes Optional. Additional CSS classes.
*
* @return string HTML for the taxonomy tags.
*/
function fictioneer_get_taxonomy_pills( $taxonomy_groups, $classes = '' ) {
function fictioneer_get_taxonomy_pills( $taxonomy_groups, $context = '', $classes = '' ) {
// Abort conditions
if ( ! is_array( $taxonomy_groups ) || count( $taxonomy_groups ) < 1) {
return '';
@ -1096,12 +1097,15 @@ if ( ! function_exists( 'fictioneer_get_taxonomy_pills' ) ) {
ob_start();
// Loop over all groups...
foreach ( $taxonomy_groups as $group ) {
foreach ( $taxonomy_groups as $key => $group ) {
// Check for empty group
if ( ! $group || ! is_array( $group ) || count( $group ) < 1 ) {
continue;
}
// Filter group
$group = apply_filters( 'fictioneer_filter_taxonomy_pills_group', $group, $key, $context );
// Process group
foreach ( $group as $taxonomy ) {
// Start HTML ---> ?>

View File

@ -125,7 +125,7 @@ function fictioneer_collection_tags_and_warnings( $args ) {
// Start HTML ---> ?>
<section class="collection__tags-and-warnings tag-group"><?php
echo fictioneer_get_taxonomy_pills( $tag_args, '_secondary' );
echo fictioneer_get_taxonomy_pills( $tag_args, 'collection_after_content', '_secondary' );
?></section>
<?php // <--- End HTML
}

View File

@ -23,7 +23,7 @@ function fictioneer_post_tags( $post_id ) {
// Start HTML ---> ?>
<section class="post__tags tag-group">
<?php echo fictioneer_get_taxonomy_pills( array( 'tags' => $tags ), '_secondary' ); ?>
<?php echo fictioneer_get_taxonomy_pills( array( 'tags' => $tags ), 'post_after_content', '_secondary' ); ?>
</section>
<?php // <--- End HTML
}

View File

@ -121,7 +121,7 @@ function fictioneer_recommendation_tags( $args ) {
// Start HTML ---> ?>
<section class="recommendation__tags tag-group">
<?php echo fictioneer_get_taxonomy_pills( $tag_args, '_secondary' ); ?>
<?php echo fictioneer_get_taxonomy_pills( $tag_args, 'recommendation_after_content', '_secondary' ); ?>
</section>
<?php // <--- End HTML
}

View File

@ -217,7 +217,7 @@ function fictioneer_story_tags_and_warnings( $args ) {
// Start HTML ---> ?>
<section class="story__tags-and-warnings tag-group padding-left padding-right"><?php
echo fictioneer_get_taxonomy_pills( $tag_args, '_secondary' );
echo fictioneer_get_taxonomy_pills( $tag_args, 'story_after_content', '_secondary' );
?></section>
<?php // <--- End HTML
}

View File

@ -43,7 +43,8 @@ $show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_pages' ) && ( $f
'fandoms' => $fandoms,
'genres' => $genres,
'characters' => $characters
)
),
'collection_header'
);
?></div>
<?php endif; ?>

View File

@ -39,7 +39,8 @@ $show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_pages' ) && ( $f
'fandoms' => $fandoms,
'genres' => $genres,
'characters' => $characters
)
),
'recommendation_header'
);
?></div>
<?php endif; ?>

View File

@ -53,7 +53,8 @@ if ( ! $thumbnail_shown ) {
'fandoms' => $story['fandoms'],
'genres' => $story['genres'],
'characters' => $story['characters']
)
),
'story_header'
);
?></div>
<div class="story__taxonomies-space"></div>