Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 7 years ago

Last modified 7 years ago

#4449 closed enhancement (wontfix)

Move to custom AJAX handler

Reported by: boonebgorges's profile 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)

#1 @johnjamesjacoby
12 years ago

  • Milestone changed from 1.7 to 1.8
  • Type changed from defect (bug) to enhancement

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.

#2 @r-a-y
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 @boonebgorges
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

#4 @DJPaul
8 years ago

  • Component changed from Appearance - Template Parts to Templates

#5 @DJPaul
7 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing most tickets related to BP-Default and BP-Legacy, since the upcoming BP-Nouveau template pack (planned for 3.0) will make these redundant.

#6 @DJPaul
7 years ago

Closing most tickets related to BP-Default and BP-Legacy, since the upcoming BP-Nouveau template pack (planned for 3.0) will make these redundant.

Note: See TracTickets for help on using tickets.