I had no interest in installing a bunch of JavaScript tools on my computer, but I did eventually accomplish what I wanted, I think. I was able to use the plugin Lazy Blocks to create a block and use it in the FSE.
Edit: False alarm. While it looks like the code was working — I get my moderation links output… they’re being output with a comment ID of 0. Evidently despite being in the comment block in the FSE, WordPress isn’t allowing it to see which comment is currently being rendered. The frustrations never end…
Here’s my almost-working code I’m using in Lazy Blocks in the Frontend box for my block. Removing the get_comment() check at the top allows the links to load, but they point to comment #0, which of course doesn’t exist.
<?php
if ( current_user_can( 'moderate_comments' ) && get_comment() ) {
$moderation_links = '';
$comment_id = get_comment_id();
$nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment_id" ) );
$moderation_links .= '<div class="wp-block-comment-edit-link">' . "\n\t";
# 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>';
$moderation_links .= "\n</div>";
echo $moderation_links;
}
?>
-
This reply was modified 1 year, 3 months ago by Rick Beckman. Reason: my problem wasn't fixed