[buddypress-trac] [BuddyPress] #3625: Core functions should not hook to bp_init with default priority

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Mon Sep 26 23:06:32 UTC 2011


#3625: Core functions should not hook to bp_init with default priority
-------------------------------------+------------------
 Reporter:  boonebgorges             |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  1.6
Component:  Core                     |     Version:  1.5
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+------------------

Comment (by webraket):

 I'm a little confused myself, my previous reply was incorrect, sorry.

 ~~Your patch makes this a little worse, because if you move the ajax
 function to bp_init priority=8, it also breaks (plugins hooked to bp_init
 with default priority=10) when BuddyPress "IS" loaded before the actual
 plugin.~~

 My wp_ajax plugin is only activated for the rootblog, so it's in /plugins
 instead.
 BuddyPress is actually loaded "before" this plugin.

 That's why BuddyPress calls do_action('wp_ajax_') before my plugin has
 called add_action('wp_ajax_') when they are both hooked to bp_init with
 the default priority 10.

 So yes, these BP core actions load too early, hooking into
 bp_setup_globals is the only way to get the ajax call working (for now).

 ---

 ''I thought the issue was that BP core functions were loading too
 *late*.''

 That was related to the other ticket when a plugin hooks to init from /mu-
 plugins with default priority 10.
 At that point bp_init is not called (yet), so you can't get activity slugs
 or other BuddyPress globals.

 Hooking to bp_init instead of init already fixes that problem.
 However when a developer only tests on /plugins and BuddyPress is loaded
 before the plugin, they won't have problems hooking into init. (until a
 multisite user drops their plugin into /mu-plugins)

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3625#comment:7>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list