Add offensive/appropriate frontend mod menu item

This commit is contained in:
Tetrakern 2024-11-15 18:43:23 +01:00
parent a3491766e5
commit dd2d6b48f4
7 changed files with 37 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -468,6 +468,8 @@ if ( ! function_exists( 'fictioneer_comment_mod_menu' ) ) {
<?php if ( get_option( 'fictioneer_enable_ajax_comment_moderation' ) ) : ?>
<button data-id="<?php echo $comment_id; ?>" data-click="ajax-mod-action" data-action="trash"><?php _e( 'Trash', 'fictioneer' ); ?></button>
<button data-id="<?php echo $comment_id; ?>" data-click="ajax-mod-action" data-action="spam"><?php _e( 'Spam', 'fictioneer' ); ?></button>
<button data-id="<?php echo $comment_id; ?>" data-click="ajax-mod-action" data-action="offensive"><?php _e( 'Offensive', 'fictioneer' ); ?></button>
<button data-id="<?php echo $comment_id; ?>" data-click="ajax-mod-action" data-action="appropriate"><?php _e( 'Appropriate', 'fictioneer' ); ?></button>
<button data-id="<?php echo $comment_id; ?>" data-click="ajax-mod-action" data-action="unapprove"><?php _e( 'Unapprove', 'fictioneer' ); ?></button>
<button data-id="<?php echo $comment_id; ?>" data-click="ajax-mod-action" data-action="approve"><?php _e( 'Approve', 'fictioneer' ); ?></button>
<button data-id="<?php echo $comment_id; ?>" data-click="ajax-mod-action" data-action="close"><?php _e( 'Close', 'fictioneer' ); ?></button>
@ -533,7 +535,12 @@ function fictioneer_ajax_moderate_comment() {
$operation = sanitize_text_field( $_POST['operation'] );
if ( ! in_array( $operation, ['spam', 'trash', 'approve', 'unapprove', 'close', 'open', 'sticky', 'unsticky'] ) ) {
if (
! in_array(
$operation,
['spam', 'trash', 'offensive', 'appropriate', 'approve', 'unapprove', 'close', 'open', 'sticky', 'unsticky']
)
) {
wp_send_json_error( array( 'error' => 'Invalid operation.' ) );
}
@ -562,6 +569,12 @@ function fictioneer_ajax_moderate_comment() {
case 'trash':
$result = wp_set_comment_status( $comment_id, 'trash' );
break;
case 'offensive':
$result = fictioneer_update_comment_meta( $comment_id, 'fictioneer_marked_offensive', true );
break;
case 'appropriate':
$result = fictioneer_update_comment_meta( $comment_id, 'fictioneer_marked_offensive', false );
break;
case 'approve':
$result = wp_set_comment_status( $comment_id, 'approve' );
break;

2
js/comments.min.js vendored

File diff suppressed because one or more lines are too long

2
js/complete.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -90,6 +90,12 @@ function fcn_moderateComment(id, operation) {
case 'unsticky':
comment.classList.remove('_sticky');
break;
case 'offensive':
comment.classList.add('_offensive');
break;
case 'appropriate':
comment.classList.remove('_offensive');
break;
case 'approve':
comment.classList.remove('_unapproved');
break;

View File

@ -325,7 +325,7 @@
margin-top: 0;
}
button:is([data-action=sticky], [data-action=approve], [data-action=unapprove]) {
button:is([data-action=sticky], [data-action=approve], [data-action=unapprove], [data-action=offensive], [data-action=appropriate]) {
display: none;
}
}
@ -362,6 +362,18 @@
}
}
&._offensive > .fictioneer-comment__container {
[data-action=offensive] {
display: none;
}
}
&:not(._offensive) > .fictioneer-comment__container {
:is([data-action=appropriate], .moderation-note-offensive) {
display: none;
}
}
&._sticky {
position: relative;