PluginProbe
bbPress / 2.6.6
bbPress v2.6.6
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/functions.php +92 -145 trunk2.6.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Core Functions.
4 + * bbPress Core Functions
5 5 *
6 6 * @package bbPress
7 7 * @subpackage Functions
8 8 */
@@ -12,9 +12,9 @@
12 12
13 13 /** Versions ******************************************************************/
14 14
15 15 /**
16 - * Output the bbPress version.
16 + * Output the bbPress version
17 17 *
18 18 * @since 2.0.0 bbPress (r3468)
19 19 */
20 20 function bbp_version() {
@@ -19,91 +19,66 @@
19 19 */
20 20 function bbp_version() {
21 21 echo bbp_get_version();
22 22 }
23 + /**
24 + * Return the bbPress version
25 + *
26 + * @since 2.0.0 bbPress (r3468)
27 + *
28 + * @retrun string The bbPress version
29 + */
30 + function bbp_get_version() {
31 + return bbpress()->version;
32 + }
23 33
24 34 /**
25 - * Return the bbPress version.
35 + * Output the bbPress database version
26 36 *
27 37 * @since 2.0.0 bbPress (r3468)
28 - *
29 - * @return string The bbPress version.
30 38 */
31 -function bbp_get_version() {
32 - return bbpress()->version;
33 -}
34 -
35 -/**
36 - * Output the bbPress asset version.
37 - *
38 - * @since 2.6.7 bbPress (r7188)
39 - */
40 -function bbp_asset_version() {
41 - echo bbp_get_asset_version();
42 -}
43 -
44 -/**
45 - * Return the bbPress asset version.
46 - *
47 - * @since 2.6.7 bbPress (r7188)
48 - *
49 - * @return string The bbPress asset version.
50 - */
51 -function bbp_get_asset_version() {
52 - return bbp_doing_script_debug()
53 - ? (string) time()
54 - : bbp_get_version();
55 -}
56 -
57 -/**
58 - * Output the bbPress database version.
59 - *
60 - * @since 2.0.0 bbPress (r3468)
61 - */
62 39 function bbp_db_version() {
63 40 echo bbp_get_db_version();
64 41 }
42 + /**
43 + * Return the bbPress database version
44 + *
45 + * @since 2.0.0 bbPress (r3468)
46 + *
47 + * @retrun string The bbPress version
48 + */
49 + function bbp_get_db_version() {
50 + return bbpress()->db_version;
51 + }
65 52
66 53 /**
67 - * Return the bbPress database version.
54 + * Output the bbPress database version directly from the database
68 55 *
69 56 * @since 2.0.0 bbPress (r3468)
70 - *
71 - * @return string The bbPress version.
72 57 */
73 -function bbp_get_db_version() {
74 - return bbpress()->db_version;
75 -}
76 -
77 -/**
78 - * Output the bbPress database version directly from the database.
79 - *
80 - * @since 2.0.0 bbPress (r3468)
81 - */
82 58 function bbp_db_version_raw() {
83 59 echo bbp_get_db_version_raw();
84 60 }
61 + /**
62 + * Return the bbPress database version directly from the database
63 + *
64 + * @since 2.0.0 bbPress (r3468)
65 + *
66 + * @retrun string The current bbPress version
67 + */
68 + function bbp_get_db_version_raw() {
69 + return get_option( '_bbp_db_version', '' );
70 + }
85 71
86 -/**
87 - * Return the bbPress database version directly from the database.
88 - *
89 - * @since 2.0.0 bbPress (r3468)
90 - *
91 - * @return string The current bbPress version.
92 - */
93 -function bbp_get_db_version_raw() {
94 - return get_option( '_bbp_db_version', '' );
95 -}
96 -
97 72 /** Post Meta *****************************************************************/
98 73
99 74 /**
100 - * Update the forum meta ID of a post.
75 + * Update the forum meta ID of a post
101 76 *
102 77 * @since 2.0.0 bbPress (r3181)
103 78 *
104 - * @param int $post_id The post to update.
105 - * @param int $forum_id The forum id.
79 + * @param int $post_id The post to update
80 + * @param int $forum_id The forum
106 81 */
107 82 function bbp_update_forum_id( $post_id = 0, $forum_id = 0 ) {
108 83
109 84 // Allow the forum ID to be updated 'just in time' before save
@@ -115,14 +90,14 @@
115 90 return $forum_id;
116 91 }
117 92
118 93 /**
119 - * Update the topic meta ID of a post.
94 + * Update the topic meta ID of a post
120 95 *
121 96 * @since 2.0.0 bbPress (r3181)
122 97 *
123 - * @param int $post_id The post to update.
124 - * @param int $topic_id The topic id.
98 + * @param int $post_id The post to update
99 + * @param int $topic_id The topic
125 100 */
126 101 function bbp_update_topic_id( $post_id = 0, $topic_id = 0 ) {
127 102
128 103 // Allow the topic ID to be updated 'just in time' before save
@@ -134,14 +109,14 @@
134 109 return $topic_id;
135 110 }
136 111
137 112 /**
138 - * Update the reply meta ID of a post.
113 + * Update the reply meta ID of a post
139 114 *
140 115 * @since 2.0.0 bbPress (r3181)
141 116 *
142 - * @param int $post_id The post to update.
143 - * @param int $reply_id The reply id.
117 + * @param int $post_id The post to update
118 + * @param int $reply_id The reply
144 119 */
145 120 function bbp_update_reply_id( $post_id = 0, $reply_id = 0 ) {
146 121
147 122 // Allow the reply ID to be updated 'just in time' before save
@@ -153,14 +128,14 @@
153 128 return $reply_id;
154 129 }
155 130
156 131 /**
157 - * Update the reply-to meta ID of a post.
132 + * Update the reply-to meta ID of a post
158 133 *
159 134 * @since 2.6.0 bbPress (r5735)
160 135 *
161 - * @param int $post_id The post to update.
162 - * @param int $reply_id The reply id.
136 + * @param int $post_id The post to update
137 + * @param int $reply_id The reply ID
163 138 */
164 139 function bbp_update_reply_to_id( $post_id = 0, $reply_id = 0 ) {
165 140
166 141 // Allow the reply ID to be updated 'just in time' before save
@@ -174,15 +149,15 @@
174 149
175 150 /** Views *********************************************************************/
176 151
177 152 /**
178 - * Get the registered views.
153 + * Get the registered views
179 154 *
180 - * Does nothing much other than return the {@link $bbp->views} variable.
155 + * Does nothing much other than return the {@link $bbp->views} variable
181 156 *
182 157 * @since 2.0.0 bbPress (r2789)
183 158 *
184 - * @return array Views.
159 + * @return array Views
185 160 */
186 161 function bbp_get_views() {
187 162 return bbpress()->views;
188 163 }
@@ -187,19 +162,19 @@
187 162 return bbpress()->views;
188 163 }
189 164
190 165 /**
191 - * Register a bbPress view.
166 + * Register a bbPress view
192 167 *
193 168 * @since 2.0.0 bbPress (r2789)
194 169 *
195 - * @param string $view View name.
196 - * @param string $title View title.
170 + * @param string $view View name
171 + * @param string $title View title
197 172 * @param mixed $query_args {@link bbp_has_topics()} arguments.
198 173 * @param bool $feed Have a feed for the view? Defaults to true.
199 - * @param string $capability Capability that the current user must have.
174 + * @param string $capability Capability that the current user must have
200 175 *
201 - * @return array The just registered (but processed) view.
176 + * @return array The just registered (but processed) view
202 177 */
203 178 function bbp_register_view( $view, $title, $query_args = '', $feed = true, $capability = '' ) {
204 179
205 180 // Bail if user does not have capability
@@ -231,15 +206,14 @@
231 206 return $bbp->views[ $view ];
232 207 }
233 208
234 209 /**
235 - * Deregister a bbPress view.
210 + * Deregister a bbPress view
236 211 *
237 212 * @since 2.0.0 bbPress (r2789)
238 213 *
239 - * @param string $view View name.
240 - *
241 - * @return bool False if the view doesn't exist, true on success.
214 + * @param string $view View name
215 + * @return bool False if the view doesn't exist, true on success
242 216 */
243 217 function bbp_deregister_view( $view ) {
244 218 $bbp = bbpress();
245 219 $view = sanitize_title( $view );
@@ -253,16 +227,15 @@
253 227 return true;
254 228 }
255 229
256 230 /**
257 - * Run the query of a topic-view.
231 + * Run the query of a topic-view
258 232 *
259 233 * @since 2.0.0 bbPress (r2789)
260 234 *
261 - * @param string $view Optional. View id.
235 + * @param string $view Optional. View id
262 236 * @param mixed $new_args New arguments. See {@link bbp_has_topics()}
263 - *
264 - * @return bool False if the view doesn't exist, otherwise if topics are there.
237 + * @return bool False if the view doesn't exist, otherwise if topics are there
265 238 */
266 239 function bbp_view_query( $view = '', $new_args = '' ) {
267 240
268 241 // Get view, or bail
@@ -281,15 +254,14 @@
281 254 return bbp_has_topics( $query_args );
282 255 }
283 256
284 257 /**
285 - * Return the query arguments of a topic-view.
258 + * Return the query arguments of a topic-view
286 259 *
287 260 * @since 2.0.0 bbPress (r2789)
288 261 *
289 - * @param string $view View name.
290 - *
291 - * @return array Query arguments.
262 + * @param string $view View name
263 + * @return array Query arguments
292 264 */
293 265 function bbp_get_view_query_args( $view = '' ) {
294 266 $bbp = bbpress();
295 267 $view = bbp_get_view_id( $view );
@@ -303,17 +275,17 @@
303 275
304 276 /** Errors ********************************************************************/
305 277
306 278 /**
307 - * Adds an error message to later be output in the theme.
279 + * Adds an error message to later be output in the theme
308 280 *
309 281 * @since 2.0.0 bbPress (r3381)
310 282 *
311 283 * @see WP_Error()
312 284 *
313 - * @param string $code Unique code for the error message.
314 - * @param string $message Translated error message.
315 - * @param string $data Any additional data passed with the error message.
285 + * @param string $code Unique code for the error message
286 + * @param string $message Translated error message
287 + * @param string $data Any additional data passed with the error message
316 288 */
317 289 function bbp_add_error( $code = '', $message = '', $data = '' ) {
318 290 bbpress()->errors->add( $code, $message, $data );
319 291 }
@@ -318,9 +290,9 @@
318 290 bbpress()->errors->add( $code, $message, $data );
319 291 }
320 292
321 293 /**
322 - * Check if error messages exist in queue.
294 + * Check if error messages exist in queue
323 295 *
324 296 * @since 2.0.0 bbPress (r3381)
325 297 *
326 298 * @see WP_Error()
@@ -343,9 +315,9 @@
343 315 *
344 316 * @since 2.4.0 bbPress (r4997)
345 317 * @deprecated 2.6.0 bbp_make_clickable()
346 318 *
347 - * @return string Pattern to match usernames with.
319 + * @return string Pattern to match usernames with
348 320 */
349 321 function bbp_find_mentions_pattern() {
350 322
351 323 // Filter & return
@@ -357,10 +329,9 @@
357 329 *
358 330 * @since 2.2.0 bbPress (r4323)
359 331 * @deprecated 2.6.0 bbp_make_clickable()
360 332 *
361 - * @param string $content The content.
362 - *
333 + * @param string $content The content
363 334 * @return bool|array $usernames Existing usernames. False if no matches.
364 335 */
365 336 function bbp_find_mentions( $content = '' ) {
366 337 $pattern = bbp_find_mentions_pattern();
@@ -376,14 +347,14 @@
376 347 return apply_filters( 'bbp_find_mentions', $usernames, $pattern, $content );
377 348 }
378 349
379 350 /**
380 - * Finds and links @-mentioned users in the content.
351 + * Finds and links @-mentioned users in the content
381 352 *
382 353 * @since 2.2.0 bbPress (r4323)
383 354 * @deprecated 2.6.0 bbp_make_clickable()
384 355 *
385 - * @return string $content Content filtered for mentions.
356 + * @return string $content Content filtered for mentions
386 357 */
387 358 function bbp_mention_filter( $content = '' ) {
388 359
389 360 // Get Usernames and bail if none exist
@@ -417,9 +388,9 @@
417 388
418 389 /** Post Statuses *************************************************************/
419 390
420 391 /**
421 - * Return the public post status ID.
392 + * Return the public post status ID
422 393 *
423 394 * @since 2.0.0 bbPress (r3504)
424 395 *
425 396 * @return string
@@ -428,9 +399,9 @@
428 399 return bbpress()->public_status_id;
429 400 }
430 401
431 402 /**
432 - * Return the pending post status ID.
403 + * Return the pending post status ID
433 404 *
434 405 * @since 2.1.0 bbPress (r3581)
435 406 *
436 407 * @return string
@@ -439,9 +410,9 @@
439 410 return bbpress()->pending_status_id;
440 411 }
441 412
442 413 /**
443 - * Return the private post status ID.
414 + * Return the private post status ID
444 415 *
445 416 * @since 2.0.0 bbPress (r3504)
446 417 *
447 418 * @return string
@@ -450,9 +421,9 @@
450 421 return bbpress()->private_status_id;
451 422 }
452 423
453 424 /**
454 - * Return the hidden post status ID.
425 + * Return the hidden post status ID
455 426 *
456 427 * @since 2.0.0 bbPress (r3504)
457 428 *
458 429 * @return string
@@ -461,9 +432,9 @@
461 432 return bbpress()->hidden_status_id;
462 433 }
463 434
464 435 /**
465 - * Return the closed post status ID.
436 + * Return the closed post status ID
466 437 *
467 438 * @since 2.0.0 bbPress (r3504)
468 439 *
469 440 * @return string
@@ -472,9 +443,9 @@
472 443 return bbpress()->closed_status_id;
473 444 }
474 445
475 446 /**
476 - * Return the spam post status ID.
447 + * Return the spam post status ID
477 448 *
478 449 * @since 2.0.0 bbPress (r3504)
479 450 *
480 451 * @return string
@@ -483,9 +454,9 @@
483 454 return bbpress()->spam_status_id;
484 455 }
485 456
486 457 /**
487 - * Return the trash post status ID.
458 + * Return the trash post status ID
488 459 *
489 460 * @since 2.0.0 bbPress (r3504)
490 461 *
491 462 * @return string
@@ -494,9 +465,9 @@
494 465 return bbpress()->trash_status_id;
495 466 }
496 467
497 468 /**
498 - * Return the orphan post status ID.
469 + * Return the orphan post status ID
499 470 *
500 471 * @since 2.0.0 bbPress (r3504)
501 472 *
502 473 * @return string
@@ -507,9 +478,9 @@
507 478
508 479 /** Rewrite IDs ***************************************************************/
509 480
510 481 /**
511 - * Return the unique ID for user profile rewrite rules.
482 + * Return the unique ID for user profile rewrite rules
512 483 *
513 484 * @since 2.1.0 bbPress (r3762)
514 485 *
515 486 * @return string
@@ -529,9 +500,9 @@
529 500 return bbpress()->edit_id;
530 501 }
531 502
532 503 /**
533 - * Return the unique ID for all search rewrite rules.
504 + * Return the unique ID for all search rewrite rules
534 505 *
535 506 * @since 2.3.0 bbPress (r4579)
536 507 *
537 508 * @return string
@@ -540,9 +511,9 @@
540 511 return bbpress()->search_id;
541 512 }
542 513
543 514 /**
544 - * Return the unique ID for user topics rewrite rules.
515 + * Return the unique ID for user topics rewrite rules
545 516 *
546 517 * @since 2.2.0 bbPress (r4321)
547 518 *
548 519 * @return string
@@ -551,9 +522,9 @@
551 522 return bbpress()->tops_id;
552 523 }
553 524
554 525 /**
555 - * Return the unique ID for user replies rewrite rules.
526 + * Return the unique ID for user replies rewrite rules
556 527 *
557 528 * @since 2.2.0 bbPress (r4321)
558 529 *
559 530 * @return string
@@ -562,9 +533,9 @@
562 533 return bbpress()->reps_id;
563 534 }
564 535
565 536 /**
566 - * Return the unique ID for user favorites rewrite rules.
537 + * Return the unique ID for user favorites rewrite rules
567 538 *
568 539 * @since 2.2.0 bbPress (r4181)
569 540 *
570 541 * @return string
@@ -573,9 +544,9 @@
573 544 return bbpress()->favs_id;
574 545 }
575 546
576 547 /**
577 - * Return the unique ID for user subscriptions rewrite rules.
548 + * Return the unique ID for user subscriptions rewrite rules
578 549 *
579 550 * @since 2.2.0 bbPress (r4181)
580 551 *
581 552 * @return string
@@ -584,9 +555,9 @@
584 555 return bbpress()->subs_id;
585 556 }
586 557
587 558 /**
588 - * Return the unique ID for user engagement rewrite rules.
559 + * Return the unique ID for user engagement rewrite rules
589 560 *
590 561 * @since 2.6.0 bbPress (r6320)
591 562 *
592 563 * @return string
@@ -595,9 +566,9 @@
595 566 return bbpress()->engagements_id;
596 567 }
597 568
598 569 /**
599 - * Return the unique ID for topic view rewrite rules.
570 + * Return the unique ID for topic view rewrite rules
600 571 *
601 572 * @since 2.1.0 bbPress (r3762)
602 573 *
603 574 * @return string
@@ -608,9 +579,9 @@
608 579
609 580 /** Rewrite Extras ************************************************************/
610 581
611 582 /**
612 - * Get the id used for paginated requests.
583 + * Get the id used for paginated requests
613 584 *
614 585 * @since 2.4.0 bbPress (r4926)
615 586 *
616 587 * @return string
@@ -631,9 +602,9 @@
631 602
632 603 /** Requests ******************************************************************/
633 604
634 605 /**
635 - * Return true|false if this is a POST request.
606 + * Return true|false if this is a POST request
636 607 *
637 608 * @since 2.3.0 bbPress (r4790)
638 609 *
639 610 * @return bool
@@ -642,9 +613,9 @@
642 613 return (bool) ( 'POST' === strtoupper( $_SERVER['REQUEST_METHOD'] ) );
643 614 }
644 615
645 616 /**
646 - * Return true|false if this is a GET request.
617 + * Return true|false if this is a GET request
647 618 *
648 619 * @since 2.3.0 bbPress (r4790)
649 620 *
650 621 * @return bool
@@ -655,9 +626,9 @@
655 626
656 627 /** Redirection ***************************************************************/
657 628
658 629 /**
659 - * Perform a safe, local redirect somewhere inside the current site.
630 + * Perform a safe, local redirect somewhere inside the current site
660 631 *
661 632 * On some setups, passing the value of wp_get_referer() may result in an empty
662 633 * value for $location, which results in an error on redirection. If $location
663 634 * is empty, we can safely redirect back to the forum root. This might change
@@ -682,29 +653,5 @@
682 653 wp_safe_redirect( $location, $status );
683 654
684 655 // Exit so the redirect takes place immediately
685 656 exit();
686 -}
687 -
688 -/** Global Helpers ************************************************************/
689 -
690 -/**
691 - * Return if debugging scripts or not.
692 - *
693 - * @since 2.6.7 (r7188)
694 - *
695 - * @return bool True if debugging scripts. False if not debugging scripts.
696 - */
697 -function bbp_doing_script_debug() {
698 - return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
699 -}
700 -
701 -/**
702 - * Return if auto-saving or not.
703 - *
704 - * @since 2.6.7 (r7188)
705 - *
706 - * @return bool True if mid auto-save. False if not mid auto-save.
707 - */
708 -function bbp_doing_autosave() {
709 - return defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE;
710 657 }