Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#18316 closed defect (bug) (invalid)

admin comments.php does not allow for non javascript custom actions in comment row action links

Reported by: commentluv's profile commentluv Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords:
Focuses: Cc:

Description

If I add a custom link to the comment_row_actions filter it works just fine as long as I have javascript enabled and 'catch' the event of a click on it and make sure that the href goes nowhere.

if the user has disabled javascript then the link will not work even if I format the href of the link in the same format as the trash link
eg.

$actions['Remove-luv'] = '<a class="removeluv" href="'.admin_url('comment.php').'?c='.$cid.'&action=removeluv&_wpnonce='.$nonce.'">Remove Luv</a>';

it cannot be processed because wp-admin/comment.php has the default in the switch($action) block set to wp_die( __('Unknown action.') );

There should be code similar to how admin-ajax.php handles custom actions.

eg. (in wp-admin/comment.php)

default:
	// there should be an existing wp_ajax_(action) added already.
	do_action( 'wp_ajax_' . $_POST['action'] );
	// do a wp_redirect here back to where it came from with helpful additional query arg
	break;

this way users that have not got javasript enabled can use the custom comment row action links and have native wordpress functions handle it instead of (like now) having the href of the link as "javascript:" or pointing to self and handling the custom action within the plugin on admin_init or load-edit-comments.php action

Change History (4)

#1 follow-up: @dd32
14 years ago

  • Component changed from General to Administration

if the user has disabled javascript then the link will not work even if I format the href of the link in the same format as the trash link eg.

Just a thought, Instead of directing the link to the comments.php file, perhaps (while you can't do it in the way you're currently trying to) you can instead direct the link to admin-post.php, handle it, and redirect back to the comments page.

#2 in reply to: ↑ 1 @commentluv
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Replying to dd32:

if the user has disabled javascript then the link will not work even if I format the href of the link in the same format as the trash link eg.

Just a thought, Instead of directing the link to the comments.php file, perhaps (while you can't do it in the way you're currently trying to) you can instead direct the link to admin-post.php, handle it, and redirect back to the comments page.

yup, good idea, it's what I kind of ended up doing. I just did an add_query_arg() with an array of the comment id, action and nonce and caught it in admin_init action and then redirect back to referring page with query args removed.

seems to work fine on all pages that show the comment row action links

I always come up with a solution precisely 2 minutes after I post to trac :-o

#3 @kawauso
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#4 @kawauso
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.