#4449 closed enhancement (wontfix)
Move to custom AJAX handler
Reported by: | boonebgorges | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.6 |
Component: | Templates | Keywords: | needs-patch |
Cc: |
Description
In BP 1.6, hooks for AJAX actions were moved into the function bp_dtheme_register_actions()
, which is hooked to after_setup_theme with a priority of 20. Prior to BP 1.6, these add_action() calls were in the global scope, meaning that they were fired immediately after the file was included. Some themes that directly include BP core's ajax.php, however, do it at a point *later* than after_setup_theme (such as http://wordpress.org/extend/themes/elbee-elgee, which loads ajax.php at widgets_init). As a result, the AJAX handlers are never successfully hooked, and AJAX events don't work.
I'm guessing this is affecting a very small number of themes (most either supply their own ajax.php, or load it at after_setup_theme like BP does). So it's probably something that we can fix with better documentation. A post on bpdevel would probably suffice. I thought I would first open this bug ticket, though, to see if any other dev thinks there's a better solution (such as moving the hooking event into the global scope - ugly, but it would work).
Change History (6)
#2
@
11 years ago
I'd like to see us build our own theme-side AJAX handler, without the cruft of using admin-ajax.php, which sets WP_ADMIN and calls 'admin_init' also.
Did this recently for an upcoming plugin.
However, unlike bbp_do_ajax()
, I use an external file and not hooked to 'template_redirect'
.
Here's a gist to look at:
https://gist.github.com/r-a-y/5209075
#3
@
11 years ago
- Keywords needs-patch added; 2nd-opinion removed
- Milestone changed from 1.8 to Future Release
- Summary changed from Hooking ajax actions inside of function scope in BP 1.6 causes issues with some themes to Move to custom AJAX handler
I'd like to see us build our own theme-side AJAX handler, without the cruft of using admin-ajax.php, which sets WP_ADMIN and calls 'admin_init' also.
Core ticket:
See: http://core.trac.wordpress.org/ticket/12400
bbPress trunk:
See: http://bbpress.trac.wordpress.org/changeset/4548/
See: http://bbpress.trac.wordpress.org/changeset/4549/
Moving to 1.8 to give us time to reimagine how to approach this, and whether or not we like the bbPress approach enough to implement it.