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