WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#28902 closed defect (bug) (invalid)

Row actions do now follow filter on ajax update

Reported by: aubreypwd Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9.1
Component: Taxonomy Keywords: close reporter-feedback
Focuses: Cc:

Description

Once a filter has been set for (at least in my application) a custom taxonomy to remove certain row actions on the terms list it persists except when adding a new row to the list via Ajax (see video).

To replicate:

Create a filter to remove row actions for a filter, like so:

// Common edits to the row_actions for tax.
function ihcrs_tax_row_actions_common( $actions ) {

	// Remove Quick Edit
	unset( $actions['inline hide-if-no-js'] );

	// Remove Preview
	unset( $actions['view'] );

	// Remove Trash for non admin users.
	if( ! current_user_can( 'manage_options' ) ) {
		if( isset( $actions['trash'] ) ) {
			unset( $actions['trash'] );
		}

		if( isset( $actions['delete'] ) ) {
			unset( $actions['delete'] );
		}
	}

	return $actions;
}

// Clean up row actions.
add_filter(
	'ihcrs_facility_row_actions',
	'ihcrs_tax_row_actions_common'
);

Now, go and see that View and Quick Edit have been removed from the terms list (may need to add a few). Add a new term via the left panel and let Ajax do it's job. Observe that the newly added row (top) have default row actions despite the filter.

https://i.cloudup.com/BhHyvrNUPF.png

Change History (3)

#1 @aubreypwd
4 years ago

http://youtu.be/KtsqHEJ7vsw

Video explanation of the description.

#2 @johnbillion
4 years ago

  • Keywords close reporter-feedback added

I'm unable to reproduce this issue. Using the code you supplied above (after registering a 'ihcrs_facility' taxonomy) the action links in the AJAX response are removed as expected.

Do you have some logic somewhere else which means the file that contains this code isn't included in AJAX requests?

I would try to reduce your code down to just the relevant bits (the taxonomy registration and the actions filter) and see if the problem persists.

#3 @boonebgorges
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Following up on johnbillion's comment above: it's possible that the file where you're doing the add_action() call is not being included during AJAX calls, because WP loads a bit different during AJAX. A good starting point for debugging this sort of thing is wp-admin/admin-ajax.php (and the judicious use of error_log()).

Going to close this one on the assumption that something like this is happening. If you find out it's a broader problem, please reopen with details. Thanks!

Note: See TracTickets for help on using tickets.