Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend the Comment Edit Link Block with More Moderation Options #53686

Open
DangitRick opened this issue Aug 15, 2023 · 2 comments
Open

Extend the Comment Edit Link Block with More Moderation Options #53686

DangitRick opened this issue Aug 15, 2023 · 2 comments
Labels
[Block] Comments Affects the Comments Block - formerly known as Comments Query Loop Needs Design Feedback Needs general design feedback. [Type] Feature New feature to highlight in changelogs.

Comments

@DangitRick
Copy link

What problem does this address?

Currently, we can add the Comment Edit Link Block to our themes to get an Edit link when viewing comments while logged in. However, if we need to perform other actions on the comment, it takes multiple interactions and involves leaving the frontend of the site and the flow of the comments which you may be reading. Actions like trashing a comment, unapproving a comment, or marking a comment as spam can be a one-click action from the frontend.

What is your proposed solution?

For the longest time, I've been making moderation easier on the sites I manage — not all of my blogging fam are as comfortable with all the admin panel forms as I am, and they often read comments by visiting posts themselves to see them in the correct flow.

It would be nice to either be able to expand the Comment Edit Link Block with an option that adds additional moderation buttons or to have a separate block that can be added called Comment Moderation Links Block, for example.

I don't know the first thing about JavaScript programming and making Gutenberg blocks, so I can only offer the code I was using on my pre-FSE sites, which filters the edit comment link to add the other moderation links:

function shareable_add_comment_moderation_links( $moderation_links ) {
	$comment_id = get_comment_id();
	$nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment_id" ) );

	# Mark comment as spam
	$moderation_links .= '<a target="_self" href="' . admin_url( "comment.php?action=spam&c=$comment_id" ) . '" title="mark this comment as spam">Spam</a>';
	# Return comment to moderation queue
	$moderation_links .= '<a target="_self" href="' . admin_url( "comment.php?c=$comment_id&action=unapprovecomment&$nonce" ) . '" title="unapprove this comment">Unapprove</a>';
	# Delete comment
	$moderation_links .= '<a target="_self" href="' . admin_url( "comment.php?action=trash&c=$comment_id" ) . '" title="trash this comment">Trash</a>';

	return $moderation_links;
}
add_filter( 'edit_comment_link', 'shareable_add_comment_moderation_links', 1 );

Alternatively (and my preferred option), having the ability to filter the output of blocks just as we could core output before the FSE was a thing would amazing.

It was recommended that I open a request here in this support post.

@jorgefilipecosta jorgefilipecosta added [Type] Feature New feature to highlight in changelogs. [Block] Comments Affects the Comments Block - formerly known as Comments Query Loop Needs Design Needs design efforts. labels Aug 15, 2023
@DangitRick
Copy link
Author

My "alternatively…" line at the end looks to already be under consideration over at #39439.

So feel free to ignore that line. :)

@jasmussen
Copy link
Contributor

Thanks for the issue.

Designwise I would think that this can be solved by having additional blocks for spam, unapprove, and trash, just like there is one for edit:

Screenshot 2023-08-16 at 11 22 17 Screenshot 2023-08-16 at 11 22 21

I'd be happy to create icons for these once a PR gets spun up. In the mean time, I'll update the labels!

@jasmussen jasmussen added Needs Design Feedback Needs general design feedback. and removed Needs Design Needs design efforts. labels Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Comments Affects the Comments Block - formerly known as Comments Query Loop Needs Design Feedback Needs general design feedback. [Type] Feature New feature to highlight in changelogs.
Projects
None yet
Development

No branches or pull requests

3 participants