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/common/template.php +553 -562 trunk2.6.17 View file →
@@ -1,11 +1,14 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Common Template Tags.
4 + * bbPress Common Template Tags
5 5 *
6 6 * Common template tags are ones that are used by more than one component, like
7 7 * forums, topics, replies, users, topic tags, etc...
8 + *
9 + * @package bbPress
10 + * @subpackage TemplateTags
8 11 */
9 12
10 13 // Exit if accessed directly
11 14 defined( 'ABSPATH' ) || exit;
@@ -12,57 +15,54 @@
12 15
13 16 /** URLs **********************************************************************/
14 17
15 18 /**
16 - * Output the forum URL.
19 + * Output the forum URL
17 20 *
18 21 * @since 2.1.0 bbPress (r3979)
19 22 *
20 - * @param string $path Additional path with leading slash.
23 + * @param string $path Additional path with leading slash
21 24 */
22 25 function bbp_forums_url( $path = '/' ) {
23 26 echo esc_url( bbp_get_forums_url( $path ) );
24 27 }
28 + /**
29 + * Return the forum URL
30 + *
31 + * @since 2.1.0 bbPress (r3979)
32 + *
33 + * @param string $path Additional path with leading slash
34 + */
35 + function bbp_get_forums_url( $path = '/' ) {
36 + return home_url( bbp_get_root_slug() . $path );
37 + }
25 38
26 39 /**
27 - * Return the forum URL.
40 + * Output the forum URL
28 41 *
29 42 * @since 2.1.0 bbPress (r3979)
30 43 *
31 - * @param string $path Additional path with leading slash.
44 + * @param string $path Additional path with leading slash
32 45 */
33 -function bbp_get_forums_url( $path = '/' ) {
34 - return home_url( bbp_get_root_slug() . $path );
35 -}
36 -
37 -/**
38 - * Output the forum URL.
39 - *
40 - * @since 2.1.0 bbPress (r3979)
41 - *
42 - * @param string $path Additional path with leading slash.
43 - */
44 46 function bbp_topics_url( $path = '/' ) {
45 47 echo esc_url( bbp_get_topics_url( $path ) );
46 48 }
49 + /**
50 + * Return the forum URL
51 + *
52 + * @since 2.1.0 bbPress (r3979)
53 + *
54 + * @param string $path Additional path with leading slash
55 + * @return The URL to the topics archive
56 + */
57 + function bbp_get_topics_url( $path = '/' ) {
58 + return home_url( bbp_get_topic_archive_slug() . $path );
59 + }
47 60
48 -/**
49 - * Return the forum URL.
50 - *
51 - * @since 2.1.0 bbPress (r3979)
52 - *
53 - * @param string $path Additional path with leading slash.
54 - *
55 - * @return The URL to the topics archive.
56 - */
57 -function bbp_get_topics_url( $path = '/' ) {
58 - return home_url( bbp_get_topic_archive_slug() . $path );
59 -}
60 -
61 61 /** Add-on Actions ************************************************************/
62 62
63 63 /**
64 - * Add our custom head action to wp_head.
64 + * Add our custom head action to wp_head
65 65 *
66 66 * @since 2.0.0 bbPress (r2464)
67 67 */
68 68 function bbp_head() {
@@ -69,9 +69,9 @@
69 69 do_action( 'bbp_head' );
70 70 }
71 71
72 72 /**
73 - * Add our custom footer action to wp_footer.
73 + * Add our custom footer action to wp_footer
74 74 *
75 75 * @since 2.0.0 bbPress (r2464)
76 76 */
77 77 function bbp_footer() {
@@ -80,15 +80,14 @@
80 80
81 81 /** is_ ***********************************************************************/
82 82
83 83 /**
84 - * Check if current site is public.
84 + * Check if current site is public
85 85 *
86 86 * @since 2.0.0 bbPress (r3398)
87 87 *
88 88 * @param int $site_id
89 - *
90 - * @return bool True if site is public, false if private.
89 + * @return bool True if site is public, false if private
91 90 */
92 91 function bbp_is_site_public( $site_id = 0 ) {
93 92
94 93 // Get the current site ID
@@ -105,15 +104,14 @@
105 104 return (bool) apply_filters( 'bbp_is_site_public', $public, $site_id );
106 105 }
107 106
108 107 /**
109 - * Check if current page is a bbPress forum.
108 + * Check if current page is a bbPress forum
110 109 *
111 110 * @since 2.0.0 bbPress (r2549)
112 111 *
113 - * @param int $post_id Possible post_id to check.
114 - *
115 - * @return bool True if it's a forum page, false if not.
112 + * @param int $post_id Possible post_id to check
113 + * @return bool True if it's a forum page, false if not
116 114 */
117 115 function bbp_is_forum( $post_id = 0 ) {
118 116
119 117 // Assume false
@@ -152,9 +150,9 @@
152 150 return (bool) apply_filters( 'bbp_is_forum_archive', $retval );
153 151 }
154 152
155 153 /**
156 - * Viewing a single forum.
154 + * Viewing a single forum
157 155 *
158 156 * @since 2.0.0 bbPress (r3338)
159 157 *
160 158 * @return bool
@@ -178,15 +176,15 @@
178 176 return (bool) apply_filters( 'bbp_is_single_forum', $retval );
179 177 }
180 178
181 179 /**
182 - * Check if current page is a forum edit page.
180 + * Check if current page is a forum edit page
183 181 *
184 182 * @since 2.1.0 bbPress (r3553)
185 183 *
186 184 * @global string $pagenow The filename of the current screen.
187 185 *
188 - * @return bool True if it's the forum edit page, false if not.
186 + * @return bool True if it's the forum edit page, false if not
189 187 */
190 188 function bbp_is_forum_edit() {
191 189 global $pagenow;
192 190
@@ -209,15 +207,14 @@
209 207 return (bool) apply_filters( 'bbp_is_forum_edit', $retval );
210 208 }
211 209
212 210 /**
213 - * Check if current page is a bbPress topic.
211 + * Check if current page is a bbPress topic
214 212 *
215 213 * @since 2.0.0 bbPress (r2549)
216 214 *
217 - * @param int $post_id Possible post_id to check.
218 - *
219 - * @return bool True if it's a topic page, false if not.
215 + * @param int $post_id Possible post_id to check
216 + * @return bool True if it's a topic page, false if not
220 217 */
221 218 function bbp_is_topic( $post_id = 0 ) {
222 219
223 220 // Assume false
@@ -232,9 +229,9 @@
232 229 return (bool) apply_filters( 'bbp_is_topic', $retval, $post_id );
233 230 }
234 231
235 232 /**
236 - * Viewing a single topic.
233 + * Viewing a single topic
237 234 *
238 235 * @since 2.0.0 bbPress (r3338)
239 236 *
240 237 * @return bool
@@ -279,15 +276,15 @@
279 276 return (bool) apply_filters( 'bbp_is_topic_archive', $retval );
280 277 }
281 278
282 279 /**
283 - * Check if current page is a topic edit page.
280 + * Check if current page is a topic edit page
284 281 *
285 282 * @since 2.0.0 bbPress (r2753)
286 283 *
287 284 * @global string $pagenow The filename of the current screen.
288 285 *
289 - * @return bool True if it's the topic edit page, false if not.
286 + * @return bool True if it's the topic edit page, false if not
290 287 */
291 288 function bbp_is_topic_edit() {
292 289 global $pagenow;
293 290
@@ -310,13 +307,13 @@
310 307 return (bool) apply_filters( 'bbp_is_topic_edit', $retval );
311 308 }
312 309
313 310 /**
314 - * Check if current page is a topic merge page.
311 + * Check if current page is a topic merge page
315 312 *
316 313 * @since 2.0.0 bbPress (r2756)
317 314 *
318 - * @return bool True if it's the topic merge page, false if not.
315 + * @return bool True if it's the topic merge page, false if not
319 316 */
320 317 function bbp_is_topic_merge() {
321 318
322 319 // Assume false
@@ -331,13 +328,13 @@
331 328 return (bool) apply_filters( 'bbp_is_topic_merge', $retval );
332 329 }
333 330
334 331 /**
335 - * Check if current page is a topic split page.
332 + * Check if current page is a topic split page
336 333 *
337 334 * @since 2.0.0 bbPress (r2756)
338 335 *
339 - * @return bool True if it's the topic split page, false if not.
336 + * @return bool True if it's the topic split page, false if not
340 337 */
341 338 function bbp_is_topic_split() {
342 339
343 340 // Assume false
@@ -352,13 +349,13 @@
352 349 return (bool) apply_filters( 'bbp_is_topic_split', $retval );
353 350 }
354 351
355 352 /**
356 - * Check if the current page is a topic tag.
353 + * Check if the current page is a topic tag
357 354 *
358 355 * @since 2.0.0 bbPress (r3311)
359 356 *
360 - * @return bool True if it's a topic tag, false if not.
357 + * @return bool True if it's a topic tag, false if not
361 358 */
362 359 function bbp_is_topic_tag() {
363 360
364 361 // Bail if topic-tags are off
@@ -383,9 +380,9 @@
383 380 return (bool) apply_filters( 'bbp_is_topic_tag', $retval );
384 381 }
385 382
386 383 /**
387 - * Check if the current page is editing a topic tag.
384 + * Check if the current page is editing a topic tag
388 385 *
389 386 * @since 2.0.0 bbPress (r3346)
390 387 *
391 388 * @global string $pagenow The filename of the current screen.
@@ -390,9 +387,9 @@
390 387 *
391 388 * @global string $pagenow The filename of the current screen.
392 389 * @global string $taxnow The taxonomy of the current screen.
393 390 *
394 - * @return bool True if editing a topic tag, false if not.
391 + * @return bool True if editing a topic tag, false if not
395 392 */
396 393 function bbp_is_topic_tag_edit() {
397 394 global $pagenow, $taxnow;
398 395
@@ -510,15 +507,14 @@
510 507 return (bool) apply_filters( 'bbp_is_password_protected', $retval, $object_id, $object_type );
511 508 }
512 509
513 510 /**
514 - * Check if current page is a bbPress reply.
511 + * Check if current page is a bbPress reply
515 512 *
516 513 * @since 2.0.0 bbPress (r2549)
517 514 *
518 - * @param int $post_id Possible post_id to check.
519 - *
520 - * @return bool True if it's a reply page, false if not.
515 + * @param int $post_id Possible post_id to check
516 + * @return bool True if it's a reply page, false if not
521 517 */
522 518 function bbp_is_reply( $post_id = 0 ) {
523 519
524 520 // Assume false
@@ -533,15 +529,15 @@
533 529 return (bool) apply_filters( 'bbp_is_reply', $retval, $post_id );
534 530 }
535 531
536 532 /**
537 - * Check if current page is a reply edit page.
533 + * Check if current page is a reply edit page
538 534 *
539 535 * @since 2.0.0 bbPress (r2753)
540 536 *
541 537 * @global string $pagenow The filename of the current screen.
542 538 *
543 - * @return bool True if it's the reply edit page, false if not.
539 + * @return bool True if it's the reply edit page, false if not
544 540 */
545 541 function bbp_is_reply_edit() {
546 542 global $pagenow;
547 543
@@ -564,11 +560,11 @@
564 560 return (bool) apply_filters( 'bbp_is_reply_edit', $retval );
565 561 }
566 562
567 563 /**
568 - * Check if current page is a reply move page.
564 + * Check if current page is a reply move page
569 565 *
570 - * @return bool True if it's the reply move page, false if not.
566 + * @return bool True if it's the reply move page, false if not
571 567 */
572 568 function bbp_is_reply_move() {
573 569
574 570 // Assume false
@@ -583,9 +579,9 @@
583 579 return (bool) apply_filters( 'bbp_is_reply_move', $retval );
584 580 }
585 581
586 582 /**
587 - * Viewing a single reply.
583 + * Viewing a single reply
588 584 *
589 585 * @since 2.0.0 bbPress (r3344)
590 586 *
591 587 * @return bool
@@ -600,9 +596,9 @@
600 596 return false;
601 597 }
602 598
603 599 // Single and a match
604 - if ( is_singular( bbp_get_reply_post_type() ) || bbp_is_query_name( 'bbp_single_reply' ) ) {
600 + if ( is_singular( bbp_get_reply_post_type() ) || ( bbp_is_query_name( 'bbp_single_reply' ) ) ) {
605 601 $retval = true;
606 602 }
607 603
608 604 // Filter & return
@@ -609,13 +605,13 @@
609 605 return (bool) apply_filters( 'bbp_is_single_reply', $retval );
610 606 }
611 607
612 608 /**
613 - * Check if current page is a bbPress user's favorites page (profile page).
609 + * Check if current page is a bbPress user's favorites page (profile page)
614 610 *
615 611 * @since 2.0.0 bbPress (r2652)
616 612 *
617 - * @return bool True if it's the favorites page, false if not.
613 + * @return bool True if it's the favorites page, false if not
618 614 */
619 615 function bbp_is_favorites() {
620 616
621 617 // Assume false
@@ -633,13 +629,13 @@
633 629 return (bool) apply_filters( 'bbp_is_favorites', $retval );
634 630 }
635 631
636 632 /**
637 - * Check if current page is a bbPress user's subscriptions page (profile page).
633 + * Check if current page is a bbPress user's subscriptions page (profile page)
638 634 *
639 635 * @since 2.0.0 bbPress (r2652)
640 636 *
641 - * @return bool True if it's the subscriptions page, false if not.
637 + * @return bool True if it's the subscriptions page, false if not
642 638 */
643 639 function bbp_is_subscriptions() {
644 640
645 641 // Assume false
@@ -658,13 +654,13 @@
658 654 }
659 655
660 656 /**
661 657 * Check if current page shows the topics created by a bbPress user (profile
662 - * page).
658 + * page)
663 659 *
664 660 * @since 2.0.0 bbPress (r2688)
665 661 *
666 - * @return bool True if it's the topics created page, false if not.
662 + * @return bool True if it's the topics created page, false if not
667 663 */
668 664 function bbp_is_topics_created() {
669 665
670 666 // Assume false
@@ -683,13 +679,13 @@
683 679 }
684 680
685 681 /**
686 682 * Check if current page shows the replies created by a bbPress user (profile
687 - * page).
683 + * page)
688 684 *
689 685 * @since 2.2.0 bbPress (r4225)
690 686 *
691 - * @return bool True if it's the replies created page, false if not.
687 + * @return bool True if it's the replies created page, false if not
692 688 */
693 689 function bbp_is_replies_created() {
694 690
695 691 // Assume false
@@ -707,13 +703,13 @@
707 703 return (bool) apply_filters( 'bbp_is_replies_created', $retval );
708 704 }
709 705
710 706 /**
711 - * Check if current page is the currently logged in users author page.
707 + * Check if current page is the currently logged in users author page
712 708 *
713 709 * @since 2.0.0 bbPress (r2688)
714 710 *
715 - * @return bool True if it's the user's home, false if not.
711 + * @return bool True if it's the user's home, false if not
716 712 */
717 713 function bbp_is_user_home() {
718 714
719 715 // Assume false
@@ -731,13 +727,13 @@
731 727 return (bool) apply_filters( 'bbp_is_user_home', $retval );
732 728 }
733 729
734 730 /**
735 - * Check if current page is the currently logged in users author edit page.
731 + * Check if current page is the currently logged in users author edit page
736 732 *
737 733 * @since 2.1.0 bbPress (r3918)
738 734 *
739 - * @return bool True if it's the user's home, false if not.
735 + * @return bool True if it's the user's home, false if not
740 736 */
741 737 function bbp_is_user_home_edit() {
742 738
743 739 // Assume false
@@ -751,13 +747,13 @@
751 747 return (bool) apply_filters( 'bbp_is_user_home_edit', $retval );
752 748 }
753 749
754 750 /**
755 - * Check if current page is a user profile page.
751 + * Check if current page is a user profile page
756 752 *
757 753 * @since 2.0.0 bbPress (r2688)
758 754 *
759 - * @return bool True if it's a user's profile page, false if not.
755 + * @return bool True if it's a user's profile page, false if not
760 756 */
761 757 function bbp_is_single_user() {
762 758
763 759 // Assume false
@@ -775,13 +771,13 @@
775 771 return (bool) apply_filters( 'bbp_is_single_user', $retval );
776 772 }
777 773
778 774 /**
779 - * Check if current page is a user profile edit page.
775 + * Check if current page is a user profile edit page
780 776 *
781 777 * @since 2.0.0 bbPress (r2688)
782 778 *
783 - * @return bool True if it's a user's profile edit page, false if not.
779 + * @return bool True if it's a user's profile edit page, false if not
784 780 */
785 781 function bbp_is_single_user_edit() {
786 782
787 783 // Assume false
@@ -799,13 +795,13 @@
799 795 return (bool) apply_filters( 'bbp_is_single_user_edit', $retval );
800 796 }
801 797
802 798 /**
803 - * Check if current page is a user profile page.
799 + * Check if current page is a user profile page
804 800 *
805 801 * @since 2.2.0 bbPress (r4225)
806 802 *
807 - * @return bool True if it's a user's profile page, false if not.
803 + * @return bool True if it's a user's profile page, false if not
808 804 */
809 805 function bbp_is_single_user_profile() {
810 806
811 807 // Assume false
@@ -823,13 +819,13 @@
823 819 return (bool) apply_filters( 'bbp_is_single_user_profile', $retval );
824 820 }
825 821
826 822 /**
827 - * Check if current page is a user topics created page.
823 + * Check if current page is a user topics created page
828 824 *
829 825 * @since 2.2.0 bbPress (r4225)
830 826 *
831 - * @return bool True if it's a user's topics page, false if not.
827 + * @return bool True if it's a user's topics page, false if not
832 828 */
833 829 function bbp_is_single_user_topics() {
834 830
835 831 // Assume false
@@ -847,13 +843,13 @@
847 843 return (bool) apply_filters( 'bbp_is_single_user_topics', $retval );
848 844 }
849 845
850 846 /**
851 - * Check if current page is a user replies created page.
847 + * Check if current page is a user replies created page
852 848 *
853 849 * @since 2.2.0 bbPress (r4225)
854 850 *
855 - * @return bool True if it's a user's replies page, false if not.
851 + * @return bool True if it's a user's replies page, false if not
856 852 */
857 853 function bbp_is_single_user_replies() {
858 854
859 855 // Assume false
@@ -871,13 +867,13 @@
871 867 return (bool) apply_filters( 'bbp_is_single_user_replies', $retval );
872 868 }
873 869
874 870 /**
875 - * Check if current page is a user engagements page.
871 + * Check if current page is a user engagements page
876 872 *
877 873 * @since 2.6.0 bbPress (r6320)
878 874 *
879 - * @return bool True if it's a user's replies page, false if not.
875 + * @return bool True if it's a user's replies page, false if not
880 876 */
881 877 function bbp_is_single_user_engagements() {
882 878
883 879 // Assume false
@@ -895,14 +891,13 @@
895 891 return (bool) apply_filters( 'bbp_is_single_user_engagements', $retval );
896 892 }
897 893
898 894 /**
899 - * Check if current page is a view page.
895 + * Check if current page is a view page
900 896 *
901 897 * @since 2.0.0 bbPress (r2789)
902 898 *
903 - * @global WP_Query $wp_query To check if WP_Query::bbp_is_view is true.
904 - *
899 + * @global WP_Query $wp_query To check if WP_Query::bbp_is_view is true
905 900 * @return bool Is it a view page?
906 901 */
907 902 function bbp_is_single_view() {
908 903
@@ -926,14 +921,13 @@
926 921 return (bool) apply_filters( 'bbp_is_single_view', $retval );
927 922 }
928 923
929 924 /**
930 - * Check if current page is a search page.
925 + * Check if current page is a search page
931 926 *
932 927 * @since 2.3.0 bbPress (r4579)
933 928 *
934 - * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true.
935 - *
929 + * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true
936 930 * @return bool Is it a search page?
937 931 */
938 932 function bbp_is_search() {
939 933
@@ -947,9 +941,9 @@
947 941
948 942 // Get the main query global
949 943 $wp_query = bbp_get_wp_query();
950 944
951 - // Get the rewrite ID (one time, to avoid repeated calls )
945 + // Get the rewrite ID (one time, to avoid repeated calls)
952 946 $rewrite_id = bbp_get_search_rewrite_id();
953 947
954 948 // Check query
955 949 if ( ! empty( $wp_query->bbp_is_search ) && ( true === $wp_query->bbp_is_search ) ) {
@@ -970,14 +964,13 @@
970 964 return (bool) apply_filters( 'bbp_is_search', $retval );
971 965 }
972 966
973 967 /**
974 - * Check if current page is a search results page.
968 + * Check if current page is a search results page
975 969 *
976 970 * @since 2.4.0 bbPress (r4919)
977 971 *
978 - * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true.
979 - *
972 + * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true
980 973 * @return bool Is it a search page?
981 974 */
982 975 function bbp_is_search_results() {
983 976
@@ -1011,13 +1004,13 @@
1011 1004 return (bool) apply_filters( 'bbp_is_search_results', $retval );
1012 1005 }
1013 1006
1014 1007 /**
1015 - * Check if current page is an edit page.
1008 + * Check if current page is an edit page
1016 1009 *
1017 1010 * @since 2.1.0 bbPress (r3585)
1018 1011 *
1019 - * @return bool True if it's the edit page, false if not.
1012 + * @return bool True if it's the edit page, false if not
1020 1013 */
1021 1014 function bbp_is_edit() {
1022 1015
1023 1016 // Assume false
@@ -1035,15 +1028,14 @@
1035 1028 return (bool) apply_filters( 'bbp_is_edit', $retval );
1036 1029 }
1037 1030
1038 1031 /**
1039 - * Use the above is_() functions to output a body class for each scenario.
1032 + * Use the above is_() functions to output a body class for each scenario
1040 1033 *
1041 1034 * @since 2.0.0 bbPress (r2926)
1042 1035 *
1043 1036 * @param array $wp_classes
1044 1037 * @param array $custom_classes
1045 - *
1046 1038 * @return array Body Classes
1047 1039 */
1048 1040 function bbp_body_class( $wp_classes = array(), $custom_classes = false ) {
1049 1041
@@ -1049,16 +1041,18 @@
1049 1041
1050 1042 // Default to no classes
1051 1043 $bbp_classes = array();
1052 1044
1053 - /* Archives ***************************************************************/
1045 + /** Archives **************************************************************/
1054 1046
1055 1047 if ( bbp_is_forum_archive() ) {
1056 1048 $bbp_classes[] = bbp_get_forum_post_type() . '-archive';
1049 +
1057 1050 } elseif ( bbp_is_topic_archive() ) {
1058 1051 $bbp_classes[] = bbp_get_topic_post_type() . '-archive';
1059 1052
1060 - /* Topic Tags *************************************************************/
1053 + /** Topic Tags ************************************************************/
1054 +
1061 1055 } elseif ( bbp_is_topic_tag() ) {
1062 1056 $bbp_classes[] = bbp_get_topic_tag_tax_id();
1063 1057 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_slug();
1064 1058 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id();
@@ -1064,92 +1058,112 @@
1064 1058 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id();
1065 1059 } elseif ( bbp_is_topic_tag_edit() ) {
1066 1060 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-edit';
1067 1061 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_slug() . '-edit';
1068 - $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id() . '-edit';
1062 + $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id() . '-edit';
1069 1063
1070 - /* Components *************************************************************/
1064 + /** Components ************************************************************/
1065 +
1071 1066 } elseif ( bbp_is_single_forum() ) {
1072 1067 $bbp_classes[] = bbp_get_forum_post_type();
1068 +
1073 1069 } elseif ( bbp_is_single_topic() ) {
1074 1070 $bbp_classes[] = bbp_get_topic_post_type();
1071 +
1075 1072 } elseif ( bbp_is_single_reply() ) {
1076 1073 $bbp_classes[] = bbp_get_reply_post_type();
1074 +
1077 1075 } elseif ( bbp_is_topic_edit() ) {
1078 1076 $bbp_classes[] = bbp_get_topic_post_type() . '-edit';
1077 +
1079 1078 } elseif ( bbp_is_topic_merge() ) {
1080 1079 $bbp_classes[] = bbp_get_topic_post_type() . '-merge';
1080 +
1081 1081 } elseif ( bbp_is_topic_split() ) {
1082 1082 $bbp_classes[] = bbp_get_topic_post_type() . '-split';
1083 +
1083 1084 } elseif ( bbp_is_reply_edit() ) {
1084 1085 $bbp_classes[] = bbp_get_reply_post_type() . '-edit';
1086 +
1085 1087 } elseif ( bbp_is_reply_move() ) {
1086 1088 $bbp_classes[] = bbp_get_reply_post_type() . '-move';
1089 +
1087 1090 } elseif ( bbp_is_single_view() ) {
1088 1091 $bbp_classes[] = 'bbp-view';
1089 1092 $bbp_classes[] = 'bbp-view-' . bbp_get_view_id();
1090 1093
1091 - /* User *******************************************************************/
1094 + /** User ******************************************************************/
1095 +
1092 1096 } elseif ( bbp_is_single_user_edit() ) {
1093 1097 $bbp_classes[] = 'bbp-user-edit';
1094 1098 $bbp_classes[] = 'single';
1095 1099 $bbp_classes[] = 'singular';
1100 +
1096 1101 } elseif ( bbp_is_single_user() ) {
1097 1102 $bbp_classes[] = 'bbp-user-page';
1098 1103 $bbp_classes[] = 'single';
1099 1104 $bbp_classes[] = 'singular';
1105 +
1100 1106 } elseif ( bbp_is_user_home() ) {
1101 1107 $bbp_classes[] = 'bbp-user-home';
1102 1108 $bbp_classes[] = 'single';
1103 1109 $bbp_classes[] = 'singular';
1110 +
1104 1111 } elseif ( bbp_is_user_home_edit() ) {
1105 1112 $bbp_classes[] = 'bbp-user-home-edit';
1106 1113 $bbp_classes[] = 'single';
1107 1114 $bbp_classes[] = 'singular';
1115 +
1108 1116 } elseif ( bbp_is_topics_created() ) {
1109 1117 $bbp_classes[] = 'bbp-topics-created';
1110 1118 $bbp_classes[] = 'single';
1111 1119 $bbp_classes[] = 'singular';
1120 +
1112 1121 } elseif ( bbp_is_replies_created() ) {
1113 1122 $bbp_classes[] = 'bbp-replies-created';
1114 1123 $bbp_classes[] = 'single';
1115 1124 $bbp_classes[] = 'singular';
1125 +
1116 1126 } elseif ( bbp_is_favorites() ) {
1117 1127 $bbp_classes[] = 'bbp-favorites';
1118 1128 $bbp_classes[] = 'single';
1119 1129 $bbp_classes[] = 'singular';
1130 +
1120 1131 } elseif ( bbp_is_subscriptions() ) {
1121 1132 $bbp_classes[] = 'bbp-subscriptions';
1122 1133 $bbp_classes[] = 'single';
1123 1134 $bbp_classes[] = 'singular';
1124 1135
1125 - /* Search *****************************************************************/
1136 + /** Search ****************************************************************/
1137 +
1126 1138 } elseif ( bbp_is_search() ) {
1127 1139 $bbp_classes[] = 'bbp-search';
1128 1140 $bbp_classes[] = 'forum-search';
1141 +
1129 1142 } elseif ( bbp_is_search_results() ) {
1130 1143 $bbp_classes[] = 'bbp-search-results';
1131 1144 $bbp_classes[] = 'forum-search-results';
1132 1145
1133 - /* Shortcodes *************************************************************/
1146 + /** Shortcodes ************************************************************/
1147 +
1134 1148 } elseif ( bbp_has_shortcode() ) {
1135 1149 $bbp_classes[] = 'bbp-shortcode';
1136 1150 }
1137 1151
1138 - /* General ****************************************************************/
1152 + /** General ***************************************************************/
1139 1153
1140 1154 // Any page with bbPress content
1141 1155 if ( ! empty( $bbp_classes ) ) {
1142 1156 $bbp_classes[] = 'bbpress';
1143 - $bbp_classes[] = 'no-js';
1157 + $bbp_classes[] = 'bbp-no-js';
1144 1158 }
1145 1159
1146 1160 /** Clean up **************************************************************/
1147 1161
1148 1162 // Merge WP classes with bbPress classes and remove any duplicates
1149 - $classes = array_unique(array_merge( (array) $bbp_classes, (array) $wp_classes ) );
1163 + $classes = array_unique( array_merge( (array) $bbp_classes, (array) $wp_classes ) );
1150 1164
1151 - // Deprecated filter (do not use )
1165 + // Deprecated filter (do not use)
1152 1166 $classes = apply_filters( 'bbp_get_the_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes );
1153 1167
1154 1168 // Filter & return
1155 1169 return (array) apply_filters( 'bbp_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes );
@@ -1171,11 +1185,11 @@
1171 1185
1172 1186 // Mark as done
1173 1187 $done = true;
1174 1188
1175 - ?>
1189 +?>
1176 1190
1177 -<script id="bbp-swap-no-js-body-class">
1191 +<script type="text/javascript" id="bbp-swap-no-js-body-class">
1178 1192 document.body.className = document.body.className.replace( 'bbp-no-js', 'bbp-js' );
1179 1193 </script>
1180 1194
1181 1195 <?php
@@ -1193,9 +1207,8 @@
1193 1207 *
1194 1208 * @since 2.6.0
1195 1209 *
1196 1210 * @param string $text
1197 - *
1198 1211 * @return bool
1199 1212 */
1200 1213 function bbp_has_shortcode( $text = '' ) {
1201 1214
@@ -1229,13 +1242,13 @@
1229 1242 return (bool) apply_filters( 'bbp_has_shortcode', $retval, $found, $text );
1230 1243 }
1231 1244
1232 1245 /**
1233 - * Use the above is_() functions to return if in any bbPress page.
1246 + * Use the above is_() functions to return if in any bbPress page
1234 1247 *
1235 1248 * @since 2.0.0 bbPress (r3344)
1236 1249 *
1237 - * @return bool In a bbPress page.
1250 + * @return bool In a bbPress page
1238 1251 */
1239 1252 function is_bbpress() {
1240 1253
1241 1254 // Default to false
@@ -1242,76 +1255,98 @@
1242 1255 $retval = false;
1243 1256
1244 1257 // Bail if main query has not been populated.
1245 1258 if ( ! bbp_get_wp_query() ) {
1246 - _doing_it_wrong(__FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '2.7.0' );
1247 -
1259 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '2.7.0' );
1248 1260 return $retval;
1249 1261 }
1250 1262
1251 - /* Archives ***************************************************************/
1263 + /** Archives **************************************************************/
1252 1264
1253 1265 if ( bbp_is_forum_archive() ) {
1254 1266 $retval = true;
1267 +
1255 1268 } elseif ( bbp_is_topic_archive() ) {
1256 1269 $retval = true;
1257 1270
1258 - /* Topic Tags *************************************************************/
1271 + /** Topic Tags ************************************************************/
1272 +
1259 1273 } elseif ( bbp_is_topic_tag() ) {
1260 1274 $retval = true;
1275 +
1261 1276 } elseif ( bbp_is_topic_tag_edit() ) {
1262 1277 $retval = true;
1263 1278
1264 - /* Components *************************************************************/
1279 + /** Components ************************************************************/
1280 +
1265 1281 } elseif ( bbp_is_single_forum() ) {
1266 1282 $retval = true;
1283 +
1267 1284 } elseif ( bbp_is_single_topic() ) {
1268 1285 $retval = true;
1286 +
1269 1287 } elseif ( bbp_is_single_reply() ) {
1270 1288 $retval = true;
1289 +
1271 1290 } elseif ( bbp_is_topic_edit() ) {
1272 1291 $retval = true;
1292 +
1273 1293 } elseif ( bbp_is_topic_merge() ) {
1274 1294 $retval = true;
1295 +
1275 1296 } elseif ( bbp_is_topic_split() ) {
1276 1297 $retval = true;
1298 +
1277 1299 } elseif ( bbp_is_reply_edit() ) {
1278 1300 $retval = true;
1301 +
1279 1302 } elseif ( bbp_is_reply_move() ) {
1280 1303 $retval = true;
1304 +
1281 1305 } elseif ( bbp_is_single_view() ) {
1282 1306 $retval = true;
1283 1307
1284 - /* User *******************************************************************/
1308 + /** User ******************************************************************/
1309 +
1285 1310 } elseif ( bbp_is_single_user_edit() ) {
1286 1311 $retval = true;
1312 +
1287 1313 } elseif ( bbp_is_single_user() ) {
1288 1314 $retval = true;
1315 +
1289 1316 } elseif ( bbp_is_user_home() ) {
1290 1317 $retval = true;
1318 +
1291 1319 } elseif ( bbp_is_user_home_edit() ) {
1292 1320 $retval = true;
1321 +
1293 1322 } elseif ( bbp_is_topics_created() ) {
1294 1323 $retval = true;
1324 +
1295 1325 } elseif ( bbp_is_replies_created() ) {
1296 1326 $retval = true;
1327 +
1297 1328 } elseif ( bbp_is_favorites() ) {
1298 1329 $retval = true;
1330 +
1299 1331 } elseif ( bbp_is_subscriptions() ) {
1300 1332 $retval = true;
1301 1333
1302 - /* Search *****************************************************************/
1334 + /** Search ****************************************************************/
1335 +
1303 1336 } elseif ( bbp_is_search() ) {
1304 1337 $retval = true;
1338 +
1305 1339 } elseif ( bbp_is_search_results() ) {
1306 1340 $retval = true;
1307 1341
1308 - /* Shortcodes *************************************************************/
1342 + /** Shortcodes ************************************************************/
1343 +
1309 1344 } elseif ( bbp_has_shortcode() ) {
1310 1345 $retval = true;
1311 1346 }
1312 1347
1313 - /* Done *******************************************************************/
1348 + /** Done ******************************************************************/
1314 1349
1315 1350 // Filter & return
1316 1351 return (bool) apply_filters( 'is_bbpress', $retval );
1317 1352 }
@@ -1318,29 +1353,29 @@
1318 1353
1319 1354 /** Forms *********************************************************************/
1320 1355
1321 1356 /**
1322 - * Output the login form action url.
1357 + * Output the login form action url
1323 1358 *
1324 1359 * @since 2.0.0 bbPress (r2815)
1325 1360 *
1326 1361 * @param array $args This function supports these arguments:
1327 - * - action: The action being taken
1328 - * - context: The context the action is being taken from
1362 + * - action: The action being taken
1363 + * - context: The context the action is being taken from
1329 1364 */
1330 1365 function bbp_wp_login_action( $args = array() ) {
1331 1366 echo esc_url( bbp_get_wp_login_action( $args ) );
1332 1367 }
1333 1368
1334 -/**
1335 - * Return the login form action url.
1336 - *
1337 - * @since 2.6.0 bbPress (r5684)
1338 - *
1339 - * @param array $args This function supports these arguments:
1340 - * - action: The action being taken
1341 - * - context: The context the action is being taken from
1342 - */
1369 + /**
1370 + * Return the login form action url
1371 + *
1372 + * @since 2.6.0 bbPress (r5684)
1373 + *
1374 + * @param array $args This function supports these arguments:
1375 + * - action: The action being taken
1376 + * - context: The context the action is being taken from
1377 + */
1343 1378 function bbp_get_wp_login_action( $args = array() ) {
1344 1379
1345 1380 // Parse arguments against default values
1346 1381 $r = bbp_parse_args(
@@ -1347,9 +1382,9 @@
1347 1382 $args,
1348 1383 array(
1349 1384 'action' => '',
1350 1385 'context' => '',
1351 - 'url' => 'wp-login.php',
1386 + 'url' => 'wp-login.php'
1352 1387 ),
1353 1388 'login_action'
1354 1389 );
1355 1390
@@ -1371,9 +1406,9 @@
1371 1406 * check the field manually, use bbp_get_redirect_to().
1372 1407 *
1373 1408 * @since 2.0.0 bbPress (r2815)
1374 1409 *
1375 - * @param string $redirect_to Pass a URL to redirect to.
1410 + * @param string $redirect_to Pass a URL to redirect to
1376 1411 */
1377 1412 function bbp_redirect_to_field( $redirect_to = '' ) {
1378 1413
1379 1414 // Make sure we are directing somewhere
@@ -1400,62 +1435,61 @@
1400 1435 * ensures correct sanitization of the value for the receiving input.
1401 1436 *
1402 1437 * @since 2.0.0 bbPress (r2815)
1403 1438 *
1404 - * @param string $request Name of $_REQUEST to look for
1439 + * @param string $request Name of $_REQUEST to look for
1405 1440 * @param string $input_type Type of input. Default: text. Accepts:
1406 - * textarea|password|select|radio|checkbox
1441 + * textarea|password|select|radio|checkbox
1407 1442 */
1408 1443 function bbp_sanitize_val( $request = '', $input_type = 'text' ) {
1409 1444 echo bbp_get_sanitize_val( $request, $input_type );
1410 1445 }
1446 + /**
1447 + * Return sanitized $_REQUEST value.
1448 + *
1449 + * Use the $input_type parameter to properly process the value. This
1450 + * ensures correct sanitization of the value for the receiving input.
1451 + *
1452 + * @since 2.0.0 bbPress (r2815)
1453 + *
1454 + * @param string $request Name of $_REQUEST to look for
1455 + * @param string $input_type Type of input. Default: text. Accepts:
1456 + * textarea|password|select|radio|checkbox
1457 + *
1458 + * @return string Sanitized value ready for screen display
1459 + */
1460 + function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) {
1411 1461
1412 -/**
1413 - * Return sanitized $_REQUEST value.
1414 - *
1415 - * Use the $input_type parameter to properly process the value. This
1416 - * ensures correct sanitization of the value for the receiving input.
1417 - *
1418 - * @since 2.0.0 bbPress (r2815)
1419 - *
1420 - * @param string $request Name of $_REQUEST to look for
1421 - * @param string $input_type Type of input. Default: text. Accepts:
1422 - * textarea|password|select|radio|checkbox
1423 - *
1424 - * @return string Sanitized value ready for screen display.
1425 - */
1426 -function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) {
1462 + // Check that requested
1463 + if ( empty( $_REQUEST[ $request ] ) ) {
1464 + return false;
1465 + }
1427 1466
1428 - // Check that requested
1429 - if ( empty( $_REQUEST[ $request ] ) ) {
1430 - return false;
1431 - }
1467 + // Set request varaible
1468 + $pre_ret_val = $_REQUEST[ $request ];
1432 1469
1433 - // Set request varaible
1434 - $pre_ret_val = $_REQUEST[ $request ];
1470 + // Treat different kinds of fields in different ways
1471 + switch ( $input_type ) {
1472 + case 'text' :
1473 + case 'textarea' :
1474 + $retval = esc_attr( wp_unslash( $pre_ret_val ) );
1475 + break;
1435 1476
1436 - // Treat different kinds of fields in different ways
1437 - switch ( $input_type ) {
1438 - case 'text':
1439 - case 'textarea':
1440 - $retval = esc_attr(wp_unslash( $pre_ret_val ) );
1441 - break;
1477 + case 'password' :
1478 + case 'select' :
1479 + case 'radio' :
1480 + case 'checkbox' :
1481 + default :
1482 + $retval = esc_attr( $pre_ret_val );
1483 + break;
1484 + }
1442 1485
1443 - case 'password':
1444 - case 'select':
1445 - case 'radio':
1446 - case 'checkbox':
1447 - default:
1448 - $retval = esc_attr( $pre_ret_val );
1449 - break;
1486 + // Filter & return
1487 + return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type );
1450 1488 }
1451 1489
1452 - // Filter & return
1453 - return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type );
1454 -}
1455 -
1456 1490 /**
1457 - * Output the current tab index of a given form.
1491 + * Output the current tab index of a given form
1458 1492 *
1459 1493 * Use this function to handle the tab indexing of user facing forms within a
1460 1494 * template file. Calling this function will automatically increment the global
1461 1495 * tab index by default.
@@ -1460,45 +1494,46 @@
1460 1494 * template file. Calling this function will automatically increment the global
1461 1495 * tab index by default.
1462 1496 *
1463 1497 * @since 2.0.0 bbPress (r2810)
1498 + *
1464 1499 * @deprecated 2.6.0 bbPress (r5561)
1465 - * @see https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
1466 1500 *
1501 + * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
1467 1502 * @param int $auto_increment Optional. Default true. Set to false to prevent
1468 - * increment.
1503 + * increment
1469 1504 */
1470 1505 function bbp_tab_index( $auto_increment = true ) {
1471 1506 echo bbp_get_tab_index( $auto_increment );
1472 1507 }
1473 1508
1474 -/**
1475 - * Return the current tab index of a given form.
1476 - *
1477 - * Use this function to handle the tab indexing of user facing forms
1478 - * within a template file. Calling this function will automatically
1479 - * increment the global tab index by default.
1480 - *
1481 - * @since 2.0.0 bbPress (r2810)
1482 - * @deprecated 2.6.0 bbPress (r5561)
1483 - * @see https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
1484 - *
1485 - * @param int $auto_increment Optional. Default true. Set to false to
1486 - * prevent the increment.
1487 - *
1488 - * @return int $bbp->tab_index The global tab index.
1489 - */
1490 -function bbp_get_tab_index( $auto_increment = true ) {
1491 - $bbp = bbpress();
1509 + /**
1510 + * Return the current tab index of a given form
1511 + *
1512 + * Use this function to handle the tab indexing of user facing forms
1513 + * within a template file. Calling this function will automatically
1514 + * increment the global tab index by default.
1515 + *
1516 + * @since 2.0.0 bbPress (r2810)
1517 + *
1518 + * @deprecated 2.6.0 bbPress (r5561)
1519 + *
1520 + * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
1521 + * @param int $auto_increment Optional. Default true. Set to false to
1522 + * prevent the increment
1523 + * @return int $bbp->tab_index The global tab index
1524 + */
1525 + function bbp_get_tab_index( $auto_increment = true ) {
1526 + $bbp = bbpress();
1492 1527
1493 - if ( true === $auto_increment ) {
1494 - ++$bbp->tab_index;
1528 + if ( true === $auto_increment ) {
1529 + ++$bbp->tab_index;
1530 + }
1531 +
1532 + // Filter & return
1533 + return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index );
1495 1534 }
1496 1535
1497 - // Filter & return
1498 - return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index );
1499 -}
1500 -
1501 1536 /**
1502 1537 * Output a "tabindex" attribute for an element, if an index was passed.
1503 1538 *
1504 1539 * This helper function is in use, but it is generally considered impolite to
@@ -1507,38 +1542,38 @@
1507 1542 * Most internal usages pass `false` which results in no attribute being used.
1508 1543 *
1509 1544 * @since 2.6.0 bbPress (r6424)
1510 1545 *
1511 - * @param mixed $tab False to skip, any integer to use.
1546 + * @param mixed $tab False to skip, any integer to use
1512 1547 */
1513 1548 function bbp_tab_index_attribute( $tab = false ) {
1514 1549 echo bbp_get_tab_index_attribute( $tab );
1515 1550 }
1516 1551
1517 -/**
1518 - * Return a "tabindex" attribute for an element, if an index was passed.
1519 - *
1520 - * This helper function is in use, but it is generally considered impolite to
1521 - * override the "tabindex" attribute beyond what the browser naturally assigns.
1522 - *
1523 - * Most internal usages pass `false` which results in no attribute being used.
1524 - *
1525 - * @since 2.6.0 bbPress (r6424)
1526 - *
1527 - * @param mixed $tab False to skip, any integer to use.
1528 - *
1529 - * @return string
1530 - */
1531 -function bbp_get_tab_index_attribute( $tab = false ) {
1552 + /**
1553 + * Return a "tabindex" attribute for an element, if an index was passed.
1554 + *
1555 + * This helper function is in use, but it is generally considered impolite to
1556 + * override the "tabindex" attribute beyond what the browser naturally assigns.
1557 + *
1558 + * Most internal usages pass `false` which results in no attribute being used.
1559 + *
1560 + * @since 2.6.0 bbPress (r6424)
1561 + *
1562 + * @param mixed $tab False to skip, any integer to use
1563 + *
1564 + * @return string
1565 + */
1566 + function bbp_get_tab_index_attribute( $tab = false ) {
1532 1567
1533 - // Get attribute
1534 - $attr = is_numeric( $tab )
1535 - ? ' tabindex="' . (int) $tab . '"'
1536 - : '';
1568 + // Get attribute
1569 + $attr = is_numeric( $tab )
1570 + ? ' tabindex="' . (int) $tab . '"'
1571 + : '';
1537 1572
1538 - // Filter & return
1539 - return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab );
1540 -}
1573 + // Filter & return
1574 + return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab );
1575 + }
1541 1576
1542 1577 /**
1543 1578 * Output a select box allowing to pick which forum/topic a new topic/reply
1544 1579 * belongs in.
@@ -1546,50 +1581,49 @@
1546 1581 * Can be used for any post type, but is mostly used for topics and forums.
1547 1582 *
1548 1583 * @since 2.0.0 bbPress (r2746)
1549 1584 *
1550 - * @param array $args See {@link bbp_get_dropdown()} for arguments.
1585 + * @param array $args See {@link bbp_get_dropdown()} for arguments
1551 1586 */
1552 1587 function bbp_dropdown( $args = array() ) {
1553 1588 echo bbp_get_dropdown( $args );
1554 1589 }
1555 -/**
1556 - * Return a select box allowing to pick which forum/topic a new
1557 - * topic/reply belongs in.
1558 - *
1559 - * @since 2.0.0 bbPress (r2746)
1560 - *
1561 - * @param array $args The function supports these args:
1562 - * - post_type: Post type, defaults to bbp_get_forum_post_type() ( bbp_forum)
1563 - * - selected: Selected ID, to not have any value as selected, pass
1564 - * anything smaller than 0 (due to the nature of select
1565 - * box, the first value would of course be selected -
1566 - * though you can have that as none (pass 'show_none' arg) )
1567 - * - orderby: Defaults to 'menu_order title'
1568 - * - post_parent: Post parent. Defaults to 0
1569 - * - post_status: Which all post_statuses to find in? Can be an array
1570 - * or CSV of publish, category, closed, private, spam,
1571 - * trash (based on post type ) - if not set, these are
1572 - * automatically determined based on the post_type
1573 - * - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get
1574 - * all posts
1575 - * - walker: Which walker to use? Defaults to
1576 - * {@link BBP_Walker_Dropdown}
1577 - * - select_id: ID of the select box. Defaults to 'bbp_forum_id'
1578 - * - tab: Deprecated. Tabindex value. False or integer
1579 - * - options_only: Show only <options>? No <select>?
1580 - * - show_none: Boolean or String __( '&mdash; No Forum &mdash;', 'bbpress' )
1581 - * - disable_categories: Disable forum categories and closed forums?
1582 - * Defaults to true. Only for forums and when
1583 - *
1584 - * @return string The dropdown
1585 - */
1590 + /**
1591 + * Return a select box allowing to pick which forum/topic a new
1592 + * topic/reply belongs in.
1593 + *
1594 + * @since 2.0.0 bbPress (r2746)
1595 + *
1596 + * @param array $args The function supports these args:
1597 + * - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum)
1598 + * - selected: Selected ID, to not have any value as selected, pass
1599 + * anything smaller than 0 (due to the nature of select
1600 + * box, the first value would of course be selected -
1601 + * though you can have that as none (pass 'show_none' arg))
1602 + * - orderby: Defaults to 'menu_order title'
1603 + * - post_parent: Post parent. Defaults to 0
1604 + * - post_status: Which all post_statuses to find in? Can be an array
1605 + * or CSV of publish, category, closed, private, spam,
1606 + * trash (based on post type) - if not set, these are
1607 + * automatically determined based on the post_type
1608 + * - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get
1609 + * all posts
1610 + * - walker: Which walker to use? Defaults to
1611 + * {@link BBP_Walker_Dropdown}
1612 + * - select_id: ID of the select box. Defaults to 'bbp_forum_id'
1613 + * - tab: Deprecated. Tabindex value. False or integer
1614 + * - options_only: Show only <options>? No <select>?
1615 + * - show_none: Boolean or String __( '&mdash; No Forum &mdash;', 'bbpress' )
1616 + * - disable_categories: Disable forum categories and closed forums?
1617 + * Defaults to true. Only for forums and when
1618 + * @return string The dropdown
1619 + */
1586 1620 function bbp_get_dropdown( $args = array() ) {
1587 1621
1588 1622 // Setup return value
1589 1623 $retval = '';
1590 1624
1591 - /** Arguments *************************************************************/
1625 + /** Arguments *********************************************************/
1592 1626
1593 1627 // Parse arguments against default values
1594 1628 $r = bbp_parse_args(
1595 1629 $args,
@@ -1618,9 +1652,9 @@
1618 1652 'tab' => false,
1619 1653 'options_only' => false,
1620 1654 'show_none' => false,
1621 1655 'disable_categories' => true,
1622 - 'disabled' => '',
1656 + 'disabled' => ''
1623 1657 ),
1624 1658 'get_dropdown'
1625 1659 );
1626 1660
@@ -1644,15 +1678,15 @@
1644 1678 if ( ! empty( $r['exclude'] ) && ! is_array( $r['exclude'] ) ) {
1645 1679 $r['exclude'] = explode( ',', $r['exclude'] );
1646 1680 }
1647 1681
1648 - /* Setup Posts ************************************************************/
1682 + /** Setup Posts *******************************************************/
1649 1683
1650 - /*
1651 - * Allow passing of custom posts data
1652 - *
1653 - * @see bbp_get_reply_to_dropdown() as an example
1654 - */
1684 + /**
1685 + * Allow passing of custom posts data
1686 + *
1687 + * @see bbp_get_reply_to_dropdown() as an example
1688 + */
1655 1689 if ( empty( $r['posts'] ) ) {
1656 1690 $r['posts'] = get_posts(
1657 1691 array(
1658 1692 'post_type' => $r['post_type'],
@@ -1666,9 +1700,9 @@
1666 1700 )
1667 1701 );
1668 1702 }
1669 1703
1670 - /* Drop Down **************************************************************/
1704 + /** Drop Down *********************************************************/
1671 1705
1672 1706 // Build the opening tag for the select element
1673 1707 if ( empty( $r['options_only'] ) ) {
1674 1708
@@ -1738,111 +1772,121 @@
1738 1772 return apply_filters( 'bbp_get_dropdown', $retval, $r, $args );
1739 1773 }
1740 1774
1741 1775 /**
1742 - * Output the required hidden fields when creating/editing a forum.
1776 + * Output the required hidden fields when creating/editing a forum
1743 1777 *
1744 1778 * @since 2.1.0 bbPress (r3553)
1745 1779 */
1746 1780 function bbp_forum_form_fields() {
1747 - if ( bbp_is_forum_edit() ) { ?>
1748 1781
1782 + if ( bbp_is_forum_edit() ) : ?>
1783 +
1749 1784 <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-forum" />
1750 1785 <input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="<?php bbp_forum_id(); ?>" />
1751 1786
1752 - <?php if ( current_user_can( 'unfiltered_html' ) ) {
1787 + <?php if ( current_user_can( 'unfiltered_html' ) ) :
1753 1788 wp_nonce_field( 'bbp-unfiltered-html-forum_' . bbp_get_forum_id(), '_bbp_unfiltered_html_forum', false );
1754 - } ?>
1789 + endif; ?>
1755 1790
1756 1791 <?php wp_nonce_field( 'bbp-edit-forum_' . bbp_get_forum_id() );
1757 - } else {
1758 - if ( bbp_is_single_forum() ) { ?>
1759 1792
1793 + else :
1794 +
1795 + if ( bbp_is_single_forum() ) : ?>
1796 +
1760 1797 <input type="hidden" name="bbp_forum_parent_id" id="bbp_forum_parent_id" value="<?php bbp_forum_parent_id(); ?>" />
1761 1798
1762 - <?php } ?>
1799 + <?php endif; ?>
1763 1800
1764 1801 <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-forum" />
1765 1802
1766 - <?php if ( current_user_can( 'unfiltered_html' ) ) {
1803 + <?php if ( current_user_can( 'unfiltered_html' ) ) :
1767 1804 wp_nonce_field( 'bbp-unfiltered-html-forum_new', '_bbp_unfiltered_html_forum', false );
1768 - } ?>
1805 + endif; ?>
1769 1806
1770 1807 <?php wp_nonce_field( 'bbp-new-forum' );
1771 - }
1808 +
1809 + endif;
1772 1810 }
1773 1811
1774 1812 /**
1775 - * Output the required hidden fields when creating/editing a topic.
1813 + * Output the required hidden fields when creating/editing a topic
1776 1814 *
1777 1815 * @since 2.0.0 bbPress (r2753)
1778 1816 */
1779 1817 function bbp_topic_form_fields() {
1780 - if ( bbp_is_topic_edit() ) { ?>
1781 1818
1819 + if ( bbp_is_topic_edit() ) : ?>
1820 +
1782 1821 <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-topic" />
1783 1822 <input type="hidden" name="bbp_topic_id" id="bbp_topic_id" value="<?php bbp_topic_id(); ?>" />
1784 1823
1785 - <?php if ( current_user_can( 'unfiltered_html' ) ) {
1824 + <?php if ( current_user_can( 'unfiltered_html' ) ) :
1786 1825 wp_nonce_field( 'bbp-unfiltered-html-topic_' . bbp_get_topic_id(), '_bbp_unfiltered_html_topic', false );
1787 - } ?>
1826 + endif; ?>
1788 1827
1789 1828 <?php wp_nonce_field( 'bbp-edit-topic_' . bbp_get_topic_id() );
1790 - } else {
1791 - if ( bbp_is_single_forum() ) { ?>
1792 1829
1830 + else :
1831 +
1832 + if ( bbp_is_single_forum() ) : ?>
1833 +
1793 1834 <input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="<?php bbp_forum_id(); ?>" />
1794 1835
1795 - <?php } ?>
1836 + <?php endif; ?>
1796 1837
1797 1838 <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-topic" />
1798 1839
1799 - <?php if ( current_user_can( 'unfiltered_html' ) ) {
1840 + <?php if ( current_user_can( 'unfiltered_html' ) ) :
1800 1841 wp_nonce_field( 'bbp-unfiltered-html-topic_new', '_bbp_unfiltered_html_topic', false );
1801 - } ?>
1842 + endif; ?>
1802 1843
1803 1844 <?php wp_nonce_field( 'bbp-new-topic' );
1804 - }
1845 +
1846 + endif;
1805 1847 }
1806 1848
1807 1849 /**
1808 - * Output the required hidden fields when creating/editing a reply.
1850 + * Output the required hidden fields when creating/editing a reply
1809 1851 *
1810 1852 * @since 2.0.0 bbPress (r2753)
1811 1853 */
1812 1854 function bbp_reply_form_fields() {
1813 - if ( bbp_is_reply_edit() ) { ?>
1814 1855
1856 + if ( bbp_is_reply_edit() ) : ?>
1857 +
1815 1858 <input type="hidden" name="bbp_reply_id" id="bbp_reply_id" value="<?php bbp_reply_id(); ?>" />
1816 1859 <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-reply" />
1817 1860
1818 - <?php if ( current_user_can( 'unfiltered_html' ) ) {
1861 + <?php if ( current_user_can( 'unfiltered_html' ) ) :
1819 1862 wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_reply_id(), '_bbp_unfiltered_html_reply', false );
1820 - } ?>
1863 + endif; ?>
1821 1864
1822 1865 <?php wp_nonce_field( 'bbp-edit-reply_' . bbp_get_reply_id() );
1823 - } else { ?>
1824 1866
1867 + else : ?>
1868 +
1825 1869 <input type="hidden" name="bbp_topic_id" id="bbp_topic_id" value="<?php bbp_topic_id(); ?>" />
1826 1870 <input type="hidden" name="bbp_reply_to" id="bbp_reply_to" value="<?php bbp_form_reply_to(); ?>" />
1827 1871 <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-reply" />
1828 1872
1829 - <?php if ( current_user_can( 'unfiltered_html' ) ) {
1873 + <?php if ( current_user_can( 'unfiltered_html' ) ) :
1830 1874 wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_topic_id(), '_bbp_unfiltered_html_reply', false );
1831 - } ?>
1875 + endif; ?>
1832 1876
1833 1877 <?php wp_nonce_field( 'bbp-new-reply' );
1834 1878
1835 1879 // Show redirect field if not viewing a specific topic
1836 - if ( bbp_is_query_name( 'bbp_single_topic' ) ) {
1880 + if ( bbp_is_query_name( 'bbp_single_topic' ) ) :
1837 1881 $redirect_to = apply_filters( 'bbp_reply_form_redirect_to', get_permalink() );
1838 1882 bbp_redirect_to_field( $redirect_to );
1839 - }
1840 - }
1883 + endif;
1884 + endif;
1841 1885 }
1842 1886
1843 1887 /**
1844 - * Output the required hidden fields when editing a user.
1888 + * Output the required hidden fields when editing a user
1845 1889 *
1846 1890 * @since 2.0.0 bbPress (r2690)
1847 1891 */
1848 1892 function bbp_edit_user_form_fields() {
@@ -1854,11 +1898,11 @@
1854 1898 <?php wp_nonce_field( 'update-user_' . bbp_get_displayed_user_id() );
1855 1899 }
1856 1900
1857 1901 /**
1858 - * Merge topic form fields.
1902 + * Merge topic form fields
1859 1903 *
1860 - * Output the required hidden fields when merging a topic.
1904 + * Output the required hidden fields when merging a topic
1861 1905 *
1862 1906 * @since 2.0.0 bbPress (r2756)
1863 1907 */
1864 1908 function bbp_merge_topic_form_fields() {
@@ -1870,11 +1914,11 @@
1870 1914 <?php wp_nonce_field( 'bbp-merge-topic_' . bbp_get_topic_id() );
1871 1915 }
1872 1916
1873 1917 /**
1874 - * Split topic form fields.
1918 + * Split topic form fields
1875 1919 *
1876 - * Output the required hidden fields when splitting a topic.
1920 + * Output the required hidden fields when splitting a topic
1877 1921 *
1878 1922 * @since 2.0.0 bbPress (r2756)
1879 1923 */
1880 1924 function bbp_split_topic_form_fields() {
@@ -1886,13 +1930,11 @@
1886 1930 <?php wp_nonce_field( 'bbp-split-topic_' . bbp_get_topic_id() );
1887 1931 }
1888 1932
1889 1933 /**
1890 - * Move reply form fields.
1934 + * Move reply form fields
1891 1935 *
1892 - * Output the required hidden fields when moving a reply.
1893 - *
1894 - * @since 2.1.0 bbPress (r3586)
1936 + * Output the required hidden fields when moving a reply
1895 1937 */
1896 1938 function bbp_move_reply_form_fields() {
1897 1939 ?>
1898 1940
@@ -1902,9 +1944,9 @@
1902 1944 <?php wp_nonce_field( 'bbp-move-reply_' . bbp_get_reply_id() );
1903 1945 }
1904 1946
1905 1947 /**
1906 - * Output a textarea or TinyMCE if enabled.
1948 + * Output a textarea or TinyMCE if enabled
1907 1949 *
1908 1950 * @since 2.1.0 bbPress (r3586)
1909 1951 *
1910 1952 * @param array $args
@@ -1911,18 +1953,17 @@
1911 1953 */
1912 1954 function bbp_the_content( $args = array() ) {
1913 1955 echo bbp_get_the_content( $args );
1914 1956 }
1915 -
1916 -/**
1917 - * Return a textarea or TinyMCE if enabled.
1918 - *
1919 - * @since 2.1.0 bbPress (r3586)
1920 - *
1921 - * @param array $args
1922 - *
1923 - * @return string HTML from output buffer
1924 - */
1957 + /**
1958 + * Return a textarea or TinyMCE if enabled
1959 + *
1960 + * @since 2.1.0 bbPress (r3586)
1961 + *
1962 + * @param array $args
1963 + *
1964 + * @return string HTML from output buffer
1965 + */
1925 1966 function bbp_get_the_content( $args = array() ) {
1926 1967
1927 1968 // Parse arguments against default values
1928 1969 $r = bbp_parse_args(
@@ -1939,9 +1980,9 @@
1939 1980 'editor_class' => 'bbp-the-content',
1940 1981 'tinymce' => false,
1941 1982 'teeny' => true,
1942 1983 'quicktags' => true,
1943 - 'dfw' => false,
1984 + 'dfw' => false
1944 1985 ),
1945 1986 'get_the_content'
1946 1987 );
1947 1988
@@ -1963,9 +2004,9 @@
1963 2004 echo $r['before'];
1964 2005 }
1965 2006
1966 2007 // Use TinyMCE if available
1967 - if ( bbp_use_wp_editor() ) {
2008 + if ( bbp_use_wp_editor() ) :
1968 2009
1969 2010 // Enable additional TinyMCE plugins before outputting the editor
1970 2011 add_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
1971 2012 add_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
@@ -1995,41 +2036,39 @@
1995 2036 remove_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
1996 2037 remove_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' );
1997 2038 remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
1998 2039
1999 - /*
2000 - * Fallback to normal textarea.
2001 - *
2002 - * Note that we do not use esc_textarea() here to prevent double
2003 - * escaping the editable output, mucking up existing content.
2004 - */
2005 - } else { ?>
2040 + /**
2041 + * Fallback to normal textarea.
2042 + *
2043 + * Note that we do not use esc_textarea() here to prevent double
2044 + * escaping the editable output, mucking up existing content.
2045 + */
2046 + else : ?>
2006 2047
2007 - <textarea id="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" class="<?php echo esc_attr( $r['editor_class'] ); ?>" name="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" cols="60" rows="<?php echo esc_attr( $r['textarea_rows'] ); ?>" <?php bbp_tab_index_attribute( $r['tabindex'] ); ?>><?php echo $post_content; ?></textarea>
2048 + <textarea id="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" class="<?php echo esc_attr( $r['editor_class'] ); ?>" name="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" cols="60" rows="<?php echo esc_attr( $r['textarea_rows'] ); ?>" <?php bbp_tab_index_attribute( $r['tabindex'] ); ?>><?php echo $post_content; ?></textarea>
2008 2049
2009 - <?php }
2050 + <?php endif;
2010 2051
2011 - // Output something after the editor
2012 - if ( ! empty( $r['after'] ) ) {
2013 - echo $r['after'];
2014 - }
2052 + // Output something after the editor
2053 + if ( ! empty( $r['after'] ) ) {
2054 + echo $r['after'];
2055 + }
2015 2056
2016 - // Put the output into a usable variable
2017 - $output = ob_get_clean();
2057 + // Put the output into a usable variable
2058 + $output = ob_get_clean();
2018 2059
2019 - // Filter & return
2020 - return apply_filters( 'bbp_get_the_content', $output, $args, $post_content );
2021 -}
2060 + // Filter & return
2061 + return apply_filters( 'bbp_get_the_content', $output, $args, $post_content );
2062 + }
2022 2063
2023 2064 /**
2024 - * Edit TinyMCE plugins to match core behaviour.
2065 + * Edit TinyMCE plugins to match core behaviour
2025 2066 *
2026 2067 * @since 2.3.0 bbPress (r4574)
2027 2068 *
2028 2069 * @param array $plugins
2029 - *
2030 2070 * @see tiny_mce_plugins, teeny_mce_plugins
2031 - *
2032 2071 * @return array
2033 2072 */
2034 2073 function bbp_get_tiny_mce_plugins( $plugins = array() ) {
2035 2074
@@ -2048,16 +2087,14 @@
2048 2087 return apply_filters( 'bbp_get_tiny_mce_plugins', $plugins );
2049 2088 }
2050 2089
2051 2090 /**
2052 - * Edit TeenyMCE buttons to match allowedtags.
2091 + * Edit TeenyMCE buttons to match allowedtags
2053 2092 *
2054 2093 * @since 2.3.0 bbPress (r4605)
2055 2094 *
2056 2095 * @param array $buttons
2057 - *
2058 2096 * @see teeny_mce_buttons
2059 - *
2060 2097 * @return array
2061 2098 */
2062 2099 function bbp_get_teeny_mce_buttons( $buttons = array() ) {
2063 2100
@@ -2067,9 +2104,9 @@
2067 2104 array(
2068 2105 'underline',
2069 2106 'justifyleft',
2070 2107 'justifycenter',
2071 - 'justifyright',
2108 + 'justifyright'
2072 2109 )
2073 2110 );
2074 2111
2075 2112 // Images
@@ -2079,16 +2116,14 @@
2079 2116 return apply_filters( 'bbp_get_teeny_mce_buttons', $buttons );
2080 2117 }
2081 2118
2082 2119 /**
2083 - * Edit TinyMCE quicktags buttons to match allowedtags.
2120 + * Edit TinyMCE quicktags buttons to match allowedtags
2084 2121 *
2085 2122 * @since 2.3.0 bbPress (r4606)
2086 2123 *
2087 2124 * @param array $settings
2088 - *
2089 2125 * @see quicktags_settings
2090 - *
2091 2126 * @return array Quicktags settings
2092 2127 */
2093 2128 function bbp_get_quicktags_settings( $settings = array() ) {
2094 2129
@@ -2100,9 +2135,9 @@
2100 2135 $buttons_array,
2101 2136 array(
2102 2137 'ins',
2103 2138 'more',
2104 - 'spell',
2139 + 'spell'
2105 2140 )
2106 2141 );
2107 2142
2108 2143 // Put them back into a string in the $settings array
@@ -2114,102 +2149,100 @@
2114 2149
2115 2150 /** Views *********************************************************************/
2116 2151
2117 2152 /**
2118 - * Output the view id.
2153 + * Output the view id
2119 2154 *
2120 2155 * @since 2.0.0 bbPress (r2789)
2121 2156 *
2122 - * @param string $view Optional. View id.
2157 + * @param string $view Optional. View id
2123 2158 */
2124 2159 function bbp_view_id( $view = '' ) {
2125 2160 echo bbp_get_view_id( $view );
2126 2161 }
2127 2162
2128 -/**
2129 - * Get the view id.
2130 - *
2131 - * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var.
2132 - *
2133 - * @since 2.0.0 bbPress (r2789)
2134 - *
2135 - * @param string $view Optional. View id.
2136 - *
2137 - * @return bool|string ID on success, false on failure.
2138 - */
2139 -function bbp_get_view_id( $view = '' ) {
2140 - $bbp = bbpress();
2163 + /**
2164 + * Get the view id
2165 + *
2166 + * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var.
2167 + *
2168 + * @since 2.0.0 bbPress (r2789)
2169 + *
2170 + * @param string $view Optional. View id.
2171 + * @return bool|string ID on success, false on failure
2172 + */
2173 + function bbp_get_view_id( $view = '' ) {
2174 + $bbp = bbpress();
2141 2175
2142 - // User supplied string
2143 - if ( ! empty( $view ) && is_string( $view ) ) {
2144 - $view_id = $view;
2176 + // User supplied string
2177 + if ( ! empty( $view ) && is_string( $view ) ) {
2178 + $view_id = $view;
2145 2179
2146 - // Current view ID
2147 - } elseif ( ! empty( $bbp->current_view_id ) ) {
2148 - $view_id = $bbp->current_view_id;
2180 + // Current view ID
2181 + } elseif ( ! empty( $bbp->current_view_id ) ) {
2182 + $view_id = $bbp->current_view_id;
2149 2183
2150 - // Querying for view
2151 - } else {
2152 - $view_id = get_query_var( bbp_get_view_rewrite_id() );
2184 + // Querying for view
2185 + } else {
2186 + $view_id = get_query_var( bbp_get_view_rewrite_id() );
2187 + }
2188 +
2189 + // Filter & return
2190 + return apply_filters( 'bbp_get_view_id', $view_id, $view );
2153 2191 }
2154 2192
2155 - // Filter & return
2156 - return apply_filters( 'bbp_get_view_id', $view_id, $view );
2157 -}
2158 -
2159 2193 /**
2160 - * Output the view name aka title.
2194 + * Output the view name aka title
2161 2195 *
2162 2196 * @since 2.0.0 bbPress (r2789)
2163 2197 *
2164 - * @param string $view Optional. View id.
2198 + * @param string $view Optional. View id
2165 2199 */
2166 2200 function bbp_view_title( $view = '' ) {
2167 2201 echo bbp_get_view_title( $view );
2168 2202 }
2169 2203
2170 -/**
2171 - * Get the view name aka title.
2172 - *
2173 - * If a view id is supplied, that is used. Otherwise the bbp_view
2174 - * query var is checked for.
2175 - *
2176 - * @since 2.0.0 bbPress (r2789)
2177 - *
2178 - * @param string $view Optional. View id.
2179 - *
2180 - * @return bool|string Title on success, false on failure.
2181 - */
2182 -function bbp_get_view_title( $view = '' ) {
2183 - $bbp = bbpress();
2204 + /**
2205 + * Get the view name aka title
2206 + *
2207 + * If a view id is supplied, that is used. Otherwise the bbp_view
2208 + * query var is checked for.
2209 + *
2210 + * @since 2.0.0 bbPress (r2789)
2211 + *
2212 + * @param string $view Optional. View id
2213 + * @return bool|string Title on success, false on failure
2214 + */
2215 + function bbp_get_view_title( $view = '' ) {
2216 + $bbp = bbpress();
2184 2217
2185 - $view = bbp_get_view_id( $view );
2186 - if ( empty( $view ) ) {
2187 - return false;
2218 + $view = bbp_get_view_id( $view );
2219 + if ( empty( $view ) ) {
2220 + return false;
2221 + }
2222 +
2223 + return $bbp->views[ $view ]['title'];
2188 2224 }
2189 2225
2190 - return $bbp->views[ $view ]['title'];
2191 -}
2192 -
2193 2226 /**
2194 - * Output the view url.
2227 + * Output the view url
2195 2228 *
2196 2229 * @since 2.0.0 bbPress (r2789)
2197 2230 *
2198 - * @param string $view Optional. View id.
2231 + * @param string $view Optional. View id
2199 2232 */
2200 2233 function bbp_view_url( $view = false ) {
2201 2234 echo esc_url( bbp_get_view_url( $view ) );
2202 2235 }
2203 -/**
2204 - * Return the view url.
2205 - *
2206 - * @since 2.0.0 bbPress (r2789)
2207 - *
2208 - * @param string $view Optional. View id.
2209 - *
2210 - * @return string View url (or home url if the view was not found).
2211 - */
2236 + /**
2237 + * Return the view url
2238 + *
2239 + * @since 2.0.0 bbPress (r2789)
2240 + *
2241 + * @param string $view Optional. View id
2242 + * used view id
2243 + * @return string View url (or home url if the view was not found)
2244 + */
2212 2245 function bbp_get_view_url( $view = false ) {
2213 2246
2214 2247 $view = bbp_get_view_id( $view );
2215 2248 if ( empty( $view ) ) {
@@ -2226,9 +2259,9 @@
2226 2259 // Unpretty permalinks
2227 2260 } else {
2228 2261 $url = add_query_arg(
2229 2262 array(
2230 - bbp_get_view_rewrite_id() => $view,
2263 + bbp_get_view_rewrite_id() => $view
2231 2264 ),
2232 2265 home_url( '/' )
2233 2266 );
2234 2267 }
@@ -2239,13 +2272,13 @@
2239 2272
2240 2273 /** Query *********************************************************************/
2241 2274
2242 2275 /**
2243 - * Check the passed parameter against the current _bbp_query_name.
2276 + * Check the passed parameter against the current _bbp_query_name
2244 2277 *
2245 2278 * @since 2.0.0 bbPress (r2980)
2246 2279 *
2247 - * @return bool True if match, false if not.
2280 + * @return bool True if match, false if not
2248 2281 */
2249 2282 function bbp_is_query_name( $name = '' ) {
2250 2283 return (bool) ( bbp_get_query_name() === $name );
2251 2284 }
@@ -2250,13 +2283,13 @@
2250 2283 return (bool) ( bbp_get_query_name() === $name );
2251 2284 }
2252 2285
2253 2286 /**
2254 - * Get the '_bbp_query_name' setting.
2287 + * Get the '_bbp_query_name' setting
2255 2288 *
2256 2289 * @since 2.0.0 bbPress (r2695)
2257 2290 *
2258 - * @return string To return the query var value.
2291 + * @return string To return the query var value
2259 2292 */
2260 2293 function bbp_get_query_name() {
2261 2294 return get_query_var( '_bbp_query_name' );
2262 2295 }
@@ -2261,13 +2294,13 @@
2261 2294 return get_query_var( '_bbp_query_name' );
2262 2295 }
2263 2296
2264 2297 /**
2265 - * Set the '_bbp_query_name' setting to $name.
2298 + * Set the '_bbp_query_name' setting to $name
2266 2299 *
2267 2300 * @since 2.0.0 bbPress (r2692)
2268 2301 *
2269 - * @param string $name What to set the query var to.
2302 + * @param string $name What to set the query var to
2270 2303 */
2271 2304 function bbp_set_query_name( $name = '' ) {
2272 2305 set_query_var( '_bbp_query_name', $name );
2273 2306 }
@@ -2272,11 +2305,12 @@
2272 2305 set_query_var( '_bbp_query_name', $name );
2273 2306 }
2274 2307
2275 2308 /**
2276 - * Used to clear the '_bbp_query_name' setting.
2309 + * Used to clear the '_bbp_query_name' setting
2277 2310 *
2278 2311 * @since 2.0.0 bbPress (r2692)
2312 + *
2279 2313 */
2280 2314 function bbp_reset_query_name() {
2281 2315 bbp_set_query_name();
2282 2316 }
@@ -2283,11 +2317,15 @@
2283 2317
2284 2318 /** Breadcrumbs ***************************************************************/
2285 2319
2286 2320 /**
2287 - * Output the page title as a breadcrumb.
2321 + * Output the page title as a breadcrumb
2288 2322 *
2289 2323 * @since 2.0.0 bbPress (r2589)
2324 + *
2325 + * @param string $sep Separator. Defaults to '&larr;'
2326 + * @param bool $current_page Include the current item
2327 + * @param bool $root Include the root page if one exists
2290 2328 */
2291 2329 function bbp_title_breadcrumb( $args = array() ) {
2292 2330 echo bbp_get_breadcrumb( $args );
2293 2331 }
@@ -2292,27 +2330,30 @@
2292 2330 echo bbp_get_breadcrumb( $args );
2293 2331 }
2294 2332
2295 2333 /**
2296 - * Output a breadcrumb.
2334 + * Output a breadcrumb
2297 2335 *
2298 2336 * @since 2.0.0 bbPress (r2589)
2337 + *
2338 + * @param string $sep Separator. Defaults to '&larr;'
2339 + * @param bool $current_page Include the current item
2340 + * @param bool $root Include the root page if one exists
2299 2341 */
2300 2342 function bbp_breadcrumb( $args = array() ) {
2301 2343 echo bbp_get_breadcrumb( $args );
2302 2344 }
2303 -
2304 -/**
2305 - * Return a breadcrumb ( forum -> topic -> reply )
2306 - *
2307 - * @since 2.0.0 bbPress (r2589)
2308 - *
2309 - * @param string $sep Separator. Defaults to '&larr;'.
2310 - * @param bool $current_page Include the current item.
2311 - * @param bool $root Include the root page if one exists.
2312 - *
2313 - * @return string Breadcrumbs.
2314 - */
2345 + /**
2346 + * Return a breadcrumb ( forum -> topic -> reply )
2347 + *
2348 + * @since 2.0.0 bbPress (r2589)
2349 + *
2350 + * @param string $sep Separator. Defaults to '&larr;'
2351 + * @param bool $current_page Include the current item
2352 + * @param bool $root Include the root page if one exists
2353 + *
2354 + * @return string Breadcrumbs
2355 + */
2315 2356 function bbp_get_breadcrumb( $args = array() ) {
2316 2357
2317 2358 // Turn off breadcrumbs
2318 2359 if ( apply_filters( 'bbp_no_breadcrumb', is_front_page() ) ) {
@@ -2319,14 +2360,14 @@
2319 2360 return;
2320 2361 }
2321 2362
2322 2363 // Define variables
2323 - $front_id = $root_id = $remove_root_id = 0;
2364 + $front_id = $root_id = 0;
2324 2365 $ancestors = $crumbs = $tag_data = array();
2325 2366 $pre_root_text = $pre_front_text = $pre_current_text = '';
2326 2367 $pre_include_root = $pre_include_home = $pre_include_current = true;
2327 2368
2328 - /** Home Text *************************************************************/
2369 + /** Home Text *********************************************************/
2329 2370
2330 2371 // No custom home text
2331 2372 if ( empty( $args['home_text'] ) ) {
2332 2373
@@ -2341,9 +2382,9 @@
2341 2382 $pre_front_text = esc_html__( 'Home', 'bbpress' );
2342 2383 }
2343 2384 }
2344 2385
2345 - /** Root Text *************************************************************/
2386 + /** Root Text *********************************************************/
2346 2387
2347 2388 // No custom root text
2348 2389 if ( empty( $args['root_text'] ) ) {
2349 2390 $page = bbp_get_page_by_path( bbp_get_root_slug() );
@@ -2352,9 +2393,9 @@
2352 2393 }
2353 2394 $pre_root_text = bbp_get_forum_archive_title();
2354 2395 }
2355 2396
2356 - /** Includes **************************************************************/
2397 + /** Includes **********************************************************/
2357 2398
2358 2399 // Root slug is also the front page
2359 2400 if ( ! empty( $front_id ) && ( $front_id === $root_id ) ) {
2360 2401 $pre_include_root = false;
@@ -2369,9 +2410,9 @@
2369 2410 if ( ! empty( $root_id ) && ( ( is_single() || is_page() ) && ( get_the_ID() === $root_id ) ) ) {
2370 2411 $pre_include_root = false;
2371 2412 }
2372 2413
2373 - /** Current Text **********************************************************/
2414 + /** Current Text ******************************************************/
2374 2415
2375 2416 // Search page
2376 2417 if ( bbp_is_search() ) {
2377 2418 $pre_current_text = bbp_get_search_title();
@@ -2423,9 +2464,9 @@
2423 2464 } else {
2424 2465 $pre_current_text = get_the_title();
2425 2466 }
2426 2467
2427 - /** Parse Args ************************************************************/
2468 + /** Parse Args ********************************************************/
2428 2469
2429 2470 // Parse args
2430 2471 $r = bbp_parse_args(
2431 2472 $args,
@@ -2461,9 +2502,9 @@
2461 2502 ),
2462 2503 'get_breadcrumb'
2463 2504 );
2464 2505
2465 - /** Ancestors *********************************************************/
2506 + /** Ancestors *********************************************************/
2466 2507
2467 2508 // Get post ancestors
2468 2509 if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() ) {
2469 2510 $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) );
@@ -2480,9 +2521,8 @@
2480 2521 // Page exists at root slug path, so use its permalink
2481 2522 $page = bbp_get_page_by_path( bbp_get_root_slug() );
2482 2523 if ( ! empty( $page ) ) {
2483 2524 $root_url = get_permalink( $page->ID );
2484 - $remove_root_id = $page->ID;
2485 2525
2486 2526 // Use the root slug
2487 2527 } else {
2488 2528 $root_url = get_post_type_archive_link( bbp_get_forum_post_type() );
@@ -2505,13 +2545,8 @@
2505 2545 if ( empty( $parent ) || is_wp_error( $parent ) ) {
2506 2546 continue;
2507 2547 }
2508 2548
2509 - // Skip to prevent duplicate root on subpages
2510 - if ( ! empty( $remove_root_id ) && ( $parent->ID === $remove_root_id ) ) {
2511 - continue;
2512 - }
2513 -
2514 2549 // Switch through post_type to ensure correct filters are applied
2515 2550 switch ( $parent->post_type ) {
2516 2551
2517 2552 // Forum
@@ -2523,9 +2558,9 @@
2523 2558 case bbp_get_topic_post_type() :
2524 2559 $crumbs[] = '<a href="' . esc_url( bbp_get_topic_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>';
2525 2560 break;
2526 2561
2527 - // Reply (Note: not in most themes )
2562 + // Reply (Note: not in most themes)
2528 2563 case bbp_get_reply_post_type() :
2529 2564 $crumbs[] = '<a href="' . esc_url( bbp_get_reply_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>';
2530 2565 break;
2531 2566
@@ -2545,9 +2580,9 @@
2545 2580 } elseif ( bbp_is_search() && bbp_get_search_terms() ) {
2546 2581 $crumbs[] = '<a href="' . esc_url( bbp_get_search_url() ) . '" class="bbp-breadcrumb-search">' . esc_html__( 'Search', 'bbpress' ) . '</a>';
2547 2582 }
2548 2583
2549 - /** Current ***********************************************************/
2584 + /** Current ***********************************************************/
2550 2585
2551 2586 // Add current page to breadcrumb
2552 2587 if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) {
2553 2588 $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after'];
@@ -2552,9 +2587,9 @@
2552 2587 if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) {
2553 2588 $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after'];
2554 2589 }
2555 2590
2556 - /** Separator *********************************************************/
2591 + /** Separator *********************************************************/
2557 2592
2558 2593 // Wrap the separator in before/after before padding and filter
2559 2594 if ( ! empty( $r['sep'] ) ) {
2560 2595 $sep = $r['sep_before'] . $r['sep'] . $r['sep_after'];
@@ -2570,9 +2605,9 @@
2570 2605 $sep = str_pad( $sep, strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH );
2571 2606 }
2572 2607 }
2573 2608
2574 - /** Finish Up *********************************************************/
2609 + /** Finish Up *********************************************************/
2575 2610
2576 2611 // Filter the separator and breadcrumb
2577 2612 $sep = apply_filters( 'bbp_breadcrumb_separator', $sep );
2578 2613 $crumbs = apply_filters( 'bbp_breadcrumbs', $crumbs );
@@ -2598,42 +2633,40 @@
2598 2633 */
2599 2634 function bbp_allowed_tags() {
2600 2635 echo bbp_get_allowed_tags();
2601 2636 }
2637 + /**
2638 + * Display all of the allowed tags in HTML format with attributes.
2639 + *
2640 + * This is useful for displaying in the post area, which elements and
2641 + * attributes are supported. As well as any plugins which want to display it.
2642 + *
2643 + * @since 2.0.0 bbPress (r2780)
2644 + *
2645 + * @return string HTML allowed tags entity encoded.
2646 + */
2647 + function bbp_get_allowed_tags() {
2602 2648
2603 -/**
2604 - * Display all of the allowed tags in HTML format with attributes.
2605 - *
2606 - * This is useful for displaying in the post area, which elements and
2607 - * attributes are supported. As well as any plugins which want to display it.
2608 - *
2609 - * @since 2.0.0 bbPress (r2780)
2610 - *
2611 - * @return string HTML allowed tags entity encoded.
2612 - */
2613 -function bbp_get_allowed_tags() {
2614 - $allowed = '';
2649 + $allowed = '';
2615 2650
2616 - foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) {
2617 - $allowed .= '<' . $tag;
2618 -
2619 - if ( 0 < count( $attributes ) ) {
2620 - foreach ( array_keys( $attributes ) as $attribute ) {
2621 - $allowed .= ' ' . $attribute. '=""';
2651 + foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) {
2652 + $allowed .= '<' . $tag;
2653 + if ( 0 < count( $attributes ) ) {
2654 + foreach ( array_keys( $attributes ) as $attribute ) {
2655 + $allowed .= ' ' . $attribute . '=""';
2656 + }
2622 2657 }
2658 + $allowed .= '> ';
2623 2659 }
2624 2660
2625 - $allowed .= '> ';
2661 + // Filter & return
2662 + return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) );
2626 2663 }
2627 2664
2628 - // Filter & return
2629 - return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) );
2630 -}
2631 -
2632 2665 /** Errors & Messages *********************************************************/
2633 2666
2634 2667 /**
2635 - * Display possible errors & messages inside a template file.
2668 + * Display possible errors & messages inside a template file
2636 2669 *
2637 2670 * @since 2.0.0 bbPress (r2688)
2638 2671 */
2639 2672 function bbp_template_notices() {
@@ -2642,9 +2675,9 @@
2642 2675 if ( ! bbp_has_errors() ) {
2643 2676 return;
2644 2677 }
2645 2678
2646 - // Define local variable(s )
2679 + // Define local variable(s)
2647 2680 $errors = $messages = array();
2648 2681
2649 2682 // Get bbPress
2650 2683 $bbp = bbpress();
@@ -2659,15 +2692,15 @@
2659 2692 foreach ( $bbp->errors->get_error_messages( $code ) as $error ) {
2660 2693 if ( 'message' === $severity ) {
2661 2694 $messages[] = $error;
2662 2695 } else {
2663 - $errors[] = $error;
2696 + $errors[] = $error;
2664 2697 }
2665 2698 }
2666 2699 }
2667 2700
2668 2701 // Display errors first...
2669 - if ( ! empty( $errors ) ) { ?>
2702 + if ( ! empty( $errors ) ) : ?>
2670 2703
2671 2704 <div class="bbp-template-notice error" role="alert" tabindex="-1">
2672 2705 <ul>
2673 2706 <li><?php echo implode( "</li>\n<li>", $errors ); ?></li>
@@ -2673,12 +2706,12 @@
2673 2706 <li><?php echo implode( "</li>\n<li>", $errors ); ?></li>
2674 2707 </ul>
2675 2708 </div>
2676 2709
2677 - <?php }
2710 + <?php endif;
2678 2711
2679 2712 // ...and messages last
2680 - if ( ! empty( $messages ) ) { ?>
2713 + if ( ! empty( $messages ) ) : ?>
2681 2714
2682 2715 <div class="bbp-template-notice">
2683 2716 <ul>
2684 2717 <li><?php echo implode( "</li>\n<li>", $messages ); ?></li>
@@ -2684,59 +2717,54 @@
2684 2717 <li><?php echo implode( "</li>\n<li>", $messages ); ?></li>
2685 2718 </ul>
2686 2719 </div>
2687 2720
2688 - <?php
2689 -
2690 - }
2721 + <?php endif;
2691 2722 }
2692 2723
2693 2724 /** Login/logout/register/lost pass *******************************************/
2694 2725
2695 2726 /**
2696 - * Output the logout link.
2727 + * Output the logout link
2697 2728 *
2698 2729 * @since 2.0.0 bbPress (r2827)
2699 2730 *
2700 - * @param string $redirect_to Redirect to url.
2731 + * @param string $redirect_to Redirect to url
2701 2732 */
2702 2733 function bbp_logout_link( $redirect_to = '' ) {
2703 2734 echo bbp_get_logout_link( $redirect_to );
2704 2735 }
2736 + /**
2737 + * Return the logout link
2738 + *
2739 + * @since 2.0.0 bbPress (r2827)
2740 + *
2741 + * @param string $redirect_to Redirect to url
2742 + * redirect to url
2743 + * @return string The logout link
2744 + */
2745 + function bbp_get_logout_link( $redirect_to = '' ) {
2705 2746
2706 -/**
2707 - * Return the logout link.
2708 - *
2709 - * @since 2.0.0 bbPress (r2827)
2710 - *
2711 - * @param string $redirect_to Redirect to url.
2712 - * redirect to url.
2713 - *
2714 - * @return string The logout link.
2715 - */
2716 -function bbp_get_logout_link( $redirect_to = '' ) {
2747 + // Build the link
2748 + $link = '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>';
2717 2749
2718 - // Build the link
2719 - $link = '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>';
2750 + // Filter & return
2751 + return apply_filters( 'bbp_get_logout_link', $link, $redirect_to );
2752 + }
2720 2753
2721 - // Filter & return
2722 - return apply_filters( 'bbp_get_logout_link', $link, $redirect_to );
2723 -}
2724 -
2725 2754 /** Title *********************************************************************/
2726 2755
2727 2756 /**
2728 - * Custom page title for bbPress pages.
2757 + * Custom page title for bbPress pages
2729 2758 *
2730 2759 * @since 2.0.0 bbPress (r2788)
2731 2760 *
2732 - * @param string $title Optional. The title (not used).
2733 - * @param string $sep Optional, default is '&raquo;'. How to separate the
2734 - * various items within the page title.
2761 + * @param string $title Optional. The title (not used).
2762 + * @param string $sep Optional, default is '&raquo;'. How to separate the
2763 + * various items within the page title.
2735 2764 * @param string $seplocation Optional. Direction to display title, 'right'.
2736 - * separator and separator location.
2737 - *
2738 - * @return string The title.
2765 + * separator and separator location
2766 + * @return string The title
2739 2767 */
2740 2768 function bbp_title( $title = '', $sep = '&raquo;', $seplocation = '' ) {
2741 2769
2742 2770 // Title array
@@ -2741,9 +2769,9 @@
2741 2769
2742 2770 // Title array
2743 2771 $new_title = array();
2744 2772
2745 - /* Archives ************************************************************* */
2773 + /** Archives **************************************************************/
2746 2774
2747 2775 // Forum Archive
2748 2776 if ( bbp_is_forum_archive() ) {
2749 2777 $new_title['text'] = bbp_get_forum_archive_title();
@@ -2751,9 +2779,9 @@
2751 2779 // Topic Archive
2752 2780 } elseif ( bbp_is_topic_archive() ) {
2753 2781 $new_title['text'] = bbp_get_topic_archive_title();
2754 2782
2755 - /* Edit ***************************************************************** */
2783 + /** Edit ******************************************************************/
2756 2784
2757 2785 // Forum edit page
2758 2786 } elseif ( bbp_is_forum_edit() ) {
2759 2787 $new_title['text'] = bbp_get_forum_title();
@@ -2777,9 +2805,9 @@
2777 2805 $new_title['text'] = bbp_get_topic_tag_name();
2778 2806 /* translators: %s: Topic tag name */
2779 2807 $new_title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' );
2780 2808
2781 - /* Singles ************************************************************** */
2809 + /** Singles ***************************************************************/
2782 2810
2783 2811 // Forum page
2784 2812 } elseif ( bbp_is_single_forum() ) {
2785 2813 $new_title['text'] = bbp_get_forum_title();
@@ -2801,12 +2829,13 @@
2801 2829 $new_title['text'] = bbp_get_topic_tag_name();
2802 2830 /* translators: %s: Topic tag name */
2803 2831 $new_title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' );
2804 2832
2805 - /* Users **************************************************************** */
2833 + /** Users *****************************************************************/
2806 2834
2807 2835 // Profile page
2808 2836 } elseif ( bbp_is_single_user() ) {
2837 +
2809 2838 // Is user viewing their own profile?
2810 2839 $is_user_home = bbp_is_user_home();
2811 2840
2812 2841 // User topics created
@@ -2849,17 +2878,14 @@
2849 2878 $new_title['format'] = esc_attr__( "%s's Subscriptions", 'bbpress' );
2850 2879 }
2851 2880
2852 2881 // User "home"
2853 - // phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found
2854 - } else {
2855 - if ( true === $is_user_home ) {
2882 + } elseif ( true === $is_user_home ) {
2856 2883 $new_title['text'] = esc_attr__( 'Your Profile', 'bbpress' );
2857 2884 } else {
2858 - $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name;
2859 - /* translators: user's display name */
2860 - $new_title['format'] = esc_attr__( "%s's Profile", 'bbpress' );
2861 - }
2885 + $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name;
2886 + /* translators: user's display name */
2887 + $new_title['format'] = esc_attr__( "%s's Profile", 'bbpress' );
2862 2888 }
2863 2889
2864 2890 // Profile edit page
2865 2891 } elseif ( bbp_is_single_user_edit() ) {
@@ -2873,9 +2899,9 @@
2873 2899 /* translators: %s: User's display name */
2874 2900 $new_title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' );
2875 2901 }
2876 2902
2877 - /* Views **************************************************************** */
2903 + /** Views *****************************************************************/
2878 2904
2879 2905 // Views
2880 2906 } elseif ( bbp_is_single_view() ) {
2881 2907 $new_title['text'] = bbp_get_view_title();
@@ -2881,9 +2907,9 @@
2881 2907 $new_title['text'] = bbp_get_view_title();
2882 2908 /* translators: %s: View title */
2883 2909 $new_title['format'] = esc_attr__( 'View: %s', 'bbpress' );
2884 2910
2885 - /* Search *************************************************************** */
2911 + /** Search ****************************************************************/
2886 2912
2887 2913 // Search
2888 2914 } elseif ( bbp_is_search() ) {
2889 2915 $new_title['text'] = bbp_get_search_title();
@@ -2896,9 +2922,9 @@
2896 2922 $new_title = bbp_parse_args(
2897 2923 $new_title,
2898 2924 array(
2899 2925 'text' => $title,
2900 - 'format' => '%s',
2926 + 'format' => '%s'
2901 2927 ),
2902 2928 'title'
2903 2929 );
2904 2930
@@ -2933,40 +2959,5 @@
2933 2959 }
2934 2960
2935 2961 // Filter & return
2936 2962 return apply_filters( 'bbp_title', $new_title, $sep, $seplocation );
2937 -}
2938 -
2939 -/**
2940 - * Removes Protected/Private post title hints.
2941 - *
2942 - * This function is hooked to 2 WordPress filters that are responsible for
2943 - * prepending hints to the beginning of Protected & Private post titles.
2944 - *
2945 - * These hints are a bit unsightly when used in functions like
2946 - * bbp_get_breadcrumb(), so we strip them back out for bbPress post types.
2947 - *
2948 - * @since 2.7.0
2949 - *
2950 - * @param string $prepend text displayed before a post title.
2951 - * @param int|WP_Post $post current post object.
2952 - *
2953 - * @return string
2954 - */
2955 -function bbp_no_title_status_hints( $prepend = '', $post = 0 ) {
2956 -
2957 - // Bail if empty
2958 - if ( empty( $prepend ) || empty( $post ) ) {
2959 - return $prepend;
2960 - }
2961 -
2962 - // Get post type
2963 - $post_type = get_post_type( $post );
2964 -
2965 - // Maybe override return value
2966 - $retval = in_array( $post_type, bbp_get_post_types(), true )
2967 - ? '%s'
2968 - : $prepend;
2969 -
2970 - // Filter & return
2971 - return (string) apply_filters( 'bbp_no_special_title_formatting', $retval, $prepend, $post );
2972 2963 }