PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.4.2
Forumax – AI Powered Advanced Community Forum Plugin v2.4.2
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / lib / bbpress / includes / core / sub-actions.php

sub-actions.php in Forumax – AI Powered Advanced Community Forum Plugin 2.4.2, at lib/bbpress/includes/core/sub-actions.php

554 lines 11.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Dependency
5 *
6 * The purpose of the following hooks is to mimic the behavior of something
7 * called 'plugin dependency' which enables a plugin to have plugins of their
8 * own in a safe and reliable way.
9 *
10 * We do this in bbPress by mirroring existing WordPress hooks in many places
11 * allowing dependant plugins to hook into the bbPress specific ones, thus
12 * guaranteeing proper code execution only when bbPress is active.
13 *
14 * The following functions are wrappers for hooks, allowing them to be
15 * manually called and/or piggy-backed on top of other hooks if needed.
16 *
17 * @package bbPress
18 * @subpackage Core
19 *
20 * @todo use anonymous functions when PHP minimum requirement allows (5.3)
21 */
22
23 /** Activation Actions ********************************************************/
24
25 /**
26 * Runs on bbPress activation
27 *
28 * @since 2.0.0 bbPress (r2509)
29 */
30 function bbp_activation() {
31 do_action( 'bbp_activation' );
32 }
33
34 /**
35 * Runs on bbPress deactivation
36 *
37 * @since 2.0.0 bbPress (r2509)
38 */
39 function bbp_deactivation() {
40 do_action( 'bbp_deactivation' );
41 }
42
43 /**
44 * Runs when uninstalling bbPress
45 *
46 * @since 2.0.0 bbPress (r2509)
47 */
48 function bbp_uninstall() {
49 do_action( 'bbp_uninstall' );
50 }
51
52 /** Main Actions **************************************************************/
53
54 /**
55 * Main action responsible for constants, globals, and includes
56 *
57 * @since 2.0.0 bbPress (r2599)
58 */
59 function bbp_loaded() {
60 do_action( 'bbp_loaded' );
61 }
62
63 /**
64 * Setup constants
65 *
66 * @since 2.0.0 bbPress (r2599)
67 */
68 function bbp_constants() {
69 do_action( 'bbp_constants' );
70 }
71
72 /**
73 * Setup globals BEFORE includes
74 *
75 * @since 2.0.0 bbPress (r2599)
76 */
77 function bbp_boot_strap_globals() {
78 do_action( 'bbp_boot_strap_globals' );
79 }
80
81 /**
82 * Include files
83 *
84 * @since 2.0.0 bbPress (r2599)
85 */
86 function bbp_includes() {
87 do_action( 'bbp_includes' );
88 }
89
90 /**
91 * Setup globals AFTER includes
92 *
93 * @since 2.0.0 bbPress (r2599)
94 */
95 function bbp_setup_globals() {
96 do_action( 'bbp_setup_globals' );
97 }
98
99 /**
100 * Register any objects before anything is initialized
101 *
102 * @since 2.2.0 bbPress (r4180)
103 */
104 function bbp_register() {
105 do_action( 'bbp_register' );
106 }
107
108 /**
109 * Initialize any code after everything has been loaded
110 *
111 * @since 2.0.0 bbPress (r2599)
112 */
113 function bbp_init() {
114 do_action( 'bbp_init' );
115 }
116
117 /**
118 * Initialize roles
119 *
120 * @since 2.6.0 bbPress (r6106)
121 *
122 * @param WP_Roles $wp_roles The array of WP_Role objects that was initialized
123 */
124 function bbp_roles_init( $wp_roles ) {
125 do_action( 'bbp_roles_init', $wp_roles );
126 }
127
128 /**
129 * Initialize widgets
130 *
131 * @since 2.0.0 bbPress (r3389)
132 */
133 function bbp_widgets_init() {
134 do_action( 'bbp_widgets_init' );
135 }
136
137 /**
138 * Setup the currently logged-in user
139 *
140 * @link https://bbpress.trac.wordpress.org/ticket/2309
141 * @link https://core.trac.wordpress.org/ticket/24169
142 *
143 * @since 2.0.0 bbPress (r2695)
144 */
145 function bbp_setup_current_user() {
146 do_action( 'bbp_setup_current_user' );
147 }
148
149 /**
150 * Setup the user engagements strategy
151 *
152 * @since 2.6.0 bbPress (r6875)
153 */
154 function bbp_setup_engagements() {
155 do_action( 'bbp_setup_engagements' );
156 }
157
158 /** Supplemental Actions ******************************************************/
159
160 /**
161 * Load translations for current language
162 *
163 * @since 2.0.0 bbPress (r2599)
164 */
165 function bbp_load_textdomain() {
166 do_action( 'bbp_load_textdomain' );
167 }
168
169 /**
170 * Setup the post types
171 *
172 * @since 2.0.0 bbPress (r2464)
173 */
174 function bbp_register_post_types() {
175 do_action( 'bbp_register_post_types' );
176 }
177
178 /**
179 * Setup the post statuses
180 *
181 * @since 2.0.0 bbPress (r2727)
182 */
183 function bbp_register_post_statuses() {
184 do_action( 'bbp_register_post_statuses' );
185 }
186
187 /**
188 * Register the built in bbPress taxonomies
189 *
190 * @since 2.0.0 bbPress (r2464)
191 */
192 function bbp_register_taxonomies() {
193 do_action( 'bbp_register_taxonomies' );
194 }
195
196 /**
197 * Register the default bbPress views
198 *
199 * @since 2.0.0 bbPress (r2789)
200 */
201 function bbp_register_views() {
202 do_action( 'bbp_register_views' );
203 }
204
205 /**
206 * Register the default bbPress shortcodes
207 *
208 * @since 2.2.0 bbPress (r4211)
209 */
210 function bbp_register_shortcodes() {
211 do_action( 'bbp_register_shortcodes' );
212 }
213
214 /**
215 * Register the default bbPress meta-data
216 *
217 * @since 2.6.0 bbPress (r46300)
218 */
219 function bbp_register_meta() {
220 do_action( 'bbp_register_meta' );
221 }
222
223 /**
224 * Enqueue bbPress specific CSS and JS
225 *
226 * @since 2.0.0 bbPress (r3373)
227 */
228 function bbp_enqueue_scripts() {
229 do_action( 'bbp_enqueue_scripts' );
230 }
231
232 /**
233 * Add the bbPress-specific rewrite tags
234 *
235 * @since 2.0.0 bbPress (r2753)
236 */
237 function bbp_add_rewrite_tags() {
238 do_action( 'bbp_add_rewrite_tags' );
239 }
240
241 /**
242 * Add the bbPress-specific rewrite rules
243 *
244 * @since 2.4.0 bbPress (r4918)
245 */
246 function bbp_add_rewrite_rules() {
247 do_action( 'bbp_add_rewrite_rules' );
248 }
249
250 /**
251 * Add the bbPress-specific permalink structures
252 *
253 * @since 2.4.0 bbPress (r4918)
254 */
255 function bbp_add_permastructs() {
256 do_action( 'bbp_add_permastructs' );
257 }
258
259 /**
260 * Add the bbPress-specific login forum action
261 *
262 * @since 2.0.0 bbPress (r2753)
263 */
264 function bbp_login_form_login() {
265 do_action( 'bbp_login_form_login' );
266 }
267
268 /**
269 * Add the bbPress-specific post status transition action
270 *
271 * @since 2.6.0 bbPress (r6792)
272 *
273 * @param string $new_status New post status
274 * @param string $old_status Old post status
275 * @param WP_Post $post Post object
276 */
277 function bbp_transition_post_status( $new_status = '', $old_status = '', $post = false ) {
278
279 // Get bbPress post types
280 $post_type = get_post_type( $post );
281 $types = bbp_get_post_types();
282
283 // Bail if post is not a bbPress post type
284 if ( ! in_array( $post_type, $types, true ) ) {
285 return;
286 }
287
288 // Do the action
289 do_action( 'bbp_transition_post_status', $new_status, $old_status, $post );
290 }
291
292 /** User Actions **************************************************************/
293
294 /**
295 * The main action for hooking into when a user account is updated
296 *
297 * @since 2.2.0 bbPress (r4304)
298 *
299 * @param int $user_id ID of user being edited
300 * @param array $old_user_data The old, unmodified user data
301 */
302 function bbp_profile_update( $user_id = 0, $old_user_data = array() ) {
303 do_action( 'bbp_profile_update', $user_id, $old_user_data );
304 }
305
306 /**
307 * The main action for hooking into a user being registered
308 *
309 * @since 2.2.0 bbPress (r4304)
310 *
311 * @param int $user_id ID of user being edited
312 */
313 function bbp_user_register( $user_id = 0 ) {
314 do_action( 'bbp_user_register', $user_id );
315 }
316
317 /** Final Action **************************************************************/
318
319 /**
320 * bbPress has loaded and initialized everything, and is okay to go
321 *
322 * @since 2.0.0 bbPress (r2618)
323 */
324 function bbp_ready() {
325 do_action( 'bbp_ready' );
326 }
327
328 /** Theme Permissions *********************************************************/
329
330 /**
331 * The main action used for redirecting bbPress theme actions that are not
332 * permitted by the current_user
333 *
334 * @since 2.1.0 bbPress (r3605)
335 */
336 function bbp_template_redirect() {
337 do_action( 'bbp_template_redirect' );
338 }
339
340 /** Theme Helpers *************************************************************/
341
342 /**
343 * The main action used for executing code before the theme has been setup
344 *
345 * @since 2.1.0 bbPress (r3829)
346 */
347 function bbp_register_theme_packages() {
348 do_action( 'bbp_register_theme_packages' );
349 }
350
351 /**
352 * The main action used for executing code before the theme has been setup
353 *
354 * @since 2.1.0 bbPress (r3732)
355 */
356 function bbp_setup_theme() {
357 do_action( 'bbp_setup_theme' );
358 }
359
360 /**
361 * The main action used for executing code after the theme has been setup
362 *
363 * @since 2.1.0 bbPress (r3732)
364 */
365 function bbp_after_setup_theme() {
366 do_action( 'bbp_after_setup_theme' );
367 }
368
369 /**
370 * The main action used for handling theme-side POST requests
371 *
372 * @since 2.3.0 bbPress (r4550)
373 */
374 function bbp_post_request() {
375
376 // Bail if not a POST action
377 if ( ! bbp_is_post_request() ) {
378 return;
379 }
380
381 // Bail if no action, or if not a string (arrays not supported)
382 if ( empty( $_POST['action'] ) || ! is_string( $_POST['action'] ) ) {
383 return;
384 }
385
386 // Sanitize the POST action
387 $action = sanitize_key( $_POST['action'] );
388
389 // Bail if action was totally invalid
390 if ( empty( $action ) ) {
391 return;
392 }
393
394 // This dynamic action is probably the one you want to use. It narrows down
395 // the scope of the 'action' without needing to check it in your function.
396 do_action( 'bbp_post_request_' . $action );
397
398 // Use this static action if you don't mind checking the 'action' yourself.
399 do_action( 'bbp_post_request', $action );
400 }
401
402 /**
403 * The main action used for handling theme-side GET requests
404 *
405 * @since 2.3.0 bbPress (r4550)
406 */
407 function bbp_get_request() {
408
409 // Bail if not a POST action
410 if ( ! bbp_is_get_request() ) {
411 return;
412 }
413
414 // Bail if no action, or if not a string (arrays not supported)
415 if ( empty( $_GET['action'] ) || ! is_string( $_GET['action'] ) ) {
416 return;
417 }
418
419 // Sanitize the GET action
420 $action = sanitize_key( $_GET['action'] );
421
422 // Bail if action was totally invalid
423 if ( empty( $action ) ) {
424 return;
425 }
426
427 // This dynamic action is probably the one you want to use. It narrows down
428 // the scope of the 'action' without needing to check it in your function.
429 do_action( 'bbp_get_request_' . $action );
430
431 // Use this static action if you don't mind checking the 'action' yourself.
432 do_action( 'bbp_get_request', $action );
433 }
434
435 /** Filters *******************************************************************/
436
437 /**
438 * Filter the plugin locale and domain.
439 *
440 * @since 2.2.0 bbPress (r4213)
441 *
442 * @param string $locale
443 * @param string $domain
444 */
445 function bbp_plugin_locale( $locale = '', $domain = '' ) {
446
447 // Filter & return
448 return apply_filters( 'bbp_plugin_locale', $locale, $domain );
449 }
450
451 /**
452 * Piggy back filter for WordPress's 'request' filter
453 *
454 * @since 2.1.0 bbPress (r3758)
455 *
456 * @param array $query_vars
457 * @return array
458 */
459 function bbp_request( $query_vars = array() ) {
460
461 // Filter & return
462 return apply_filters( 'bbp_request', $query_vars );
463 }
464
465 /**
466 * The main filter used for theme compatibility and displaying custom bbPress
467 * theme files.
468 *
469 * @since 2.0.0 bbPress (r3311)
470 *
471 * @param string $template
472 * @return string Template file to use
473 */
474 function bbp_template_include( $template = '' ) {
475
476 // Filter & return
477 return apply_filters( 'bbp_template_include', $template );
478 }
479
480 /**
481 * Generate bbPress-specific rewrite rules
482 *
483 * @since 2.0.0 bbPress (r2688)
484 *
485 * @deprecated 2.4.0 bbPress (r4918)
486 *
487 * @param WP_Rewrite $wp_rewrite
488 */
489 function bbp_generate_rewrite_rules( $wp_rewrite ) {
490 do_action_ref_array( 'bbp_generate_rewrite_rules', array( &$wp_rewrite ) );
491 }
492
493 /**
494 * Filter the allowed themes list for bbPress specific themes
495 *
496 * @since 2.0.0 bbPress (r2944)
497 *
498 * @param array $themes
499 *
500 * @return array Array of allowed themes
501 */
502 function bbp_allowed_themes( $themes ) {
503
504 // Filter & return
505 return (array) apply_filters( 'bbp_allowed_themes', $themes );
506 }
507
508 /**
509 * Maps forum/topic/reply caps to built in WordPress caps
510 *
511 * @since 2.0.0 bbPress (r2593)
512 *
513 * @param array $caps Capabilities for meta capability
514 * @param string $cap Capability name
515 * @param int $user_id User id
516 * @param array $args Arguments
517 *
518 * @return array Array of capabilities
519 */
520 function bbp_map_meta_caps( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
521
522 // Filter & return
523 return (array) apply_filters( 'bbp_map_meta_caps', $caps, $cap, $user_id, $args );
524 }
525
526 /**
527 * Filter the arguments used by wp_mail for bbPress specific emails
528 *
529 * @since 2.6.0 bbPress (r6918)
530 *
531 * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
532 * subject, message, headers, and attachments values.
533 *
534 * @return array Array of capabilities
535 */
536 function bbp_mail( $args = array() ) {
537
538 // Bail if headers are missing/malformed
539 if ( empty( $args['headers'] ) || ! is_array( $args['headers'] ) ) {
540 return $args;
541 }
542
543 // Header to search all headers for
544 $bbp_header = bbp_get_email_header();
545
546 // Bail if no bbPress header found
547 if ( false === array_search( $bbp_header, $args['headers'], true ) ) {
548 return $args;
549 }
550
551 // Filter & return
552 return (array) apply_filters( 'bbp_mail', $args );
553 }
554