Opened 10 years ago
Closed 9 years ago
#33523 closed defect (bug) (wontfix)
WP_List_Table sortable header links break when list table is loaded via Ajax
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.3 |
| Component: | Administration | Keywords: | close |
| Focuses: | Cc: |
Description
When using Ajax to load up a WP_List_Table with sortable columns, the column header links are broken and point to admin-ajax.php instead of the actual current URL.
This appears to be due to the following line in wp-admin/includes/class-wp-list-table.php:
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
Checking the $_SERVER variable returns the current request info, which is via admin-ajax.php, not the actual URL (current admin page) from which the Ajax request is made. This completely breaks column sorting for list tables loaded via Ajax, with the column header links pointing to something like: http://local.wordpress-trunk.dev/wp-admin/admin-ajax.php?orderby=version&order=asc instead of the proper URL.
Here's a screencast for clarity: http://recordit.co/DSsXlaUuka
Is there a workaround for this one? If not, it seems like a bug, right?
Change History (5)
#2
in reply to:
↑ description
@
10 years ago
- Version set to 4.3
#3
@
10 years ago
Would making adjustments here do anything beyond enabling Ajax-y list tables? Because if that's the only thing it'd be for, I don't like the idea of essentially explicitly saying "this is a thing you can do" because that then implies support and therefore maintaining back-compat. That's already hard enough as it is with list tables, which were always marked as private, but clearly that's disregarded so core at least tries to play nice.
Replying to McGuive7:
hi @McGuive7 I'm not the best person to give an answer and I've seen you've opted for a different solution in your plugin :) just noticed that in the terms list table, where AJAX is used for some actions (for example when creating a new category or tag), a similar issue is solved this way:
Wondering if this should be done for all the tables to allow plugins to play with AJAX. Any thoughts more than welcome. cc @wonderboymusic