Add fictioneer_filter_comment_actions filter

This commit is contained in:
Tetrakern 2024-05-27 21:04:03 +02:00
parent 609e631e92
commit 00265f4db3
5 changed files with 50 additions and 10 deletions

View File

@ -389,6 +389,17 @@ Filters the queried comments in the `comments.php` template and `fictioneer_ajax
---
### `apply_filters( 'fictioneer_filter_comment_actions', $output, $comment, $args, $depth )`
Filters the intermediate output array of comment actions before it is imploded and rendered. The `$args` parameter also includes the keys `'has_private_ancestor'` (bool), `'has_closed_ancestor'` (bool), and `'sticky'` (bool).
**Parameters:**
* $output (array) - HTML snippets of actions. Normally just `'reply'` (if allowed). Can be empty.
* $comment (WP_Comment) The comment object.
* $args (array) Arguments passed to `fictioneer_theme_comment()` plus extension.
* $depth (int) Depth of the comment.
---
### `apply_filters( 'fictioneer_filter_comment_badge', $output, $user, $args )`
Filters the HTML of the `fictioneer_get_comment_badge( $user, $comment, $post_author_id )` function before it is returned for rendering. The badge class and label are inserted into `<div class="fictioneer-comment__badge CLASS"><span>LABEL</span></div>`. Possible label classes are `is-author`, `is-admin`, `is-moderator`, `is-supporter`, and `badge-override`.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -665,11 +665,15 @@ if ( ! function_exists( 'fictioneer_theme_comment' ) ) {
// (PRIVATE) REPLY BUTTON
// =============================================================================
?>
<?php if ( $can_comment && ! $is_offensive && ! ( $is_report_hidden && ! $is_ignoring_reports ) ) : ?>
<?php if ( ! ( $is_report_hidden && ! $is_ignoring_reports ) ) : ?>
<div class="fictioneer-comment__actions"><?php
$caption = $comment->comment_type === 'private' || $is_child_of_private ? __( 'Private Reply', 'fictioneer' ) : __( 'Reply', 'fictioneer' );
$actions = [];
comment_reply_link(
if ( ! $is_offensive && $can_comment ) {
$caption = $comment->comment_type === 'private' || $is_child_of_private ?
__( 'Private Reply', 'fictioneer' ) : __( 'Reply', 'fictioneer' );
$actions['reply'] = get_comment_reply_link(
array_merge(
$args,
array(
@ -681,6 +685,24 @@ if ( ! function_exists( 'fictioneer_theme_comment' ) ) {
),
$comment
);
}
$actions = apply_filters(
'fictioneer_filter_comment_actions',
$actions,
$comment,
array_merge(
$args,
array(
'has_private_ancestor' => $is_child_of_private,
'has_closed_ancestor' => $closed_ancestor,
'sticky' => $is_sticky
)
),
$depth
);
echo implode( '', $actions );
?></div>
<?php endif; ?>
<?php

View File

@ -636,6 +636,13 @@
}
}
&__actions {
display: flex;
align-items: flex-start;
flex-wrap: wrap;
gap: 12px;
}
&__fingerprint {
cursor: help;