Add output and filter for card attributes
This commit is contained in:
parent
c69e7075cd
commit
abecf5249f
@ -97,6 +97,15 @@ Filters the array of breadcrumb tuples inside the `fictioneer_get_breadcrumbs( $
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_card_attributes', $post, $context )`
|
||||
Filters the intermediate output array of HTML attributes inside the `.card` element before they are rendered. The keys are used as attribute names. Make sure to account for already existing attributes.
|
||||
|
||||
**Parameters:**
|
||||
* $post (WP_Post) – The current post object.
|
||||
* $context (string|null) - Context regarding where or how the card is rendered. Unsafe.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_card_control_icons', $icons, $story_id, $chapter_id )`
|
||||
Filters the intermediate output array of the card control icons inside the `fictioneer_get_card_controls( $story_id, $chapter_id )` function before being rendered. Note that card controls will not be rendered without a story ID.
|
||||
|
||||
|
@ -156,8 +156,16 @@ $pag_args = array(
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-article-cards' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
// Start HTML ---> ?>
|
||||
<li id="article-card-<?php the_ID(); ?>" class="card _article <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li id="article-card-<?php the_ID(); ?>" class="card _article <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<article class="card__body _article polygon">
|
||||
|
||||
<div class="card__main _article">
|
||||
|
@ -63,6 +63,14 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-chapter' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<li
|
||||
@ -71,6 +79,7 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
data-story-id="<?php echo $story_id; ?>"
|
||||
data-check-id="<?php echo $post->ID; ?>"
|
||||
data-unavailable="<?php esc_attr_e( 'Unavailable', 'fictioneer' ); ?>"
|
||||
<?php echo $card_attributes; ?>
|
||||
>
|
||||
<div class="card__body polygon">
|
||||
|
||||
|
@ -78,9 +78,17 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-collection' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<li id="collection-card-<?php the_ID(); ?>" class="card _large _collection <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li id="collection-card-<?php the_ID(); ?>" class="card _large _collection <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<div class="card__header _large">
|
||||
|
@ -26,9 +26,17 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-hidden' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<li class="card _large _hidden-result <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card _large _hidden-result <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
<div class="card__main _hidden-result">
|
||||
<div class="card__content _hidden-result"><?php echo _x( 'Hidden Result', 'Hidden card.', 'fictioneer' ); ?></div>
|
||||
|
@ -26,9 +26,17 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-page' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<li id="post-card-<?php the_ID(); ?>" class="card _large _page <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li id="post-card-<?php the_ID(); ?>" class="card _large _page <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<div class="card__header _large">
|
||||
|
@ -27,9 +27,17 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-post' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<li id="post-card-<?php echo $post->ID; ?>" class="card _large _post <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li id="post-card-<?php echo $post->ID; ?>" class="card _large _post <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<div class="card__header _large">
|
||||
|
@ -55,9 +55,17 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-recommendation' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<li id="recommendation-card-<?php the_ID(); ?>" class="card _large _recommendation <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li id="recommendation-card-<?php the_ID(); ?>" class="card _large _recommendation <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<div class="card__header _large">
|
||||
|
@ -54,6 +54,14 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-story' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<li
|
||||
@ -61,6 +69,7 @@ if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
class="card _large _story <?php echo implode( ' ', $card_classes ); ?>"
|
||||
data-story-id="<?php echo $post->ID; ?>"
|
||||
data-check-id="<?php echo $post->ID; ?>"
|
||||
<?php echo $card_attributes; ?>
|
||||
>
|
||||
<div class="card__body polygon">
|
||||
|
||||
|
@ -154,9 +154,17 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
if ( ++$card_counter > $args['count'] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-latest-chapters-compact' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card watch-last-clicked _small _info _chapter <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card watch-last-clicked _small _info _chapter <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<button class="card__info-toggle toggle-last-clicked" aria-label="<?php esc_attr_e( 'Open info box', 'fictioneer' ); ?>"><i class="fa-solid fa-chevron-down"></i></button>
|
||||
|
@ -156,9 +156,17 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
if ( ++$card_counter > $args['count'] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-latest-chapters' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card _small _chapter <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card _small _chapter <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<div class="card__main _grid _small">
|
||||
|
@ -115,9 +115,17 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-latest-recommendations-compact' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card watch-last-clicked _small _recommendation <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card watch-last-clicked _small _recommendation <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<?php if ( $show_taxonomies ) : ?>
|
||||
|
@ -134,9 +134,17 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$url = $urls[0];
|
||||
$tuple = explode( '|', $url );
|
||||
$tuple = array_map( 'trim', $tuple );
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-latest-recommendations' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card _small _recommendation <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card _small _recommendation <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<div class="card__main _grid _small">
|
||||
|
@ -139,9 +139,17 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-latest-stories-compact' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card watch-last-clicked _small _story <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card watch-last-clicked _small _story <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<?php if ( $show_taxonomies ) : ?>
|
||||
|
@ -131,9 +131,17 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-latest-stories' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card _small _story <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card _small _story <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<div class="card__main _grid _small">
|
||||
|
@ -169,9 +169,17 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
if ( ++$card_counter > $args['count'] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-latest-updates-compact' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card watch-last-clicked _small _info _story-update <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card watch-last-clicked _small _info _story-update <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<button class="card__info-toggle toggle-last-clicked" aria-label="<?php esc_attr_e( 'Open info box', 'fictioneer' ); ?>"><i class="fa-solid fa-chevron-down"></i></button>
|
||||
|
@ -172,9 +172,17 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
if ( ++$card_counter > $args['count'] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'shortcode-latest-updates' );
|
||||
$card_attributes = '';
|
||||
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="card _small _story-update <?php echo implode( ' ', $card_classes ); ?>">
|
||||
<li class="card _small _story-update <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<div class="card__main _grid _small">
|
||||
|
Loading…
x
Reference in New Issue
Block a user