33 | | add_action( 'plugins_loaded', 'bp_loaded', 10 ); |
34 | | add_action( 'init', 'bp_init', 10 ); |
35 | | add_action( 'rest_api_init', 'bp_rest_api_init', 20 ); // After WP core. |
36 | | add_action( 'customize_register', 'bp_customize_register', 20 ); // After WP core. |
| 33 | add_action( 'plugins_loaded', function() { |
| 34 | |
| 35 | /** |
| 36 | * Fires on the 'plugins_loaded' hook, which fires after BP's core plugin files have been loaded. |
| 37 | * |
| 38 | * @since 1.2.5 |
| 39 | */ |
| 40 | do_action( 'bp_loaded' ); |
| 41 | }, 10 ); |
| 42 | add_action( 'init', function() { |
| 43 | |
| 44 | /** |
| 45 | * Fires on the 'init' hook, BuddyPress' main initialization hook. |
| 46 | * |
| 47 | * @since 1.2.0 |
| 48 | */ |
| 49 | do_action( 'bp_init' ); |
| 50 | }, 10 ); |
| 51 | add_action( 'rest_api_init', function() { |
| 52 | |
| 53 | /** |
| 54 | * Fires on the 'rest_api_init' hook, where BuddyPress registers REST API endpoints. |
| 55 | * |
| 56 | * @since 2.6.0 |
| 57 | */ |
| 58 | do_action( 'bp_rest_api_init' ); |
| 59 | }, 20 ); // After WP core. |
| 60 | add_action( 'customize_register', function( WP_Customize_Manager $customizer ) { |
| 61 | |
| 62 | /** |
| 63 | * Fires once the Customizer has loaded, allow scripts and styles to be initialized. |
| 64 | * |
| 65 | * @since 2.5.0 |
| 66 | * |
| 67 | * @param WP_Customize_Manager $customizer Customizer instance. |
| 68 | */ |
| 69 | do_action( 'bp_customize_register', $customizer ); |
| 70 | }, 20 ); // After WP core. |
38 | | add_action( 'wp', 'bp_ready', 10 ); |
39 | | add_action( 'set_current_user', 'bp_setup_current_user', 10 ); |
40 | | add_action( 'setup_theme', 'bp_setup_theme', 10 ); |
41 | | add_action( 'after_setup_theme', 'bp_after_setup_theme', 100 ); // After WP themes. |
42 | | add_action( 'wp_enqueue_scripts', 'bp_enqueue_scripts', 10 ); |
43 | | add_action( 'enqueue_embed_scripts', 'bp_enqueue_embed_scripts', 10 ); |
44 | | add_action( 'admin_bar_menu', 'bp_setup_admin_bar', 20 ); // After WP core. |
45 | | add_action( 'template_redirect', 'bp_template_redirect', 10 ); |
46 | | add_action( 'widgets_init', 'bp_widgets_init', 10 ); |
47 | | add_action( 'generate_rewrite_rules', 'bp_generate_rewrite_rules', 10 ); |
| 72 | add_action( 'wp', function() { |
| 73 | |
| 74 | /** |
| 75 | * Fires on the 'wp' hook, which runs after BP is set up and the page is about to render. |
| 76 | * |
| 77 | * @since 1.6.0 |
| 78 | */ |
| 79 | do_action( 'bp_ready' ); |
| 80 | }, 10 ); |
| 81 | add_action( 'set_current_user', function() { |
| 82 | |
| 83 | /** |
| 84 | * Fires on the set_current_user hook for the current user setup process. |
| 85 | * |
| 86 | * @since 1.7.0 |
| 87 | */ |
| 88 | do_action( 'bp_setup_current_user' ); |
| 89 | }, 10 ); |
| 90 | add_action( 'setup_theme', function() { |
| 91 | |
| 92 | /** |
| 93 | * Fires on the 'setup_theme' hook. |
| 94 | * |
| 95 | * @since 1.6.0 |
| 96 | */ |
| 97 | do_action( 'bp_setup_theme' ); |
| 98 | }, 10 ); |
| 99 | add_action( 'after_setup_theme', function() { |
| 100 | |
| 101 | /** |
| 102 | * Fires on the 'after_setup_theme' hook. |
| 103 | * |
| 104 | * @since 1.7.0 |
| 105 | */ |
| 106 | do_action( 'bp_after_setup_theme' ); |
| 107 | }, 100 ); // After WP themes. |
| 108 | add_action( 'wp_enqueue_scripts', function() { |
| 109 | |
| 110 | /** |
| 111 | * Fires on the 'wp_enqueue_scripts' hook, where BP enqueues its CSS and JS. |
| 112 | * |
| 113 | * @since 1.6.0 |
| 114 | */ |
| 115 | do_action( 'bp_enqueue_scripts' ); |
| 116 | }, 10 ); |
| 117 | add_action( 'enqueue_embed_scripts', function() { |
| 118 | |
| 119 | if ( ! is_buddypress() ) { |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Enqueue CSS and JS files for BuddyPress embeds. |
| 125 | * |
| 126 | * @since 2.6.0 |
| 127 | */ |
| 128 | do_action( 'bp_enqueue_embed_scripts' ); |
| 129 | }, 10 ); |
| 130 | add_action( 'admin_bar_menu', function() { |
| 131 | if ( bp_use_wp_admin_bar() ) { |
| 132 | |
| 133 | /** |
| 134 | * Fires on the 'admin_bar_menu' hook, where plugins should add items to the WP admin bar. |
| 135 | * |
| 136 | * This hook will only fire if bp_use_wp_admin_bar() returns true. |
| 137 | * |
| 138 | * @since 1.5.0 |
| 139 | */ |
| 140 | do_action( 'bp_setup_admin_bar' ); |
| 141 | } |
| 142 | }, 20 ); // After WP core. |
| 143 | add_action( 'template_redirect', function() { |
| 144 | |
| 145 | /** |
| 146 | * Fires on the 'template_redirect' hook. |
| 147 | * |
| 148 | * @since 1.6.0 |
| 149 | */ |
| 150 | do_action( 'bp_template_redirect' ); |
| 151 | }, 10 ); |
| 152 | add_action( 'widgets_init', function() { |
| 153 | |
| 154 | /** |
| 155 | * Fires on the 'widgets_init' hook, which runs after widgets have been set up. |
| 156 | * |
| 157 | * Hooked to 'widgets_init'. |
| 158 | * |
| 159 | * @since 1.6.0 |
| 160 | */ |
| 161 | do_action( 'bp_widgets_init' ); |
| 162 | }, 10 ); |
| 163 | add_action( 'generate_rewrite_rules', function( $wp_rewrite ) { |
| 164 | |
| 165 | /** |
| 166 | * Fires on the 'generate_rewrite_rules' hook. |
| 167 | * |
| 168 | * @since 1.7.0 |
| 169 | * |
| 170 | * @param WP_Rewrite $wp_rewrite WP_Rewrite object. Passed by reference. |
| 171 | */ |
| 172 | do_action_ref_array( 'bp_generate_rewrite_rules', array( &$wp_rewrite ) ); |
| 173 | }, 10 ); |
56 | | add_action( 'bp_loaded', 'bp_setup_components', 2 ); |
57 | | add_action( 'bp_loaded', 'bp_include', 4 ); |
58 | | add_action( 'bp_loaded', 'bp_setup_cache_groups', 5 ); |
59 | | add_action( 'bp_loaded', 'bp_setup_widgets', 6 ); |
60 | | add_action( 'bp_loaded', 'bp_register_theme_packages', 12 ); |
61 | | add_action( 'bp_loaded', 'bp_register_theme_directory', 14 ); |
| 182 | add_action( 'bp_loaded', function() { |
| 183 | |
| 184 | /** |
| 185 | * Fires on the 'bp_loaded' action, where plugins should initialize components. |
| 186 | * |
| 187 | * @since 1.6.0 |
| 188 | */ |
| 189 | do_action( 'bp_setup_components' ); |
| 190 | }, 2 ); |
| 191 | |
| 192 | add_action( 'bp_loaded', function() { |
| 193 | |
| 194 | /** |
| 195 | * Fires on the 'bp_loaded' action, where plugins should include files. |
| 196 | * |
| 197 | * @since 1.2.5 |
| 198 | */ |
| 199 | do_action( 'bp_include' ); |
| 200 | }, 4 ); |
| 201 | add_action( 'bp_loaded', function() { |
| 202 | |
| 203 | /** |
| 204 | * Fires on the 'bp_loaded' hook, where cache groups are registered. |
| 205 | * |
| 206 | * @since 2.2.0 |
| 207 | */ |
| 208 | do_action( 'bp_setup_cache_groups' ); |
| 209 | }, 5 ); |
| 210 | add_action( 'bp_loaded', function() { |
| 211 | |
| 212 | /** |
| 213 | * Fires on the 'bp_loaded' hook, where plugins should register widgets. |
| 214 | * |
| 215 | * @since 1.2.0 |
| 216 | */ |
| 217 | do_action( 'bp_register_widgets' ); |
| 218 | }, 6 ); |
| 219 | add_action( 'bp_loaded', function() { |
| 220 | |
| 221 | /** |
| 222 | * Fires on the 'bp_loaded' hook. |
| 223 | * |
| 224 | * @since 1.7.0 |
| 225 | */ |
| 226 | do_action( 'bp_register_theme_packages' ); |
| 227 | }, 12 ); |
| 228 | add_action( 'bp_loaded', function() { |
| 229 | |
| 230 | /** |
| 231 | * Fires on the 'bp_loaded' function. |
| 232 | * |
| 233 | * The main action used registering theme directories. |
| 234 | * |
| 235 | * @since 1.7.0 |
| 236 | */ |
| 237 | do_action( 'bp_register_theme_directory' ); |
| 238 | }, 14 ); |
73 | | add_action( 'bp_init', 'bp_setup_globals', 4 ); |
74 | | add_action( 'bp_init', 'bp_setup_canonical_stack', 5 ); |
75 | | add_action( 'bp_init', 'bp_setup_nav', 6 ); |
76 | | add_action( 'bp_init', 'bp_setup_title', 8 ); |
| 268 | add_action( 'bp_init', function() { |
| 269 | |
| 270 | /** |
| 271 | * Fires on the 'bp_init' hook, where plugins should initialize global settings. |
| 272 | * |
| 273 | * @since 1.2.0 |
| 274 | */ |
| 275 | do_action( 'bp_setup_globals' ); |
| 276 | }, 4 ); |
| 277 | add_action( 'bp_init', function() { |
| 278 | |
| 279 | /** |
| 280 | * Fires on the 'bp_init' hook, where plugins should set up their canonical URL. |
| 281 | * |
| 282 | * @since 2.1.0 |
| 283 | */ |
| 284 | do_action( 'bp_setup_canonical_stack' ); |
| 285 | }, 5 ); |
| 286 | add_action( 'bp_init', function() { |
| 287 | |
| 288 | /** |
| 289 | * Fires on the 'bp_init' hook, where plugins should register their navigation items. |
| 290 | * |
| 291 | * @since 1.2.0 |
| 292 | */ |
| 293 | do_action( 'bp_setup_nav' ); |
| 294 | }, 6 ); |
| 295 | add_action( 'bp_init', function() { |
| 296 | |
| 297 | /** |
| 298 | * Fires on the 'bp_init' hook, where plugins should modify the page title. |
| 299 | * |
| 300 | * @since 1.5.0 |
| 301 | */ |
| 302 | do_action( 'bp_setup_title' ); |
| 303 | }, 8 ); |
78 | | add_action( 'bp_init', 'bp_add_rewrite_tags', 20 ); |
79 | | add_action( 'bp_init', 'bp_add_rewrite_rules', 30 ); |
80 | | add_action( 'bp_init', 'bp_add_permastructs', 40 ); |
| 305 | add_action( 'bp_init', function() { |
| 306 | |
| 307 | /** |
| 308 | * Fires on the 'bp_init' hook, where BP adds its custom rewrite tags. |
| 309 | * |
| 310 | * @since 1.8.0 |
| 311 | */ |
| 312 | do_action( 'bp_add_rewrite_tags' ); |
| 313 | }, 20 ); |
| 314 | add_action( 'bp_init', function() { |
| 315 | |
| 316 | /** |
| 317 | * Fires on the 'bp_init' hook, where BP adds its custom rewrite rules. |
| 318 | * |
| 319 | * @since 1.9.0 |
| 320 | */ |
| 321 | do_action( 'bp_add_rewrite_rules' ); |
| 322 | }, 30 ); |
| 323 | add_action( 'bp_init', function() { |
| 324 | |
| 325 | /** |
| 326 | * Fires on the 'bp_init' hook, where BP adds its BP-specific permalink structure. |
| 327 | * |
| 328 | * @since 1.9.0 |
| 329 | */ |
| 330 | do_action( 'bp_add_permastructs' ); |
| 331 | }, 40 ); |
99 | | add_action( 'bp_template_redirect', 'bp_actions', 4 ); |
100 | | add_action( 'bp_template_redirect', 'bp_screens', 6 ); |
101 | | add_action( 'bp_template_redirect', 'bp_post_request', 10 ); |
102 | | add_action( 'bp_template_redirect', 'bp_get_request', 10 ); |
| 358 | add_action( 'bp_template_redirect', function() { |
| 359 | |
| 360 | /** |
| 361 | * Fires on the 'bp_actions' hook, which runs just before rendering. |
| 362 | * |
| 363 | * @since 1.5.0 |
| 364 | */ |
| 365 | do_action( 'bp_actions' ); |
| 366 | }, 4 ); |
| 367 | add_action( 'bp_template_redirect', function() { |
| 368 | |
| 369 | /** |
| 370 | * Fires on the 'bp_template_redirect' hook, which runs just before rendering. |
| 371 | * |
| 372 | * Runs just after 'bp_actions'. Use this hook to attach your template loaders. |
| 373 | * |
| 374 | * @since 1.5.0 |
| 375 | */ |
| 376 | do_action( 'bp_screens' ); |
| 377 | }, 6 ); |
| 378 | add_action( 'bp_template_redirect', function() { |
| 379 | |
| 380 | // Bail if not a POST action. |
| 381 | if ( ! bp_is_post_request() ) { |
| 382 | return; |
| 383 | } |
| 384 | |
| 385 | // Bail if no action. |
| 386 | if ( empty( $_POST['action'] ) ) { |
| 387 | return; |
| 388 | } |
| 389 | |
| 390 | // Sanitize the POST action. |
| 391 | $action = sanitize_key( $_POST['action'] ); |
| 392 | |
| 393 | /** |
| 394 | * Fires at the end of the bp_template_redirect callback for BuddyPress. |
| 395 | * |
| 396 | * This dynamic action is probably the one you want to use. It narrows down |
| 397 | * the scope of the 'action' without needing to check it in your function. |
| 398 | * |
| 399 | * @since 1.9.0 |
| 400 | */ |
| 401 | do_action( 'bp_post_request_' . $action ); |
| 402 | |
| 403 | /** |
| 404 | * Fires at the end of the bp_template_redirect callback for BuddyPress. |
| 405 | * |
| 406 | * Use this static action if you don't mind checking the 'action' yourself. |
| 407 | * |
| 408 | * @since 1.9.0 |
| 409 | * |
| 410 | * @param string $action The action being run. |
| 411 | */ |
| 412 | do_action( 'bp_post_request', $action ); |
| 413 | }, 10 ); |
| 414 | add_action( 'bp_template_redirect', function() { |
| 415 | |
| 416 | // Bail if not a POST action. |
| 417 | if ( ! bp_is_get_request() ) { |
| 418 | return; |
| 419 | } |
| 420 | |
| 421 | // Bail if no action. |
| 422 | if ( empty( $_GET['action'] ) ) { |
| 423 | return; |
| 424 | } |
| 425 | |
| 426 | // Sanitize the GET action. |
| 427 | $action = sanitize_key( $_GET['action'] ); |
| 428 | |
| 429 | /** |
| 430 | * Fires at the end of the bp_template_redirect callback for BuddyPress. |
| 431 | * |
| 432 | * This dynamic action is probably the one you want to use. It narrows down |
| 433 | * the scope of the 'action' without needing to check it in your function. |
| 434 | * |
| 435 | * @since 1.9.0 |
| 436 | */ |
| 437 | do_action( 'bp_get_request_' . $action ); |
| 438 | |
| 439 | /** |
| 440 | * Fires at the end of the bp_template_redirect callback for BuddyPress. |
| 441 | * |
| 442 | * Use this static action if you don't mind checking the 'action' yourself. |
| 443 | * |
| 444 | * @since 1.9.0 |
| 445 | * |
| 446 | * @param string $action The action being run. |
| 447 | */ |
| 448 | do_action( 'bp_get_request', $action ); |
| 449 | }, 10 ); |