PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
← All changes | includes/core/actions.php +250 -116 2.22.6.17 View file →
@@ -2,11 +2,8 @@
2 2
3 3 /**
4 4 * bbPress Actions
5 5 *
6 - * @package bbPress
7 - * @subpackage Core
8 - *
9 6 * This file contains the actions that are used through-out bbPress. They are
10 7 * consolidated here to make searching for them easier, and to help developers
11 8 * understand at a glance the order in which things occur.
12 9 *
@@ -14,13 +11,16 @@
14 11 *
15 12 * - bbPress: In {@link bbPress::setup_actions()} in bbpress.php
16 13 * - Admin: More in {@link BBP_Admin::setup_actions()} in admin.php
17 14 *
15 + * @package bbPress
16 + * @subpackage Core
17 + *
18 18 * @see /core/filters.php
19 19 */
20 20
21 21 // Exit if accessed directly
22 -if ( !defined( 'ABSPATH' ) ) exit;
22 +defined( 'ABSPATH' ) || exit;
23 23
24 24 /**
25 25 * Attach bbPress to WordPress
26 26 *
@@ -36,23 +36,28 @@
36 36 * near the bottom of this file.
37 37 *
38 38 * v--WordPress Actions v--bbPress Sub-actions
39 39 */
40 -add_action( 'plugins_loaded', 'bbp_loaded', 10 );
41 -add_action( 'init', 'bbp_init', 0 ); // Early for bbp_register
42 -add_action( 'parse_query', 'bbp_parse_query', 2 ); // Early for overrides
43 -add_action( 'widgets_init', 'bbp_widgets_init', 10 );
44 -add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 10 );
45 -add_action( 'wp_enqueue_scripts', 'bbp_enqueue_scripts', 10 );
46 -add_action( 'wp_head', 'bbp_head', 10 );
47 -add_action( 'wp_footer', 'bbp_footer', 10 );
48 -add_action( 'set_current_user', 'bbp_setup_current_user', 10 );
49 -add_action( 'setup_theme', 'bbp_setup_theme', 10 );
50 -add_action( 'after_setup_theme', 'bbp_after_setup_theme', 10 );
51 -add_action( 'template_redirect', 'bbp_template_redirect', 10 );
52 -add_action( 'login_form_login', 'bbp_login_form_login', 10 );
53 -add_action( 'profile_update', 'bbp_profile_update', 10, 2 ); // user_id and old_user_data
54 -add_action( 'user_register', 'bbp_user_register', 10 );
40 +add_action( 'plugins_loaded', 'bbp_loaded', 10 );
41 +add_action( 'init', 'bbp_init', 0 ); // Early for bbp_register
42 +add_action( 'parse_query', 'bbp_parse_query', 2 ); // Early for overrides
43 +add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 10 );
44 +add_action( 'after_setup_theme', 'bbp_after_setup_theme', 10 );
45 +add_action( 'setup_theme', 'bbp_setup_theme', 10 );
46 +add_action( 'set_current_user', 'bbp_setup_current_user', 10 );
47 +add_action( 'profile_update', 'bbp_profile_update', 10, 2 ); // user_id and old_user_data
48 +add_action( 'user_register', 'bbp_user_register', 10 );
49 +add_action( 'login_form_login', 'bbp_login_form_login', 10 );
50 +add_action( 'template_redirect', 'bbp_template_redirect', 8 ); // Before BuddyPress's 10 [BB2225]
51 +add_action( 'widgets_init', 'bbp_widgets_init', 10 );
52 +add_action( 'wp_roles_init', 'bbp_roles_init', 10 );
53 +add_action( 'wp_enqueue_scripts', 'bbp_enqueue_scripts', 10 );
54 +add_action( 'wp_head', 'bbp_head', 10 );
55 +add_action( 'wp_footer', 'bbp_footer', 10 );
56 +add_action( 'rest_api_init', 'bbp_rest_api_init', 10 );
57 +add_action( 'xmlrpc_call', 'bbp_xmlrpc_call', 10, 3 );
58 +add_action( 'transition_post_status', 'bbp_transition_post_status', 10, 3 );
59 +add_action( 'post_updated', 'bbp_post_updated', 10, 3 );
55 60
56 61 /**
57 62 * bbp_loaded - Attached to 'plugins_loaded' above
58 63 *
@@ -65,10 +70,9 @@
65 70 add_action( 'bbp_loaded', 'bbp_includes', 6 );
66 71 add_action( 'bbp_loaded', 'bbp_setup_globals', 8 );
67 72 add_action( 'bbp_loaded', 'bbp_setup_option_filters', 10 );
68 73 add_action( 'bbp_loaded', 'bbp_setup_user_option_filters', 12 );
69 -add_action( 'bbp_loaded', 'bbp_register_theme_packages', 14 );
70 -add_action( 'bbp_loaded', 'bbp_filter_user_roles_option', 16 );
74 +add_action( 'bbp_loaded', 'bbp_pre_load_options', 14 );
71 75
72 76 /**
73 77 * bbp_init - Attached to 'init' above
74 78 *
@@ -73,37 +77,52 @@
73 77 * bbp_init - Attached to 'init' above
74 78 *
75 79 * Attach various initialization actions to the init action.
76 80 * The load order helps to execute code at the correct time.
77 - * v---Load order
81 + * v---Load order
78 82 */
79 -add_action( 'bbp_init', 'bbp_register', 0 );
80 -add_action( 'bbp_init', 'bbp_load_textdomain', 10 );
81 -add_action( 'bbp_init', 'bbp_add_rewrite_tags', 20 );
82 -add_action( 'bbp_init', 'bbp_ready', 999 );
83 +add_action( 'bbp_init', 'bbp_load_textdomain', 0 );
84 +add_action( 'bbp_init', 'bbp_register', 10 );
85 +add_action( 'bbp_init', 'bbp_add_rewrite_tags', 20 );
86 +add_action( 'bbp_init', 'bbp_add_rewrite_rules', 30 );
87 +add_action( 'bbp_init', 'bbp_add_permastructs', 40 );
88 +add_action( 'bbp_init', 'bbp_setup_engagements', 50 );
89 +add_action( 'bbp_init', 'bbp_ready', 999 );
83 90
84 91 /**
85 - * There is no action API for roles to use, so hook in immediately after the
86 - * $wp_roles global is set, which is the 'setup_theme' action.
92 + * bbp_rest_api_init - Attached to 'rest_api_init' above
93 + */
94 +add_action( 'bbp_rest_api_init', 'bbp_register_rest_attachment_controller', 5 );
95 +
96 +/**
97 + * bbp_xmlrpc_call - Attached to 'xmlrpc_call' above
98 + */
99 +add_action( 'bbp_xmlrpc_call', 'bbp_validate_xmlrpc_post', 10, 2 );
100 +
101 +/**
102 + * bbp_setup_theme - Attached to 'setup_theme' above
87 103 *
88 - * This is kind of lame, but is all we have for now.
104 + * Attach various theme related actions to the setup_theme action.
105 + * The load order helps to execute code at the correct time.
106 + * v---Load order
89 107 */
90 -add_action( 'bbp_setup_theme', 'bbp_add_forums_roles', 1 );
108 +add_action( 'bbp_setup_theme', 'bbp_register_theme_packages', 2 ); // Lower than 5
91 109
92 110 /**
93 - * When switching to a new blog, a users mapped role will get wiped out by
94 - * WP_User::for_blog() and WP_User::_init_caps().
111 + * bbp_roles_init - Attached to 'wp_roles_init' above
95 112 *
96 - * This happens naturally in multisite setups during WP_Admin_Bar::initialize(),
97 - * which is annoying because it will happen on each page-load.
113 + * Attach various role related actions to the wp_roles_init action.
114 + * The load order helps to execute code at the correct time.
115 + * v---Load order
116 + */
117 +add_action( 'bbp_roles_init', 'bbp_add_forums_roles', 8 );
118 +
119 +/**
120 + * When setting up the current user, make sure they have a role for the forums.
98 121 *
99 - * Resetting the role on blog-switch enables us to maintain the user's dynamic
100 - * role between sites. Note that if a user already has a role on that site, no
101 - * mapping will occur.
102 - *
103 - * We also hook to 'bbp_setup_current_user' -- naturally.
122 + * This is multisite aware, thanks to bbp_filter_user_roles_option(), hooked to
123 + * the 'bbp_loaded' action above.
104 124 */
105 -add_action( 'switch_blog', 'bbp_set_current_user_default_role' );
106 125 add_action( 'bbp_setup_current_user', 'bbp_set_current_user_default_role' );
107 126
108 127 /**
109 128 * bbp_register - Attached to 'init' above on 0 priority
@@ -116,13 +135,18 @@
116 135 add_action( 'bbp_register', 'bbp_register_post_statuses', 4 );
117 136 add_action( 'bbp_register', 'bbp_register_taxonomies', 6 );
118 137 add_action( 'bbp_register', 'bbp_register_views', 8 );
119 138 add_action( 'bbp_register', 'bbp_register_shortcodes', 10 );
139 +add_action( 'bbp_register', 'bbp_register_meta', 12 );
120 140
121 141 // Autoembeds
122 -add_action( 'bbp_init', 'bbp_reply_content_autoembed', 8 );
123 -add_action( 'bbp_init', 'bbp_topic_content_autoembed', 8 );
142 +add_action( 'bbp_init', 'bbp_reply_content_autoembed', 8 );
143 +add_action( 'bbp_init', 'bbp_topic_content_autoembed', 8 );
124 144
145 +// <body> class swap from "bbp-no-js" to "bbp-js"
146 +add_action( 'wp_body_open', 'bbp_swap_no_js_body_class' );
147 +add_action( 'bbp_footer', 'bbp_swap_no_js_body_class' );
148 +
125 149 /**
126 150 * bbp_ready - attached to end 'bbp_init' above
127 151 *
128 152 * Attach actions to the ready action after bbPress has fully initialized.
@@ -129,42 +153,46 @@
129 153 * The load order helps to execute code at the correct time.
130 154 * v---Load order
131 155 */
132 156 add_action( 'bbp_ready', 'bbp_setup_akismet', 2 ); // Spam prevention for topics and replies
133 -add_action( 'bp_include', 'bbp_setup_buddypress', 10 ); // Social network integration
134 157
158 +// Setup BuddyPress using its own hook
159 +add_action( 'bp_init', 'bbp_setup_buddypress', 0 ); // Social network integration
160 +
135 161 // Try to load the bbpress-functions.php file from the active themes
136 162 add_action( 'bbp_after_setup_theme', 'bbp_load_theme_functions', 10 );
137 163
138 164 // Widgets
165 +// phpcs:disable Universal.WhiteSpace.CommaSpacing.TooMuchSpaceAfter
139 166 add_action( 'bbp_widgets_init', array( 'BBP_Login_Widget', 'register_widget' ), 10 );
140 167 add_action( 'bbp_widgets_init', array( 'BBP_Views_Widget', 'register_widget' ), 10 );
168 +add_action( 'bbp_widgets_init', array( 'BBP_Search_Widget', 'register_widget' ), 10 );
141 169 add_action( 'bbp_widgets_init', array( 'BBP_Forums_Widget', 'register_widget' ), 10 );
142 170 add_action( 'bbp_widgets_init', array( 'BBP_Topics_Widget', 'register_widget' ), 10 );
143 171 add_action( 'bbp_widgets_init', array( 'BBP_Replies_Widget', 'register_widget' ), 10 );
172 +add_action( 'bbp_widgets_init', array( 'BBP_Stats_Widget', 'register_widget' ), 10 );
144 173
145 -// Template - Head, foot, errors and messages
146 -add_action( 'bbp_loaded', 'bbp_login_notices' );
147 -add_action( 'bbp_head', 'bbp_topic_notices' );
148 -add_action( 'bbp_template_notices', 'bbp_template_notices' );
174 +// Notices
175 +add_action( 'bbp_template_notices', 'bbp_template_notices', 20 );
176 +add_action( 'bbp_template_notices', 'bbp_login_notices' );
177 +add_action( 'bbp_template_notices', 'bbp_topic_notices' );
178 +add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success' );
179 +add_action( 'bbp_template_notices', 'bbp_notice_edit_user_pending_email' );
180 +add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 );
149 181
150 182 // Always exclude private/hidden forums if needed
151 -add_action( 'pre_get_posts', 'bbp_pre_get_posts_exclude_forums', 4 );
183 +add_action( 'pre_get_posts', 'bbp_pre_get_posts_normalize_forum_visibility', 4 );
152 184
153 -// Profile Page Messages
154 -add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success' );
155 -add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 );
185 +// Before Delete/Trash/Untrash Forum
186 +add_action( 'wp_trash_post', 'bbp_trash_forum' );
187 +add_action( 'trash_post', 'bbp_trash_forum' );
188 +add_action( 'untrash_post', 'bbp_untrash_forum' );
189 +add_action( 'before_delete_post', 'bbp_delete_forum' );
156 190
157 -// Before Delete/Trash/Untrash Topic
158 -add_action( 'wp_trash_post', 'bbp_trash_forum' );
159 -add_action( 'trash_post', 'bbp_trash_forum' );
160 -add_action( 'untrash_post', 'bbp_untrash_forum' );
161 -add_action( 'delete_post', 'bbp_delete_forum' );
162 -
163 -// After Deleted/Trashed/Untrashed Topic
191 +// After Deleted/Trashed/Untrashed Forum
164 192 add_action( 'trashed_post', 'bbp_trashed_forum' );
165 193 add_action( 'untrashed_post', 'bbp_untrashed_forum' );
166 -add_action( 'deleted_post', 'bbp_deleted_forum' );
194 +add_action( 'deleted_post', 'bbp_deleted_forum', 10, 2 );
167 195
168 196 // Auto trash/untrash/delete a forums topics
169 197 add_action( 'bbp_delete_forum', 'bbp_delete_forum_topics', 10 );
170 198 add_action( 'bbp_trash_forum', 'bbp_trash_forum_topics', 10 );
@@ -179,16 +207,16 @@
179 207 add_action( 'bbp_edit_forum_post_extras', 'bbp_save_forum_extras', 2 );
180 208 add_action( 'bbp_forum_attributes_metabox_save', 'bbp_save_forum_extras', 2 );
181 209
182 210 // New/Edit Reply
183 -add_action( 'bbp_new_reply', 'bbp_update_reply', 10, 6 );
184 -add_action( 'bbp_edit_reply', 'bbp_update_reply', 10, 6 );
211 +add_action( 'bbp_new_reply', 'bbp_update_reply', 10, 7 );
212 +add_action( 'bbp_edit_reply', 'bbp_update_reply', 10, 7 );
185 213
186 214 // Before Delete/Trash/Untrash Reply
187 -add_action( 'wp_trash_post', 'bbp_trash_reply' );
188 -add_action( 'trash_post', 'bbp_trash_reply' );
189 -add_action( 'untrash_post', 'bbp_untrash_reply' );
190 -add_action( 'delete_post', 'bbp_delete_reply' );
215 +add_action( 'wp_trash_post', 'bbp_trash_reply' );
216 +add_action( 'trash_post', 'bbp_trash_reply' );
217 +add_action( 'untrash_post', 'bbp_untrash_reply' );
218 +add_action( 'before_delete_post', 'bbp_delete_reply' );
191 219
192 220 // After Deleted/Trashed/Untrashed Reply
193 221 add_action( 'trashed_post', 'bbp_trashed_reply' );
194 222 add_action( 'untrashed_post', 'bbp_untrashed_reply' );
@@ -201,13 +229,16 @@
201 229 // Split/Merge Topic
202 230 add_action( 'bbp_merged_topic', 'bbp_merge_topic_count', 1, 3 );
203 231 add_action( 'bbp_post_split_topic', 'bbp_split_topic_count', 1, 3 );
204 232
233 +// Move Reply
234 +add_action( 'bbp_post_move_reply', 'bbp_move_reply_count', 1, 3 );
235 +
205 236 // Before Delete/Trash/Untrash Topic
206 -add_action( 'wp_trash_post', 'bbp_trash_topic' );
207 -add_action( 'trash_post', 'bbp_trash_topic' );
208 -add_action( 'untrash_post', 'bbp_untrash_topic' );
209 -add_action( 'delete_post', 'bbp_delete_topic' );
237 +add_action( 'wp_trash_post', 'bbp_trash_topic' );
238 +add_action( 'trash_post', 'bbp_trash_topic' );
239 +add_action( 'untrash_post', 'bbp_untrash_topic' );
240 +add_action( 'before_delete_post', 'bbp_delete_topic' );
210 241
211 242 // After Deleted/Trashed/Untrashed Topic
212 243 add_action( 'trashed_post', 'bbp_trashed_topic' );
213 244 add_action( 'untrashed_post', 'bbp_untrashed_topic' );
@@ -213,34 +244,120 @@
213 244 add_action( 'untrashed_post', 'bbp_untrashed_topic' );
214 245 add_action( 'deleted_post', 'bbp_deleted_topic' );
215 246
216 247 // Favorites
248 +add_action( 'bbp_spam_topic', 'bbp_remove_topic_from_all_favorites' );
217 249 add_action( 'bbp_trash_topic', 'bbp_remove_topic_from_all_favorites' );
218 250 add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_favorites' );
219 251
220 252 // Subscriptions
221 -add_action( 'bbp_trash_topic', 'bbp_remove_topic_from_all_subscriptions' );
222 -add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_subscriptions' );
223 -add_action( 'bbp_new_reply', 'bbp_notify_subscribers', 1, 5 );
253 +add_action( 'bbp_spam_topic', 'bbp_remove_topic_from_all_subscriptions' );
254 +add_action( 'bbp_trash_topic', 'bbp_remove_topic_from_all_subscriptions' );
255 +add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_subscriptions' );
256 +add_action( 'bbp_trash_forum', 'bbp_remove_forum_from_all_subscriptions' );
257 +add_action( 'bbp_delete_forum', 'bbp_remove_forum_from_all_subscriptions' );
224 258
259 +// Subscription notifications
260 +add_action( 'bbp_new_reply', 'bbp_notify_topic_subscribers', 11, 5 );
261 +add_action( 'bbp_new_topic', 'bbp_notify_forum_subscribers', 11, 4 );
262 +
225 263 // Sticky
226 -add_action( 'bbp_trash_topic', 'bbp_unstick_topic' );
227 -add_action( 'bbp_delete_topic', 'bbp_unstick_topic' );
264 +add_action( 'bbp_stick_topic', 'bbp_unstick_topic' );
265 +add_action( 'bbp_unapprove_topic', 'bbp_unstick_topic' );
266 +add_action( 'bbp_spam_topic', 'bbp_unstick_topic' );
267 +add_action( 'bbp_trash_topic', 'bbp_unstick_topic' );
268 +add_action( 'bbp_delete_topic', 'bbp_unstick_topic' );
228 269
229 270 // Update topic branch
230 -add_action( 'bbp_trashed_topic', 'bbp_update_topic_walker' );
231 -add_action( 'bbp_untrashed_topic', 'bbp_update_topic_walker' );
232 -add_action( 'bbp_deleted_topic', 'bbp_update_topic_walker' );
233 -add_action( 'bbp_spammed_topic', 'bbp_update_topic_walker' );
234 -add_action( 'bbp_unspammed_topic', 'bbp_update_topic_walker' );
271 +add_action( 'bbp_trashed_topic', 'bbp_update_topic_walker' );
272 +add_action( 'bbp_untrashed_topic', 'bbp_update_topic_walker' );
273 +add_action( 'bbp_deleted_topic', 'bbp_update_topic_walker' );
274 +add_action( 'bbp_spammed_topic', 'bbp_update_topic_walker' );
275 +add_action( 'bbp_unspammed_topic', 'bbp_update_topic_walker' );
276 +add_action( 'bbp_approved_topic', 'bbp_update_topic_walker' );
277 +add_action( 'bbp_unapproved_topic', 'bbp_update_topic_walker' );
235 278
236 279 // Update reply branch
237 -add_action( 'bbp_trashed_reply', 'bbp_update_reply_walker' );
238 -add_action( 'bbp_untrashed_reply', 'bbp_update_reply_walker' );
239 -add_action( 'bbp_deleted_reply', 'bbp_update_reply_walker' );
240 -add_action( 'bbp_spammed_reply', 'bbp_update_reply_walker' );
241 -add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' );
280 +add_action( 'bbp_trashed_reply', 'bbp_update_reply_walker' );
281 +add_action( 'bbp_untrashed_reply', 'bbp_update_reply_walker' );
282 +add_action( 'bbp_deleted_reply', 'bbp_update_reply_walker' );
283 +add_action( 'bbp_spammed_reply', 'bbp_update_reply_walker' );
284 +add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' );
285 +add_action( 'bbp_approved_reply', 'bbp_update_reply_walker' );
286 +add_action( 'bbp_unapproved_reply', 'bbp_update_reply_walker' );
242 287
288 +// Update counts from persisted post status changes
289 +add_action( 'bbp_transition_post_status', 'bbp_update_counts_on_transition_post_status', 10, 3 );
290 +add_action( 'bbp_transition_post_status', 'bbp_update_forum_subforum_count_on_transition_post_status', 10, 3 );
291 +
292 +// Update parent subforum counts after updates and permanent deletion
293 +add_action( 'bbp_deleted_forum', 'bbp_reparent_forum_subforums', 9, 2 );
294 +add_action( 'bbp_deleted_forum', 'bbp_update_parent_forum_subforum_count', 10, 2 );
295 +add_action( 'bbp_post_updated', 'bbp_update_forum_subforum_counts_on_post_updated', 10, 3 );
296 +
297 +// Update user topic & reply counts
298 +add_action( 'bbp_deleted_topic', 'bbp_decrease_user_topic_count' );
299 +add_action( 'bbp_deleted_reply', 'bbp_decrease_user_reply_count' );
300 +add_action( 'bbp_post_updated', 'bbp_update_counts_on_post_author_change', 10, 3 );
301 +add_action( 'bbp_post_updated', 'bbp_recalculate_engagements_on_post_author_change', 20, 3 );
302 +
303 +// Update counts and engagements after WordPress reassigns a deleted user's posts
304 +add_action( 'delete_user', 'bbp_update_counts_on_user_reassignment', 10, 2 );
305 +add_action( 'deleted_user', 'bbp_update_counts_on_user_reassignment', 10, 2 );
306 +
307 +// Topic status transition helpers for replies
308 +add_action( 'bbp_trash_topic', 'bbp_trash_topic_replies' );
309 +add_action( 'bbp_untrash_topic', 'bbp_untrash_topic_replies' );
310 +add_action( 'bbp_delete_topic', 'bbp_delete_topic_replies' );
311 +add_action( 'bbp_spam_topic', 'bbp_spam_topic_replies' );
312 +add_action( 'bbp_unspam_topic', 'bbp_unspam_topic_replies' );
313 +
314 +// Topic engagements on user creation
315 +add_action( 'bbp_new_topic', 'bbp_update_topic_engagements', 20 );
316 +add_action( 'bbp_new_reply', 'bbp_update_topic_engagements', 20 );
317 +
318 +add_action( 'bbp_new_reply', 'bbp_update_topic_voice_count', 30 );
319 +add_action( 'bbp_new_topic', 'bbp_update_topic_voice_count', 30 );
320 +
321 +// Topic engagements on code insert (unit tests)
322 +add_action( 'bbp_insert_topic', 'bbp_update_topic_engagements', 20 );
323 +add_action( 'bbp_insert_reply', 'bbp_update_topic_engagements', 20 );
324 +
325 +// Topic engagement counts on code insert (unit tests)
326 +add_action( 'bbp_insert_topic', 'bbp_update_topic_voice_count', 30 );
327 +add_action( 'bbp_insert_reply', 'bbp_update_topic_voice_count', 30 );
328 +
329 +// Recalculate engagements
330 +add_action( 'bbp_trashed_reply', 'bbp_recalculate_topic_engagements' );
331 +add_action( 'bbp_untrashed_reply', 'bbp_recalculate_topic_engagements' );
332 +add_action( 'bbp_spammed_reply', 'bbp_recalculate_topic_engagements' );
333 +add_action( 'bbp_unspammed_reply', 'bbp_recalculate_topic_engagements' );
334 +add_action( 'bbp_approved_reply', 'bbp_recalculate_topic_engagements' );
335 +add_action( 'bbp_unapproved_reply', 'bbp_recalculate_topic_engagements' );
336 +add_action( 'bbp_deleted_reply', 'bbp_recalculate_topic_engagements' );
337 +add_action( 'bbp_trashed_topic', 'bbp_recalculate_topic_engagements' );
338 +add_action( 'bbp_untrashed_topic', 'bbp_recalculate_topic_engagements' );
339 +add_action( 'bbp_spammed_topic', 'bbp_recalculate_topic_engagements' );
340 +add_action( 'bbp_unspammed_topic', 'bbp_recalculate_topic_engagements' );
341 +add_action( 'bbp_approved_topic', 'bbp_recalculate_topic_engagements' );
342 +add_action( 'bbp_unapproved_topic', 'bbp_recalculate_topic_engagements' );
343 +add_action( 'bbp_deleted_topic', 'bbp_recalculate_topic_engagements' );
344 +
345 +// Update engagement counts
346 +add_action( 'bbp_trashed_reply', 'bbp_update_topic_voice_count', 30 );
347 +add_action( 'bbp_untrashed_reply', 'bbp_update_topic_voice_count', 30 );
348 +add_action( 'bbp_spammed_reply', 'bbp_update_topic_voice_count', 30 );
349 +add_action( 'bbp_unspammed_reply', 'bbp_update_topic_voice_count', 30 );
350 +add_action( 'bbp_approved_reply', 'bbp_update_topic_voice_count', 30 );
351 +add_action( 'bbp_unapproved_reply', 'bbp_update_topic_voice_count', 30 );
352 +add_action( 'bbp_deleted_reply', 'bbp_update_topic_voice_count', 30 );
353 +add_action( 'bbp_trashed_topic', 'bbp_update_topic_voice_count', 30 );
354 +add_action( 'bbp_untrashed_topic', 'bbp_update_topic_voice_count', 30 );
355 +add_action( 'bbp_spammed_topic', 'bbp_update_topic_voice_count', 30 );
356 +add_action( 'bbp_unspammed_topic', 'bbp_update_topic_voice_count', 30 );
357 +add_action( 'bbp_approved_topic', 'bbp_update_topic_voice_count', 30 );
358 +add_action( 'bbp_unapproved_topic', 'bbp_update_topic_voice_count', 30 );
359 +
243 360 // User status
244 361 // @todo make these sub-actions
245 362 add_action( 'make_ham_user', 'bbp_make_ham_user' );
246 363 add_action( 'make_spam_user', 'bbp_make_spam_user' );
@@ -250,46 +367,63 @@
250 367
251 368 // Hook WordPress admin actions to bbPress profiles on save
252 369 add_action( 'bbp_user_edit_after', 'bbp_user_edit_after' );
253 370
254 -// Caches
255 -add_action( 'bbp_new_forum_pre_extras', 'bbp_clean_post_cache' );
256 -add_action( 'bbp_new_forum_post_extras', 'bbp_clean_post_cache' );
257 -add_action( 'bbp_new_topic_pre_extras', 'bbp_clean_post_cache' );
258 -add_action( 'bbp_new_topic_post_extras', 'bbp_clean_post_cache' );
259 -add_action( 'bbp_new_reply_pre_extras', 'bbp_clean_post_cache' );
260 -add_action( 'bbp_new_reply_post_extras', 'bbp_clean_post_cache' );
371 +// Clean bbPress post caches when WordPress's is cleaned
372 +add_action( 'clean_post_cache', 'bbp_clean_post_cache', 10, 2 );
261 373
374 +// User Registration
375 +add_action( 'added_existing_user', 'bbp_user_add_role_on_register', 10, 1 );
376 +add_action( 'bbp_user_register', 'bbp_user_add_role_on_register', 10, 1 );
377 +
378 +// Invite a New User
379 +add_action( 'invite_user', 'bbp_user_add_role_on_invite', 10, 3 );
380 +
381 +// Multisite Activation (does not work in wp-activate.php)
382 +add_action( 'wpmu_activate_user', 'bbp_user_add_role_on_activate', 10, 3 );
383 +
262 384 /**
263 385 * bbPress needs to redirect the user around in a few different circumstances:
264 386 *
265 - * 1. Form submission within a theme (new and edit)
387 + * 1. POST and GET requests
266 388 * 2. Accessing private or hidden content (forums/topics/replies)
267 389 * 3. Editing forums, topics, replies, users, and tags
390 + * 4. bbPress specific AJAX requests
268 391 */
269 -add_action( 'bbp_template_redirect', 'bbp_forum_enforce_blocked', -1 );
270 -add_action( 'bbp_template_redirect', 'bbp_forum_enforce_hidden', -1 );
271 -add_action( 'bbp_template_redirect', 'bbp_forum_enforce_private', -1 );
272 -add_action( 'bbp_template_redirect', 'bbp_new_forum_handler', 10 );
273 -add_action( 'bbp_template_redirect', 'bbp_new_reply_handler', 10 );
274 -add_action( 'bbp_template_redirect', 'bbp_new_topic_handler', 10 );
275 -add_action( 'bbp_template_redirect', 'bbp_edit_topic_tag_handler', 1 );
276 -add_action( 'bbp_template_redirect', 'bbp_edit_user_handler', 1 );
277 -add_action( 'bbp_template_redirect', 'bbp_edit_forum_handler', 1 );
278 -add_action( 'bbp_template_redirect', 'bbp_edit_reply_handler', 1 );
279 -add_action( 'bbp_template_redirect', 'bbp_edit_topic_handler', 1 );
280 -add_action( 'bbp_template_redirect', 'bbp_merge_topic_handler', 1 );
281 -add_action( 'bbp_template_redirect', 'bbp_split_topic_handler', 1 );
282 -add_action( 'bbp_template_redirect', 'bbp_toggle_topic_handler', 1 );
283 -add_action( 'bbp_template_redirect', 'bbp_toggle_reply_handler', 1 );
284 -add_action( 'bbp_template_redirect', 'bbp_favorites_handler', 1 );
285 -add_action( 'bbp_template_redirect', 'bbp_subscriptions_handler', 1 );
286 -add_action( 'bbp_template_redirect', 'bbp_check_user_edit', 10 );
287 -add_action( 'bbp_template_redirect', 'bbp_check_forum_edit', 10 );
288 -add_action( 'bbp_template_redirect', 'bbp_check_topic_edit', 10 );
289 -add_action( 'bbp_template_redirect', 'bbp_check_reply_edit', 10 );
290 -add_action( 'bbp_template_redirect', 'bbp_check_topic_tag_edit', 10 );
392 +add_action( 'bbp_template_redirect', 'bbp_forum_enforce_blocked', 1 );
393 +add_action( 'bbp_template_redirect', 'bbp_forum_enforce_hidden', 1 );
394 +add_action( 'bbp_template_redirect', 'bbp_forum_enforce_private', 1 );
395 +add_action( 'bbp_template_redirect', 'bbp_post_request', 10 );
396 +add_action( 'bbp_template_redirect', 'bbp_get_request', 10 );
397 +add_action( 'bbp_template_redirect', 'bbp_check_user_edit', 10 );
398 +add_action( 'bbp_template_redirect', 'bbp_check_forum_edit', 10 );
399 +add_action( 'bbp_template_redirect', 'bbp_check_topic_edit', 10 );
400 +add_action( 'bbp_template_redirect', 'bbp_check_reply_edit', 10 );
401 +add_action( 'bbp_template_redirect', 'bbp_check_topic_tag_edit', 10 );
291 402
403 +// Must be after bbp_template_include_theme_compat
404 +add_action( 'bbp_template_redirect', 'bbp_remove_adjacent_posts', 10 );
405 +
406 +// Theme-side POST requests
407 +add_action( 'bbp_post_request', 'bbp_do_ajax', 1 );
408 +add_action( 'bbp_post_request', 'bbp_edit_topic_tag_handler', 1 );
409 +add_action( 'bbp_post_request', 'bbp_edit_user_handler', 1 );
410 +add_action( 'bbp_post_request', 'bbp_edit_forum_handler', 1 );
411 +add_action( 'bbp_post_request', 'bbp_edit_reply_handler', 1 );
412 +add_action( 'bbp_post_request', 'bbp_edit_topic_handler', 1 );
413 +add_action( 'bbp_post_request', 'bbp_merge_topic_handler', 1 );
414 +add_action( 'bbp_post_request', 'bbp_split_topic_handler', 1 );
415 +add_action( 'bbp_post_request', 'bbp_move_reply_handler', 1 );
416 +add_action( 'bbp_post_request', 'bbp_new_forum_handler', 10 );
417 +add_action( 'bbp_post_request', 'bbp_new_reply_handler', 10 );
418 +add_action( 'bbp_post_request', 'bbp_new_topic_handler', 10 );
419 +
420 +// Theme-side GET requests
421 +add_action( 'bbp_get_request', 'bbp_toggle_topic_handler', 1 );
422 +add_action( 'bbp_get_request', 'bbp_toggle_reply_handler', 1 );
423 +add_action( 'bbp_get_request', 'bbp_favorites_handler', 1 );
424 +add_action( 'bbp_get_request', 'bbp_subscriptions_handler', 1 );
425 +add_action( 'bbp_get_request', 'bbp_user_email_change_handler', 1 );
426 +add_action( 'bbp_get_request', 'bbp_search_results_redirect', 10 );
427 +
292 428 // Maybe convert the users password
293 429 add_action( 'bbp_login_form_login', 'bbp_user_maybe_convert_pass' );
294 -
295 -add_action( 'bbp_activation', 'bbp_add_activation_redirect' );