On the edit-comments.php page, I'm hooking into the comment_row_actions filter to add another link at the end. I'm copying the "Approve" link, adding another query key and value and modifying the anchor text. I want to add some comment meta based on the value of the new query key.
Approved link:
/wp-admin/comment.php?c=9999&action=approvecomment&_wpnonce=8526c66
Approved w/ meta link
/wp-admin/comment.php?c=9999&action=approvecomment&metalink=1&_wpnonce=8526c66
The URL prints out just fine so the comment_row_actions filter is performing as expected.
Since that URL calls wp_transition_comment_status()
, I'm hooking into that to check for the value of $_GET['metalink']
and setting some comment metadata off of that in the hooked function.
The edit-comments.php script loads JS that takes some traditional anchor tag links and makes them AJAX calls for approving, trashing, and unapproving comments. I would expect clicking my new link to mimic the AJAX call for the Approved link but apparently the presence of another query variable is a problem. The hooked function is running but the $_GET['metalink']
variable is not available to the function and the AJAX message/behavior is not the same as the Approve link behavior.
Best I can tell is that WordPress may be dropping the extra query variables for security reasons which is understandable.
Any suggestions for passing a variable in the url query string that will work in the AJAX environment?
document.ready
event to capture the query var and store it in a global JS var for the click handlers to access when needed.