| @@ -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 (r3344) |
| 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 (r3344) |
| 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 (r3348) |
| 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 | |
| @@ -423,9 +420,9 @@ | ||
| 423 | 420 | /** |
| 424 | 421 | * Check if the current post type is one that comes with bbPress. |
| 425 | 422 | * |
| 426 | 423 | * @since 2.0.0 bbPress (r3311) |
| 427 | - * @since 2.6.17 bbPress (r7499) Added support for post-type names and arrays. | |
| 424 | + * @since 2.6.17 bbPress (r7500) Added support for post-type names and arrays. | |
| 428 | 425 | * |
| 429 | 426 | * @param mixed $post_types Optional. Post object, post ID, post-type name, or |
| 430 | 427 | * an array of post-type names. |
| 431 | 428 | * |
| @@ -455,9 +452,9 @@ | ||
| 455 | 452 | |
| 456 | 453 | /** |
| 457 | 454 | * Check if a bbPress object or any of its parents is password protected. |
| 458 | 455 | * |
| 459 | - * @since 2.6.17 bbPress (r7501) | |
| 456 | + * @since 2.6.17 bbPress (r7502) | |
| 460 | 457 | * |
| 461 | 458 | * @param int $object_id Optional. Object ID. Defaults to the current post. |
| 462 | 459 | * @param string $object_type Optional. Object type. Defaults to 'post'. |
| 463 | 460 | * @return bool True if the object is password protected, otherwise false. |
| @@ -559,15 +556,14 @@ | ||
| 559 | 556 | return 0; |
| 560 | 557 | } |
| 561 | 558 | |
| 562 | 559 | /** |
| 563 | - * Check if current page is a bbPress reply. | |
| 560 | + * Check if current page is a bbPress reply | |
| 564 | 561 | * |
| 565 | 562 | * @since 2.0.0 bbPress (r2553) |
| 566 | 563 | * |
| 567 | - * @param int $post_id Possible post_id to check. | |
| 568 | - * | |
| 569 | - * @return bool True if it's a reply page, false if not. | |
| 564 | + * @param int $post_id Possible post_id to check | |
| 565 | + * @return bool True if it's a reply page, false if not | |
| 570 | 566 | */ |
| 571 | 567 | function bbp_is_reply( $post_id = 0 ) { |
| 572 | 568 | |
| 573 | 569 | // Assume false |
| @@ -582,15 +578,15 @@ | ||
| 582 | 578 | return (bool) apply_filters( 'bbp_is_reply', $retval, $post_id ); |
| 583 | 579 | } |
| 584 | 580 | |
| 585 | 581 | /** |
| 586 | - * Check if current page is a reply edit page. | |
| 582 | + * Check if current page is a reply edit page | |
| 587 | 583 | * |
| 588 | 584 | * @since 2.0.0 bbPress (r2753) |
| 589 | 585 | * |
| 590 | 586 | * @global string $pagenow The filename of the current screen. |
| 591 | 587 | * |
| 592 | - * @return bool True if it's the reply edit page, false if not. | |
| 588 | + * @return bool True if it's the reply edit page, false if not | |
| 593 | 589 | */ |
| 594 | 590 | function bbp_is_reply_edit() { |
| 595 | 591 | global $pagenow; |
| 596 | 592 | |
| @@ -613,11 +609,11 @@ | ||
| 613 | 609 | return (bool) apply_filters( 'bbp_is_reply_edit', $retval ); |
| 614 | 610 | } |
| 615 | 611 | |
| 616 | 612 | /** |
| 617 | - * Check if current page is a reply move page. | |
| 613 | + * Check if current page is a reply move page | |
| 618 | 614 | * |
| 619 | - * @return bool True if it's the reply move page, false if not. | |
| 615 | + * @return bool True if it's the reply move page, false if not | |
| 620 | 616 | */ |
| 621 | 617 | function bbp_is_reply_move() { |
| 622 | 618 | |
| 623 | 619 | // Assume false |
| @@ -632,9 +628,9 @@ | ||
| 632 | 628 | return (bool) apply_filters( 'bbp_is_reply_move', $retval ); |
| 633 | 629 | } |
| 634 | 630 | |
| 635 | 631 | /** |
| 636 | - * Viewing a single reply. | |
| 632 | + * Viewing a single reply | |
| 637 | 633 | * |
| 638 | 634 | * @since 2.0.0 bbPress (r3344) |
| 639 | 635 | * |
| 640 | 636 | * @return bool |
| @@ -649,9 +645,9 @@ | ||
| 649 | 645 | return false; |
| 650 | 646 | } |
| 651 | 647 | |
| 652 | 648 | // Single and a match |
| 653 | - if ( is_singular( bbp_get_reply_post_type() ) || bbp_is_query_name( 'bbp_single_reply' ) ) { | |
| 649 | + if ( is_singular( bbp_get_reply_post_type() ) || ( bbp_is_query_name( 'bbp_single_reply' ) ) ) { | |
| 654 | 650 | $retval = true; |
| 655 | 651 | } |
| 656 | 652 | |
| 657 | 653 | // Filter & return |
| @@ -658,13 +654,13 @@ | ||
| 658 | 654 | return (bool) apply_filters( 'bbp_is_single_reply', $retval ); |
| 659 | 655 | } |
| 660 | 656 | |
| 661 | 657 | /** |
| 662 | - * Check if current page is a bbPress user's favorites page (profile page). | |
| 658 | + * Check if current page is a bbPress user's favorites page (profile page) | |
| 663 | 659 | * |
| 664 | 660 | * @since 2.0.0 bbPress (r2652) |
| 665 | 661 | * |
| 666 | - * @return bool True if it's the favorites page, false if not. | |
| 662 | + * @return bool True if it's the favorites page, false if not | |
| 667 | 663 | */ |
| 668 | 664 | function bbp_is_favorites() { |
| 669 | 665 | |
| 670 | 666 | // Assume false |
| @@ -682,13 +678,13 @@ | ||
| 682 | 678 | return (bool) apply_filters( 'bbp_is_favorites', $retval ); |
| 683 | 679 | } |
| 684 | 680 | |
| 685 | 681 | /** |
| 686 | - * Check if current page is a bbPress user's subscriptions page (profile page). | |
| 682 | + * Check if current page is a bbPress user's subscriptions page (profile page) | |
| 687 | 683 | * |
| 688 | 684 | * @since 2.0.0 bbPress (r2668) |
| 689 | 685 | * |
| 690 | - * @return bool True if it's the subscriptions page, false if not. | |
| 686 | + * @return bool True if it's the subscriptions page, false if not | |
| 691 | 687 | */ |
| 692 | 688 | function bbp_is_subscriptions() { |
| 693 | 689 | |
| 694 | 690 | // Assume false |
| @@ -707,13 +703,13 @@ | ||
| 707 | 703 | } |
| 708 | 704 | |
| 709 | 705 | /** |
| 710 | 706 | * Check if current page shows the topics created by a bbPress user (profile |
| 711 | - * page). | |
| 707 | + * page) | |
| 712 | 708 | * |
| 713 | 709 | * @since 2.0.0 bbPress (r2688) |
| 714 | 710 | * |
| 715 | - * @return bool True if it's the topics created page, false if not. | |
| 711 | + * @return bool True if it's the topics created page, false if not | |
| 716 | 712 | */ |
| 717 | 713 | function bbp_is_topics_created() { |
| 718 | 714 | |
| 719 | 715 | // Assume false |
| @@ -732,13 +728,13 @@ | ||
| 732 | 728 | } |
| 733 | 729 | |
| 734 | 730 | /** |
| 735 | 731 | * Check if current page shows the replies created by a bbPress user (profile |
| 736 | - * page). | |
| 732 | + * page) | |
| 737 | 733 | * |
| 738 | 734 | * @since 2.2.0 bbPress (r4228) |
| 739 | 735 | * |
| 740 | - * @return bool True if it's the replies created page, false if not. | |
| 736 | + * @return bool True if it's the replies created page, false if not | |
| 741 | 737 | */ |
| 742 | 738 | function bbp_is_replies_created() { |
| 743 | 739 | |
| 744 | 740 | // Assume false |
| @@ -756,13 +752,13 @@ | ||
| 756 | 752 | return (bool) apply_filters( 'bbp_is_replies_created', $retval ); |
| 757 | 753 | } |
| 758 | 754 | |
| 759 | 755 | /** |
| 760 | - * Check if current page is the currently logged in users author page. | |
| 756 | + * Check if current page is the currently logged in users author page | |
| 761 | 757 | * |
| 762 | 758 | * @since 2.0.0 bbPress (r2660) |
| 763 | 759 | * |
| 764 | - * @return bool True if it's the user's home, false if not. | |
| 760 | + * @return bool True if it's the user's home, false if not | |
| 765 | 761 | */ |
| 766 | 762 | function bbp_is_user_home() { |
| 767 | 763 | |
| 768 | 764 | // Assume false |
| @@ -780,13 +776,13 @@ | ||
| 780 | 776 | return (bool) apply_filters( 'bbp_is_user_home', $retval ); |
| 781 | 777 | } |
| 782 | 778 | |
| 783 | 779 | /** |
| 784 | - * Check if current page is the currently logged in users author edit page. | |
| 780 | + * Check if current page is the currently logged in users author edit page | |
| 785 | 781 | * |
| 786 | 782 | * @since 2.1.0 bbPress (r3918) |
| 787 | 783 | * |
| 788 | - * @return bool True if it's the user's home, false if not. | |
| 784 | + * @return bool True if it's the user's home, false if not | |
| 789 | 785 | */ |
| 790 | 786 | function bbp_is_user_home_edit() { |
| 791 | 787 | |
| 792 | 788 | // Assume false |
| @@ -800,13 +796,13 @@ | ||
| 800 | 796 | return (bool) apply_filters( 'bbp_is_user_home_edit', $retval ); |
| 801 | 797 | } |
| 802 | 798 | |
| 803 | 799 | /** |
| 804 | - * Check if current page is a user profile page. | |
| 800 | + * Check if current page is a user profile page | |
| 805 | 801 | * |
| 806 | 802 | * @since 2.0.0 bbPress (r3311) |
| 807 | 803 | * |
| 808 | - * @return bool True if it's a user's profile page, false if not. | |
| 804 | + * @return bool True if it's a user's profile page, false if not | |
| 809 | 805 | */ |
| 810 | 806 | function bbp_is_single_user() { |
| 811 | 807 | |
| 812 | 808 | // Assume false |
| @@ -824,13 +820,13 @@ | ||
| 824 | 820 | return (bool) apply_filters( 'bbp_is_single_user', $retval ); |
| 825 | 821 | } |
| 826 | 822 | |
| 827 | 823 | /** |
| 828 | - * Check if current page is a user profile edit page. | |
| 824 | + * Check if current page is a user profile edit page | |
| 829 | 825 | * |
| 830 | 826 | * @since 2.0.0 bbPress (r3311) |
| 831 | 827 | * |
| 832 | - * @return bool True if it's a user's profile edit page, false if not. | |
| 828 | + * @return bool True if it's a user's profile edit page, false if not | |
| 833 | 829 | */ |
| 834 | 830 | function bbp_is_single_user_edit() { |
| 835 | 831 | |
| 836 | 832 | // Assume false |
| @@ -848,13 +844,13 @@ | ||
| 848 | 844 | return (bool) apply_filters( 'bbp_is_single_user_edit', $retval ); |
| 849 | 845 | } |
| 850 | 846 | |
| 851 | 847 | /** |
| 852 | - * Check if current page is a user profile page. | |
| 848 | + * Check if current page is a user profile page | |
| 853 | 849 | * |
| 854 | 850 | * @since 2.2.0 bbPress (r4228) |
| 855 | 851 | * |
| 856 | - * @return bool True if it's a user's profile page, false if not. | |
| 852 | + * @return bool True if it's a user's profile page, false if not | |
| 857 | 853 | */ |
| 858 | 854 | function bbp_is_single_user_profile() { |
| 859 | 855 | |
| 860 | 856 | // Assume false |
| @@ -872,13 +868,13 @@ | ||
| 872 | 868 | return (bool) apply_filters( 'bbp_is_single_user_profile', $retval ); |
| 873 | 869 | } |
| 874 | 870 | |
| 875 | 871 | /** |
| 876 | - * Check if current page is a user topics created page. | |
| 872 | + * Check if current page is a user topics created page | |
| 877 | 873 | * |
| 878 | 874 | * @since 2.2.0 bbPress (r4228) |
| 879 | 875 | * |
| 880 | - * @return bool True if it's a user's topics page, false if not. | |
| 876 | + * @return bool True if it's a user's topics page, false if not | |
| 881 | 877 | */ |
| 882 | 878 | function bbp_is_single_user_topics() { |
| 883 | 879 | |
| 884 | 880 | // Assume false |
| @@ -896,13 +892,13 @@ | ||
| 896 | 892 | return (bool) apply_filters( 'bbp_is_single_user_topics', $retval ); |
| 897 | 893 | } |
| 898 | 894 | |
| 899 | 895 | /** |
| 900 | - * Check if current page is a user replies created page. | |
| 896 | + * Check if current page is a user replies created page | |
| 901 | 897 | * |
| 902 | 898 | * @since 2.2.0 bbPress (r4228) |
| 903 | 899 | * |
| 904 | - * @return bool True if it's a user's replies page, false if not. | |
| 900 | + * @return bool True if it's a user's replies page, false if not | |
| 905 | 901 | */ |
| 906 | 902 | function bbp_is_single_user_replies() { |
| 907 | 903 | |
| 908 | 904 | // Assume false |
| @@ -920,13 +916,13 @@ | ||
| 920 | 916 | return (bool) apply_filters( 'bbp_is_single_user_replies', $retval ); |
| 921 | 917 | } |
| 922 | 918 | |
| 923 | 919 | /** |
| 924 | - * Check if current page is a user engagements page. | |
| 920 | + * Check if current page is a user engagements page | |
| 925 | 921 | * |
| 926 | 922 | * @since 2.6.0 bbPress (r6320) |
| 927 | 923 | * |
| 928 | - * @return bool True if it's a user's replies page, false if not. | |
| 924 | + * @return bool True if it's a user's replies page, false if not | |
| 929 | 925 | */ |
| 930 | 926 | function bbp_is_single_user_engagements() { |
| 931 | 927 | |
| 932 | 928 | // Assume false |
| @@ -944,14 +940,13 @@ | ||
| 944 | 940 | return (bool) apply_filters( 'bbp_is_single_user_engagements', $retval ); |
| 945 | 941 | } |
| 946 | 942 | |
| 947 | 943 | /** |
| 948 | - * Check if current page is a view page. | |
| 944 | + * Check if current page is a view page | |
| 949 | 945 | * |
| 950 | 946 | * @since 2.0.0 bbPress (r3311) |
| 951 | 947 | * |
| 952 | - * @global WP_Query $wp_query To check if WP_Query::bbp_is_view is true. | |
| 953 | - * | |
| 948 | + * @global WP_Query $wp_query To check if WP_Query::bbp_is_view is true | |
| 954 | 949 | * @return bool Is it a view page? |
| 955 | 950 | */ |
| 956 | 951 | function bbp_is_single_view() { |
| 957 | 952 | |
| @@ -975,14 +970,13 @@ | ||
| 975 | 970 | return (bool) apply_filters( 'bbp_is_single_view', $retval ); |
| 976 | 971 | } |
| 977 | 972 | |
| 978 | 973 | /** |
| 979 | - * Check if current page is a search page. | |
| 974 | + * Check if current page is a search page | |
| 980 | 975 | * |
| 981 | 976 | * @since 2.3.0 bbPress (r4579) |
| 982 | 977 | * |
| 983 | - * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true. | |
| 984 | - * | |
| 978 | + * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true | |
| 985 | 979 | * @return bool Is it a search page? |
| 986 | 980 | */ |
| 987 | 981 | function bbp_is_search() { |
| 988 | 982 | |
| @@ -996,9 +990,9 @@ | ||
| 996 | 990 | |
| 997 | 991 | // Get the main query global |
| 998 | 992 | $wp_query = bbp_get_wp_query(); |
| 999 | 993 | |
| 1000 | - // Get the rewrite ID (one time, to avoid repeated calls ) | |
| 994 | + // Get the rewrite ID (one time, to avoid repeated calls) | |
| 1001 | 995 | $rewrite_id = bbp_get_search_rewrite_id(); |
| 1002 | 996 | |
| 1003 | 997 | // Check query |
| 1004 | 998 | if ( ! empty( $wp_query->bbp_is_search ) && ( true === $wp_query->bbp_is_search ) ) { |
| @@ -1019,14 +1013,13 @@ | ||
| 1019 | 1013 | return (bool) apply_filters( 'bbp_is_search', $retval ); |
| 1020 | 1014 | } |
| 1021 | 1015 | |
| 1022 | 1016 | /** |
| 1023 | - * Check if current page is a search results page. | |
| 1017 | + * Check if current page is a search results page | |
| 1024 | 1018 | * |
| 1025 | 1019 | * @since 2.4.0 bbPress (r4919) |
| 1026 | 1020 | * |
| 1027 | - * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true. | |
| 1028 | - * | |
| 1021 | + * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true | |
| 1029 | 1022 | * @return bool Is it a search page? |
| 1030 | 1023 | */ |
| 1031 | 1024 | function bbp_is_search_results() { |
| 1032 | 1025 | |
| @@ -1060,13 +1053,13 @@ | ||
| 1060 | 1053 | return (bool) apply_filters( 'bbp_is_search_results', $retval ); |
| 1061 | 1054 | } |
| 1062 | 1055 | |
| 1063 | 1056 | /** |
| 1064 | - * Check if current page is an edit page. | |
| 1057 | + * Check if current page is an edit page | |
| 1065 | 1058 | * |
| 1066 | 1059 | * @since 2.1.0 bbPress (r3586) |
| 1067 | 1060 | * |
| 1068 | - * @return bool True if it's the edit page, false if not. | |
| 1061 | + * @return bool True if it's the edit page, false if not | |
| 1069 | 1062 | */ |
| 1070 | 1063 | function bbp_is_edit() { |
| 1071 | 1064 | |
| 1072 | 1065 | // Assume false |
| @@ -1084,15 +1077,14 @@ | ||
| 1084 | 1077 | return (bool) apply_filters( 'bbp_is_edit', $retval ); |
| 1085 | 1078 | } |
| 1086 | 1079 | |
| 1087 | 1080 | /** |
| 1088 | - * Use the above is_() functions to output a body class for each scenario. | |
| 1081 | + * Use the above is_() functions to output a body class for each scenario | |
| 1089 | 1082 | * |
| 1090 | 1083 | * @since 2.0.0 bbPress (r2926) |
| 1091 | 1084 | * |
| 1092 | 1085 | * @param array $wp_classes |
| 1093 | 1086 | * @param array $custom_classes |
| 1094 | - * | |
| 1095 | 1087 | * @return array Body Classes |
| 1096 | 1088 | */ |
| 1097 | 1089 | function bbp_body_class( $wp_classes = array(), $custom_classes = false ) { |
| 1098 | 1090 | |
| @@ -1098,16 +1090,18 @@ | ||
| 1098 | 1090 | |
| 1099 | 1091 | // Default to no classes |
| 1100 | 1092 | $bbp_classes = array(); |
| 1101 | 1093 | |
| 1102 | - /* Archives ***************************************************************/ | |
| 1094 | + /** Archives **************************************************************/ | |
| 1103 | 1095 | |
| 1104 | 1096 | if ( bbp_is_forum_archive() ) { |
| 1105 | 1097 | $bbp_classes[] = bbp_get_forum_post_type() . '-archive'; |
| 1098 | + | |
| 1106 | 1099 | } elseif ( bbp_is_topic_archive() ) { |
| 1107 | 1100 | $bbp_classes[] = bbp_get_topic_post_type() . '-archive'; |
| 1108 | 1101 | |
| 1109 | - /* Topic Tags *************************************************************/ | |
| 1102 | + /** Topic Tags ************************************************************/ | |
| 1103 | + | |
| 1110 | 1104 | } elseif ( bbp_is_topic_tag() ) { |
| 1111 | 1105 | $bbp_classes[] = bbp_get_topic_tag_tax_id(); |
| 1112 | 1106 | $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_slug(); |
| 1113 | 1107 | $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id(); |
| @@ -1113,92 +1107,112 @@ | ||
| 1113 | 1107 | $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id(); |
| 1114 | 1108 | } elseif ( bbp_is_topic_tag_edit() ) { |
| 1115 | 1109 | $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-edit'; |
| 1116 | 1110 | $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_slug() . '-edit'; |
| 1117 | - $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id() . '-edit'; | |
| 1111 | + $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id() . '-edit'; | |
| 1118 | 1112 | |
| 1119 | - /* Components *************************************************************/ | |
| 1113 | + /** Components ************************************************************/ | |
| 1114 | + | |
| 1120 | 1115 | } elseif ( bbp_is_single_forum() ) { |
| 1121 | 1116 | $bbp_classes[] = bbp_get_forum_post_type(); |
| 1117 | + | |
| 1122 | 1118 | } elseif ( bbp_is_single_topic() ) { |
| 1123 | 1119 | $bbp_classes[] = bbp_get_topic_post_type(); |
| 1120 | + | |
| 1124 | 1121 | } elseif ( bbp_is_single_reply() ) { |
| 1125 | 1122 | $bbp_classes[] = bbp_get_reply_post_type(); |
| 1123 | + | |
| 1126 | 1124 | } elseif ( bbp_is_topic_edit() ) { |
| 1127 | 1125 | $bbp_classes[] = bbp_get_topic_post_type() . '-edit'; |
| 1126 | + | |
| 1128 | 1127 | } elseif ( bbp_is_topic_merge() ) { |
| 1129 | 1128 | $bbp_classes[] = bbp_get_topic_post_type() . '-merge'; |
| 1129 | + | |
| 1130 | 1130 | } elseif ( bbp_is_topic_split() ) { |
| 1131 | 1131 | $bbp_classes[] = bbp_get_topic_post_type() . '-split'; |
| 1132 | + | |
| 1132 | 1133 | } elseif ( bbp_is_reply_edit() ) { |
| 1133 | 1134 | $bbp_classes[] = bbp_get_reply_post_type() . '-edit'; |
| 1135 | + | |
| 1134 | 1136 | } elseif ( bbp_is_reply_move() ) { |
| 1135 | 1137 | $bbp_classes[] = bbp_get_reply_post_type() . '-move'; |
| 1138 | + | |
| 1136 | 1139 | } elseif ( bbp_is_single_view() ) { |
| 1137 | 1140 | $bbp_classes[] = 'bbp-view'; |
| 1138 | 1141 | $bbp_classes[] = 'bbp-view-' . bbp_get_view_id(); |
| 1139 | 1142 | |
| 1140 | - /* User *******************************************************************/ | |
| 1143 | + /** User ******************************************************************/ | |
| 1144 | + | |
| 1141 | 1145 | } elseif ( bbp_is_single_user_edit() ) { |
| 1142 | 1146 | $bbp_classes[] = 'bbp-user-edit'; |
| 1143 | 1147 | $bbp_classes[] = 'single'; |
| 1144 | 1148 | $bbp_classes[] = 'singular'; |
| 1149 | + | |
| 1145 | 1150 | } elseif ( bbp_is_single_user() ) { |
| 1146 | 1151 | $bbp_classes[] = 'bbp-user-page'; |
| 1147 | 1152 | $bbp_classes[] = 'single'; |
| 1148 | 1153 | $bbp_classes[] = 'singular'; |
| 1154 | + | |
| 1149 | 1155 | } elseif ( bbp_is_user_home() ) { |
| 1150 | 1156 | $bbp_classes[] = 'bbp-user-home'; |
| 1151 | 1157 | $bbp_classes[] = 'single'; |
| 1152 | 1158 | $bbp_classes[] = 'singular'; |
| 1159 | + | |
| 1153 | 1160 | } elseif ( bbp_is_user_home_edit() ) { |
| 1154 | 1161 | $bbp_classes[] = 'bbp-user-home-edit'; |
| 1155 | 1162 | $bbp_classes[] = 'single'; |
| 1156 | 1163 | $bbp_classes[] = 'singular'; |
| 1164 | + | |
| 1157 | 1165 | } elseif ( bbp_is_topics_created() ) { |
| 1158 | 1166 | $bbp_classes[] = 'bbp-topics-created'; |
| 1159 | 1167 | $bbp_classes[] = 'single'; |
| 1160 | 1168 | $bbp_classes[] = 'singular'; |
| 1169 | + | |
| 1161 | 1170 | } elseif ( bbp_is_replies_created() ) { |
| 1162 | 1171 | $bbp_classes[] = 'bbp-replies-created'; |
| 1163 | 1172 | $bbp_classes[] = 'single'; |
| 1164 | 1173 | $bbp_classes[] = 'singular'; |
| 1174 | + | |
| 1165 | 1175 | } elseif ( bbp_is_favorites() ) { |
| 1166 | 1176 | $bbp_classes[] = 'bbp-favorites'; |
| 1167 | 1177 | $bbp_classes[] = 'single'; |
| 1168 | 1178 | $bbp_classes[] = 'singular'; |
| 1179 | + | |
| 1169 | 1180 | } elseif ( bbp_is_subscriptions() ) { |
| 1170 | 1181 | $bbp_classes[] = 'bbp-subscriptions'; |
| 1171 | 1182 | $bbp_classes[] = 'single'; |
| 1172 | 1183 | $bbp_classes[] = 'singular'; |
| 1173 | 1184 | |
| 1174 | - /* Search *****************************************************************/ | |
| 1185 | + /** Search ****************************************************************/ | |
| 1186 | + | |
| 1175 | 1187 | } elseif ( bbp_is_search() ) { |
| 1176 | 1188 | $bbp_classes[] = 'bbp-search'; |
| 1177 | 1189 | $bbp_classes[] = 'forum-search'; |
| 1190 | + | |
| 1178 | 1191 | } elseif ( bbp_is_search_results() ) { |
| 1179 | 1192 | $bbp_classes[] = 'bbp-search-results'; |
| 1180 | 1193 | $bbp_classes[] = 'forum-search-results'; |
| 1181 | 1194 | |
| 1182 | - /* Shortcodes *************************************************************/ | |
| 1195 | + /** Shortcodes ************************************************************/ | |
| 1196 | + | |
| 1183 | 1197 | } elseif ( bbp_has_shortcode() ) { |
| 1184 | 1198 | $bbp_classes[] = 'bbp-shortcode'; |
| 1185 | 1199 | } |
| 1186 | 1200 | |
| 1187 | - /* General ****************************************************************/ | |
| 1201 | + /** General ***************************************************************/ | |
| 1188 | 1202 | |
| 1189 | 1203 | // Any page with bbPress content |
| 1190 | 1204 | if ( ! empty( $bbp_classes ) ) { |
| 1191 | 1205 | $bbp_classes[] = 'bbpress'; |
| 1192 | - $bbp_classes[] = 'no-js'; | |
| 1206 | + $bbp_classes[] = 'bbp-no-js'; | |
| 1193 | 1207 | } |
| 1194 | 1208 | |
| 1195 | 1209 | /** Clean up **************************************************************/ |
| 1196 | 1210 | |
| 1197 | 1211 | // Merge WP classes with bbPress classes and remove any duplicates |
| 1198 | - $classes = array_unique(array_merge( (array) $bbp_classes, (array) $wp_classes ) ); | |
| 1212 | + $classes = array_unique( array_merge( (array) $bbp_classes, (array) $wp_classes ) ); | |
| 1199 | 1213 | |
| 1200 | - // Deprecated filter (do not use ) | |
| 1214 | + // Deprecated filter (do not use) | |
| 1201 | 1215 | $classes = apply_filters( 'bbp_get_the_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes ); |
| 1202 | 1216 | |
| 1203 | 1217 | // Filter & return |
| 1204 | 1218 | return (array) apply_filters( 'bbp_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes ); |
| @@ -1207,9 +1221,9 @@ | ||
| 1207 | 1221 | /** |
| 1208 | 1222 | * Output a small piece of JavaScript to replace the "bbp-no-js" body class |
| 1209 | 1223 | * with "bbp-js" to allow interactive & dynamic elements to work as intended. |
| 1210 | 1224 | * |
| 1211 | - * @since 2.6.10 bbPress (r7231) | |
| 1225 | + * @since 2.6.10 bbPress (r7230) | |
| 1212 | 1226 | */ |
| 1213 | 1227 | function bbp_swap_no_js_body_class() { |
| 1214 | 1228 | static $done = false; |
| 1215 | 1229 | |
| @@ -1220,11 +1234,11 @@ | ||
| 1220 | 1234 | |
| 1221 | 1235 | // Mark as done |
| 1222 | 1236 | $done = true; |
| 1223 | 1237 | |
| 1224 | - ?> | |
| 1238 | +?> | |
| 1225 | 1239 | |
| 1226 | -<script id="bbp-swap-no-js-body-class"> | |
| 1240 | +<script type="text/javascript" id="bbp-swap-no-js-body-class"> | |
| 1227 | 1241 | document.body.className = document.body.className.replace( 'bbp-no-js', 'bbp-js' ); |
| 1228 | 1242 | </script> |
| 1229 | 1243 | |
| 1230 | 1244 | <?php |
| @@ -1242,9 +1256,8 @@ | ||
| 1242 | 1256 | * |
| 1243 | 1257 | * @since 2.6.0 bbPress (r6440) |
| 1244 | 1258 | * |
| 1245 | 1259 | * @param string $text |
| 1246 | - * | |
| 1247 | 1260 | * @return bool |
| 1248 | 1261 | */ |
| 1249 | 1262 | function bbp_has_shortcode( $text = '' ) { |
| 1250 | 1263 | |
| @@ -1278,13 +1291,13 @@ | ||
| 1278 | 1291 | return (bool) apply_filters( 'bbp_has_shortcode', $retval, $found, $text ); |
| 1279 | 1292 | } |
| 1280 | 1293 | |
| 1281 | 1294 | /** |
| 1282 | - * Use the above is_() functions to return if in any bbPress page. | |
| 1295 | + * Use the above is_() functions to return if in any bbPress page | |
| 1283 | 1296 | * |
| 1284 | 1297 | * @since 2.0.0 bbPress (r3344) |
| 1285 | 1298 | * |
| 1286 | - * @return bool In a bbPress page. | |
| 1299 | + * @return bool In a bbPress page | |
| 1287 | 1300 | */ |
| 1288 | 1301 | function is_bbpress() { |
| 1289 | 1302 | |
| 1290 | 1303 | // Default to false |
| @@ -1291,76 +1304,98 @@ | ||
| 1291 | 1304 | $retval = false; |
| 1292 | 1305 | |
| 1293 | 1306 | // Bail if main query has not been populated. |
| 1294 | 1307 | if ( ! bbp_get_wp_query() ) { |
| 1295 | - _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' ); | |
| 1296 | - | |
| 1308 | + _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' ); | |
| 1297 | 1309 | return $retval; |
| 1298 | 1310 | } |
| 1299 | 1311 | |
| 1300 | - /* Archives ***************************************************************/ | |
| 1312 | + /** Archives **************************************************************/ | |
| 1301 | 1313 | |
| 1302 | 1314 | if ( bbp_is_forum_archive() ) { |
| 1303 | 1315 | $retval = true; |
| 1316 | + | |
| 1304 | 1317 | } elseif ( bbp_is_topic_archive() ) { |
| 1305 | 1318 | $retval = true; |
| 1306 | 1319 | |
| 1307 | - /* Topic Tags *************************************************************/ | |
| 1320 | + /** Topic Tags ************************************************************/ | |
| 1321 | + | |
| 1308 | 1322 | } elseif ( bbp_is_topic_tag() ) { |
| 1309 | 1323 | $retval = true; |
| 1324 | + | |
| 1310 | 1325 | } elseif ( bbp_is_topic_tag_edit() ) { |
| 1311 | 1326 | $retval = true; |
| 1312 | 1327 | |
| 1313 | - /* Components *************************************************************/ | |
| 1328 | + /** Components ************************************************************/ | |
| 1329 | + | |
| 1314 | 1330 | } elseif ( bbp_is_single_forum() ) { |
| 1315 | 1331 | $retval = true; |
| 1332 | + | |
| 1316 | 1333 | } elseif ( bbp_is_single_topic() ) { |
| 1317 | 1334 | $retval = true; |
| 1335 | + | |
| 1318 | 1336 | } elseif ( bbp_is_single_reply() ) { |
| 1319 | 1337 | $retval = true; |
| 1338 | + | |
| 1320 | 1339 | } elseif ( bbp_is_topic_edit() ) { |
| 1321 | 1340 | $retval = true; |
| 1341 | + | |
| 1322 | 1342 | } elseif ( bbp_is_topic_merge() ) { |
| 1323 | 1343 | $retval = true; |
| 1344 | + | |
| 1324 | 1345 | } elseif ( bbp_is_topic_split() ) { |
| 1325 | 1346 | $retval = true; |
| 1347 | + | |
| 1326 | 1348 | } elseif ( bbp_is_reply_edit() ) { |
| 1327 | 1349 | $retval = true; |
| 1350 | + | |
| 1328 | 1351 | } elseif ( bbp_is_reply_move() ) { |
| 1329 | 1352 | $retval = true; |
| 1353 | + | |
| 1330 | 1354 | } elseif ( bbp_is_single_view() ) { |
| 1331 | 1355 | $retval = true; |
| 1332 | 1356 | |
| 1333 | - /* User *******************************************************************/ | |
| 1357 | + /** User ******************************************************************/ | |
| 1358 | + | |
| 1334 | 1359 | } elseif ( bbp_is_single_user_edit() ) { |
| 1335 | 1360 | $retval = true; |
| 1361 | + | |
| 1336 | 1362 | } elseif ( bbp_is_single_user() ) { |
| 1337 | 1363 | $retval = true; |
| 1364 | + | |
| 1338 | 1365 | } elseif ( bbp_is_user_home() ) { |
| 1339 | 1366 | $retval = true; |
| 1367 | + | |
| 1340 | 1368 | } elseif ( bbp_is_user_home_edit() ) { |
| 1341 | 1369 | $retval = true; |
| 1370 | + | |
| 1342 | 1371 | } elseif ( bbp_is_topics_created() ) { |
| 1343 | 1372 | $retval = true; |
| 1373 | + | |
| 1344 | 1374 | } elseif ( bbp_is_replies_created() ) { |
| 1345 | 1375 | $retval = true; |
| 1376 | + | |
| 1346 | 1377 | } elseif ( bbp_is_favorites() ) { |
| 1347 | 1378 | $retval = true; |
| 1379 | + | |
| 1348 | 1380 | } elseif ( bbp_is_subscriptions() ) { |
| 1349 | 1381 | $retval = true; |
| 1350 | 1382 | |
| 1351 | - /* Search *****************************************************************/ | |
| 1383 | + /** Search ****************************************************************/ | |
| 1384 | + | |
| 1352 | 1385 | } elseif ( bbp_is_search() ) { |
| 1353 | 1386 | $retval = true; |
| 1387 | + | |
| 1354 | 1388 | } elseif ( bbp_is_search_results() ) { |
| 1355 | 1389 | $retval = true; |
| 1356 | 1390 | |
| 1357 | - /* Shortcodes *************************************************************/ | |
| 1391 | + /** Shortcodes ************************************************************/ | |
| 1392 | + | |
| 1358 | 1393 | } elseif ( bbp_has_shortcode() ) { |
| 1359 | 1394 | $retval = true; |
| 1360 | 1395 | } |
| 1361 | 1396 | |
| 1362 | - /* Done *******************************************************************/ | |
| 1397 | + /** Done ******************************************************************/ | |
| 1363 | 1398 | |
| 1364 | 1399 | // Filter & return |
| 1365 | 1400 | return (bool) apply_filters( 'is_bbpress', $retval ); |
| 1366 | 1401 | } |
| @@ -1367,29 +1402,29 @@ | ||
| 1367 | 1402 | |
| 1368 | 1403 | /** Forms *********************************************************************/ |
| 1369 | 1404 | |
| 1370 | 1405 | /** |
| 1371 | - * Output the login form action url. | |
| 1406 | + * Output the login form action url | |
| 1372 | 1407 | * |
| 1373 | 1408 | * @since 2.0.0 bbPress (r2815) |
| 1374 | 1409 | * |
| 1375 | 1410 | * @param array $args This function supports these arguments: |
| 1376 | - * - action: The action being taken | |
| 1377 | - * - context: The context the action is being taken from | |
| 1411 | + * - action: The action being taken | |
| 1412 | + * - context: The context the action is being taken from | |
| 1378 | 1413 | */ |
| 1379 | 1414 | function bbp_wp_login_action( $args = array() ) { |
| 1380 | 1415 | echo esc_url( bbp_get_wp_login_action( $args ) ); |
| 1381 | 1416 | } |
| 1382 | 1417 | |
| 1383 | -/** | |
| 1384 | - * Return the login form action url. | |
| 1385 | - * | |
| 1386 | - * @since 2.6.0 bbPress (r5685) | |
| 1387 | - * | |
| 1388 | - * @param array $args This function supports these arguments: | |
| 1389 | - * - action: The action being taken | |
| 1390 | - * - context: The context the action is being taken from | |
| 1391 | - */ | |
| 1418 | + /** | |
| 1419 | + * Return the login form action url | |
| 1420 | + * | |
| 1421 | + * @since 2.6.0 bbPress (r5685) | |
| 1422 | + * | |
| 1423 | + * @param array $args This function supports these arguments: | |
| 1424 | + * - action: The action being taken | |
| 1425 | + * - context: The context the action is being taken from | |
| 1426 | + */ | |
| 1392 | 1427 | function bbp_get_wp_login_action( $args = array() ) { |
| 1393 | 1428 | |
| 1394 | 1429 | // Parse arguments against default values |
| 1395 | 1430 | $r = bbp_parse_args( |
| @@ -1396,9 +1431,9 @@ | ||
| 1396 | 1431 | $args, |
| 1397 | 1432 | array( |
| 1398 | 1433 | 'action' => '', |
| 1399 | 1434 | 'context' => '', |
| 1400 | - 'url' => 'wp-login.php', | |
| 1435 | + 'url' => 'wp-login.php' | |
| 1401 | 1436 | ), |
| 1402 | 1437 | 'login_action' |
| 1403 | 1438 | ); |
| 1404 | 1439 | |
| @@ -1420,9 +1455,9 @@ | ||
| 1420 | 1455 | * check the field manually, use bbp_get_redirect_to(). |
| 1421 | 1456 | * |
| 1422 | 1457 | * @since 2.0.0 bbPress (r2815) |
| 1423 | 1458 | * |
| 1424 | - * @param string $redirect_to Pass a URL to redirect to. | |
| 1459 | + * @param string $redirect_to Pass a URL to redirect to | |
| 1425 | 1460 | */ |
| 1426 | 1461 | function bbp_redirect_to_field( $redirect_to = '' ) { |
| 1427 | 1462 | |
| 1428 | 1463 | // Make sure we are directing somewhere |
| @@ -1449,62 +1484,61 @@ | ||
| 1449 | 1484 | * ensures correct sanitization of the value for the receiving input. |
| 1450 | 1485 | * |
| 1451 | 1486 | * @since 2.0.0 bbPress (r2815) |
| 1452 | 1487 | * |
| 1453 | - * @param string $request Name of $_REQUEST to look for | |
| 1488 | + * @param string $request Name of $_REQUEST to look for | |
| 1454 | 1489 | * @param string $input_type Type of input. Default: text. Accepts: |
| 1455 | - * textarea|password|select|radio|checkbox | |
| 1490 | + * textarea|password|select|radio|checkbox | |
| 1456 | 1491 | */ |
| 1457 | 1492 | function bbp_sanitize_val( $request = '', $input_type = 'text' ) { |
| 1458 | 1493 | echo bbp_get_sanitize_val( $request, $input_type ); |
| 1459 | 1494 | } |
| 1495 | + /** | |
| 1496 | + * Return sanitized $_REQUEST value. | |
| 1497 | + * | |
| 1498 | + * Use the $input_type parameter to properly process the value. This | |
| 1499 | + * ensures correct sanitization of the value for the receiving input. | |
| 1500 | + * | |
| 1501 | + * @since 2.0.0 bbPress (r2815) | |
| 1502 | + * | |
| 1503 | + * @param string $request Name of $_REQUEST to look for | |
| 1504 | + * @param string $input_type Type of input. Default: text. Accepts: | |
| 1505 | + * textarea|password|select|radio|checkbox | |
| 1506 | + * | |
| 1507 | + * @return string Sanitized value ready for screen display | |
| 1508 | + */ | |
| 1509 | + function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) { | |
| 1460 | 1510 | |
| 1461 | -/** | |
| 1462 | - * Return sanitized $_REQUEST value. | |
| 1463 | - * | |
| 1464 | - * Use the $input_type parameter to properly process the value. This | |
| 1465 | - * ensures correct sanitization of the value for the receiving input. | |
| 1466 | - * | |
| 1467 | - * @since 2.0.0 bbPress (r2815) | |
| 1468 | - * | |
| 1469 | - * @param string $request Name of $_REQUEST to look for | |
| 1470 | - * @param string $input_type Type of input. Default: text. Accepts: | |
| 1471 | - * textarea|password|select|radio|checkbox | |
| 1472 | - * | |
| 1473 | - * @return string Sanitized value ready for screen display. | |
| 1474 | - */ | |
| 1475 | -function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) { | |
| 1511 | + // Check that requested | |
| 1512 | + if ( empty( $_REQUEST[ $request ] ) ) { | |
| 1513 | + return false; | |
| 1514 | + } | |
| 1476 | 1515 | |
| 1477 | - // Check that requested | |
| 1478 | - if ( empty( $_REQUEST[ $request ] ) ) { | |
| 1479 | - return false; | |
| 1480 | - } | |
| 1516 | + // Set request varaible | |
| 1517 | + $pre_ret_val = $_REQUEST[ $request ]; | |
| 1481 | 1518 | |
| 1482 | - // Set request varaible | |
| 1483 | - $pre_ret_val = $_REQUEST[ $request ]; | |
| 1519 | + // Treat different kinds of fields in different ways | |
| 1520 | + switch ( $input_type ) { | |
| 1521 | + case 'text' : | |
| 1522 | + case 'textarea' : | |
| 1523 | + $retval = esc_attr( wp_unslash( $pre_ret_val ) ); | |
| 1524 | + break; | |
| 1484 | 1525 | |
| 1485 | - // Treat different kinds of fields in different ways | |
| 1486 | - switch ( $input_type ) { | |
| 1487 | - case 'text': | |
| 1488 | - case 'textarea': | |
| 1489 | - $retval = esc_attr(wp_unslash( $pre_ret_val ) ); | |
| 1490 | - break; | |
| 1526 | + case 'password' : | |
| 1527 | + case 'select' : | |
| 1528 | + case 'radio' : | |
| 1529 | + case 'checkbox' : | |
| 1530 | + default : | |
| 1531 | + $retval = esc_attr( $pre_ret_val ); | |
| 1532 | + break; | |
| 1533 | + } | |
| 1491 | 1534 | |
| 1492 | - case 'password': | |
| 1493 | - case 'select': | |
| 1494 | - case 'radio': | |
| 1495 | - case 'checkbox': | |
| 1496 | - default: | |
| 1497 | - $retval = esc_attr( $pre_ret_val ); | |
| 1498 | - break; | |
| 1535 | + // Filter & return | |
| 1536 | + return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type ); | |
| 1499 | 1537 | } |
| 1500 | 1538 | |
| 1501 | - // Filter & return | |
| 1502 | - return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type ); | |
| 1503 | -} | |
| 1504 | - | |
| 1505 | 1539 | /** |
| 1506 | - * Output the current tab index of a given form. | |
| 1540 | + * Output the current tab index of a given form | |
| 1507 | 1541 | * |
| 1508 | 1542 | * Use this function to handle the tab indexing of user facing forms within a |
| 1509 | 1543 | * template file. Calling this function will automatically increment the global |
| 1510 | 1544 | * tab index by default. |
| @@ -1509,45 +1543,46 @@ | ||
| 1509 | 1543 | * template file. Calling this function will automatically increment the global |
| 1510 | 1544 | * tab index by default. |
| 1511 | 1545 | * |
| 1512 | 1546 | * @since 2.0.0 bbPress (r2810) |
| 1547 | + * | |
| 1513 | 1548 | * @deprecated 2.6.0 bbPress (r5561) |
| 1514 | - * @see https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket | |
| 1515 | 1549 | * |
| 1550 | + * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket | |
| 1516 | 1551 | * @param int $auto_increment Optional. Default true. Set to false to prevent |
| 1517 | - * increment. | |
| 1552 | + * increment | |
| 1518 | 1553 | */ |
| 1519 | 1554 | function bbp_tab_index( $auto_increment = true ) { |
| 1520 | 1555 | echo bbp_get_tab_index( $auto_increment ); |
| 1521 | 1556 | } |
| 1522 | 1557 | |
| 1523 | -/** | |
| 1524 | - * Return the current tab index of a given form. | |
| 1525 | - * | |
| 1526 | - * Use this function to handle the tab indexing of user facing forms | |
| 1527 | - * within a template file. Calling this function will automatically | |
| 1528 | - * increment the global tab index by default. | |
| 1529 | - * | |
| 1530 | - * @since 2.0.0 bbPress (r2810) | |
| 1531 | - * @deprecated 2.6.0 bbPress (r5561) | |
| 1532 | - * @see https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket | |
| 1533 | - * | |
| 1534 | - * @param int $auto_increment Optional. Default true. Set to false to | |
| 1535 | - * prevent the increment. | |
| 1536 | - * | |
| 1537 | - * @return int $bbp->tab_index The global tab index. | |
| 1538 | - */ | |
| 1539 | -function bbp_get_tab_index( $auto_increment = true ) { | |
| 1540 | - $bbp = bbpress(); | |
| 1558 | + /** | |
| 1559 | + * Return the current tab index of a given form | |
| 1560 | + * | |
| 1561 | + * Use this function to handle the tab indexing of user facing forms | |
| 1562 | + * within a template file. Calling this function will automatically | |
| 1563 | + * increment the global tab index by default. | |
| 1564 | + * | |
| 1565 | + * @since 2.0.0 bbPress (r2810) | |
| 1566 | + * | |
| 1567 | + * @deprecated 2.6.0 bbPress (r5561) | |
| 1568 | + * | |
| 1569 | + * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket | |
| 1570 | + * @param int $auto_increment Optional. Default true. Set to false to | |
| 1571 | + * prevent the increment | |
| 1572 | + * @return int $bbp->tab_index The global tab index | |
| 1573 | + */ | |
| 1574 | + function bbp_get_tab_index( $auto_increment = true ) { | |
| 1575 | + $bbp = bbpress(); | |
| 1541 | 1576 | |
| 1542 | - if ( true === $auto_increment ) { | |
| 1543 | - ++$bbp->tab_index; | |
| 1577 | + if ( true === $auto_increment ) { | |
| 1578 | + ++$bbp->tab_index; | |
| 1579 | + } | |
| 1580 | + | |
| 1581 | + // Filter & return | |
| 1582 | + return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index ); | |
| 1544 | 1583 | } |
| 1545 | 1584 | |
| 1546 | - // Filter & return | |
| 1547 | - return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index ); | |
| 1548 | -} | |
| 1549 | - | |
| 1550 | 1585 | /** |
| 1551 | 1586 | * Output a "tabindex" attribute for an element, if an index was passed. |
| 1552 | 1587 | * |
| 1553 | 1588 | * This helper function is in use, but it is generally considered impolite to |
| @@ -1556,38 +1591,38 @@ | ||
| 1556 | 1591 | * Most internal usages pass `false` which results in no attribute being used. |
| 1557 | 1592 | * |
| 1558 | 1593 | * @since 2.6.0 bbPress (r6433) |
| 1559 | 1594 | * |
| 1560 | - * @param mixed $tab False to skip, any integer to use. | |
| 1595 | + * @param mixed $tab False to skip, any integer to use | |
| 1561 | 1596 | */ |
| 1562 | 1597 | function bbp_tab_index_attribute( $tab = false ) { |
| 1563 | 1598 | echo bbp_get_tab_index_attribute( $tab ); |
| 1564 | 1599 | } |
| 1565 | 1600 | |
| 1566 | -/** | |
| 1567 | - * Return a "tabindex" attribute for an element, if an index was passed. | |
| 1568 | - * | |
| 1569 | - * This helper function is in use, but it is generally considered impolite to | |
| 1570 | - * override the "tabindex" attribute beyond what the browser naturally assigns. | |
| 1571 | - * | |
| 1572 | - * Most internal usages pass `false` which results in no attribute being used. | |
| 1573 | - * | |
| 1574 | - * @since 2.6.0 bbPress (r6433) | |
| 1575 | - * | |
| 1576 | - * @param mixed $tab False to skip, any integer to use. | |
| 1577 | - * | |
| 1578 | - * @return string | |
| 1579 | - */ | |
| 1580 | -function bbp_get_tab_index_attribute( $tab = false ) { | |
| 1601 | + /** | |
| 1602 | + * Return a "tabindex" attribute for an element, if an index was passed. | |
| 1603 | + * | |
| 1604 | + * This helper function is in use, but it is generally considered impolite to | |
| 1605 | + * override the "tabindex" attribute beyond what the browser naturally assigns. | |
| 1606 | + * | |
| 1607 | + * Most internal usages pass `false` which results in no attribute being used. | |
| 1608 | + * | |
| 1609 | + * @since 2.6.0 bbPress (r6433) | |
| 1610 | + * | |
| 1611 | + * @param mixed $tab False to skip, any integer to use | |
| 1612 | + * | |
| 1613 | + * @return string | |
| 1614 | + */ | |
| 1615 | + function bbp_get_tab_index_attribute( $tab = false ) { | |
| 1581 | 1616 | |
| 1582 | - // Get attribute | |
| 1583 | - $attr = is_numeric( $tab ) | |
| 1584 | - ? ' tabindex="' . (int) $tab . '"' | |
| 1585 | - : ''; | |
| 1617 | + // Get attribute | |
| 1618 | + $attr = is_numeric( $tab ) | |
| 1619 | + ? ' tabindex="' . (int) $tab . '"' | |
| 1620 | + : ''; | |
| 1586 | 1621 | |
| 1587 | - // Filter & return | |
| 1588 | - return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab ); | |
| 1589 | -} | |
| 1622 | + // Filter & return | |
| 1623 | + return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab ); | |
| 1624 | + } | |
| 1590 | 1625 | |
| 1591 | 1626 | /** |
| 1592 | 1627 | * Output a select box allowing to pick which forum/topic a new topic/reply |
| 1593 | 1628 | * belongs in. |
| @@ -1595,50 +1630,49 @@ | ||
| 1595 | 1630 | * Can be used for any post type, but is mostly used for topics and forums. |
| 1596 | 1631 | * |
| 1597 | 1632 | * @since 2.0.0 bbPress (r2746) |
| 1598 | 1633 | * |
| 1599 | - * @param array $args See {@link bbp_get_dropdown()} for arguments. | |
| 1634 | + * @param array $args See {@link bbp_get_dropdown()} for arguments | |
| 1600 | 1635 | */ |
| 1601 | 1636 | function bbp_dropdown( $args = array() ) { |
| 1602 | 1637 | echo bbp_get_dropdown( $args ); |
| 1603 | 1638 | } |
| 1604 | -/** | |
| 1605 | - * Return a select box allowing to pick which forum/topic a new | |
| 1606 | - * topic/reply belongs in. | |
| 1607 | - * | |
| 1608 | - * @since 2.0.0 bbPress (r2746) | |
| 1609 | - * | |
| 1610 | - * @param array $args The function supports these args: | |
| 1611 | - * - post_type: Post type, defaults to bbp_get_forum_post_type() ( bbp_forum) | |
| 1612 | - * - selected: Selected ID, to not have any value as selected, pass | |
| 1613 | - * anything smaller than 0 (due to the nature of select | |
| 1614 | - * box, the first value would of course be selected - | |
| 1615 | - * though you can have that as none (pass 'show_none' arg) ) | |
| 1616 | - * - orderby: Defaults to 'menu_order title' | |
| 1617 | - * - post_parent: Post parent. Defaults to 0 | |
| 1618 | - * - post_status: Which all post_statuses to find in? Can be an array | |
| 1619 | - * or CSV of publish, category, closed, private, spam, | |
| 1620 | - * trash (based on post type ) - if not set, these are | |
| 1621 | - * automatically determined based on the post_type | |
| 1622 | - * - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get | |
| 1623 | - * all posts | |
| 1624 | - * - walker: Which walker to use? Defaults to | |
| 1625 | - * {@link BBP_Walker_Dropdown} | |
| 1626 | - * - select_id: ID of the select box. Defaults to 'bbp_forum_id' | |
| 1627 | - * - tab: Deprecated. Tabindex value. False or integer | |
| 1628 | - * - options_only: Show only <options>? No <select>? | |
| 1629 | - * - show_none: Boolean or String __( '— No Forum —', 'bbpress' ) | |
| 1630 | - * - disable_categories: Disable forum categories and closed forums? | |
| 1631 | - * Defaults to true. Only for forums and when | |
| 1632 | - * | |
| 1633 | - * @return string The dropdown | |
| 1634 | - */ | |
| 1639 | + /** | |
| 1640 | + * Return a select box allowing to pick which forum/topic a new | |
| 1641 | + * topic/reply belongs in. | |
| 1642 | + * | |
| 1643 | + * @since 2.0.0 bbPress (r2746) | |
| 1644 | + * | |
| 1645 | + * @param array $args The function supports these args: | |
| 1646 | + * - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum) | |
| 1647 | + * - selected: Selected ID, to not have any value as selected, pass | |
| 1648 | + * anything smaller than 0 (due to the nature of select | |
| 1649 | + * box, the first value would of course be selected - | |
| 1650 | + * though you can have that as none (pass 'show_none' arg)) | |
| 1651 | + * - orderby: Defaults to 'menu_order title' | |
| 1652 | + * - post_parent: Post parent. Defaults to 0 | |
| 1653 | + * - post_status: Which all post_statuses to find in? Can be an array | |
| 1654 | + * or CSV of publish, category, closed, private, spam, | |
| 1655 | + * trash (based on post type) - if not set, these are | |
| 1656 | + * automatically determined based on the post_type | |
| 1657 | + * - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get | |
| 1658 | + * all posts | |
| 1659 | + * - walker: Which walker to use? Defaults to | |
| 1660 | + * {@link BBP_Walker_Dropdown} | |
| 1661 | + * - select_id: ID of the select box. Defaults to 'bbp_forum_id' | |
| 1662 | + * - tab: Deprecated. Tabindex value. False or integer | |
| 1663 | + * - options_only: Show only <options>? No <select>? | |
| 1664 | + * - show_none: Boolean or String __( '— No Forum —', 'bbpress' ) | |
| 1665 | + * - disable_categories: Disable forum categories and closed forums? | |
| 1666 | + * Defaults to true. Only for forums and when | |
| 1667 | + * @return string The dropdown | |
| 1668 | + */ | |
| 1635 | 1669 | function bbp_get_dropdown( $args = array() ) { |
| 1636 | 1670 | |
| 1637 | 1671 | // Setup return value |
| 1638 | 1672 | $retval = ''; |
| 1639 | 1673 | |
| 1640 | - /** Arguments *************************************************************/ | |
| 1674 | + /** Arguments *********************************************************/ | |
| 1641 | 1675 | |
| 1642 | 1676 | // Parse arguments against default values |
| 1643 | 1677 | $r = bbp_parse_args( |
| 1644 | 1678 | $args, |
| @@ -1667,9 +1701,9 @@ | ||
| 1667 | 1701 | 'tab' => false, |
| 1668 | 1702 | 'options_only' => false, |
| 1669 | 1703 | 'show_none' => false, |
| 1670 | 1704 | 'disable_categories' => true, |
| 1671 | - 'disabled' => '', | |
| 1705 | + 'disabled' => '' | |
| 1672 | 1706 | ), |
| 1673 | 1707 | 'get_dropdown' |
| 1674 | 1708 | ); |
| 1675 | 1709 | |
| @@ -1693,15 +1727,15 @@ | ||
| 1693 | 1727 | if ( ! empty( $r['exclude'] ) && ! is_array( $r['exclude'] ) ) { |
| 1694 | 1728 | $r['exclude'] = explode( ',', $r['exclude'] ); |
| 1695 | 1729 | } |
| 1696 | 1730 | |
| 1697 | - /* Setup Posts ************************************************************/ | |
| 1731 | + /** Setup Posts *******************************************************/ | |
| 1698 | 1732 | |
| 1699 | - /* | |
| 1700 | - * Allow passing of custom posts data | |
| 1701 | - * | |
| 1702 | - * @see bbp_get_reply_to_dropdown() as an example | |
| 1703 | - */ | |
| 1733 | + /** | |
| 1734 | + * Allow passing of custom posts data | |
| 1735 | + * | |
| 1736 | + * @see bbp_get_reply_to_dropdown() as an example | |
| 1737 | + */ | |
| 1704 | 1738 | if ( empty( $r['posts'] ) ) { |
| 1705 | 1739 | $r['posts'] = get_posts( |
| 1706 | 1740 | array( |
| 1707 | 1741 | 'post_type' => $r['post_type'], |
| @@ -1715,9 +1749,9 @@ | ||
| 1715 | 1749 | ) |
| 1716 | 1750 | ); |
| 1717 | 1751 | } |
| 1718 | 1752 | |
| 1719 | - /* Drop Down **************************************************************/ | |
| 1753 | + /** Drop Down *********************************************************/ | |
| 1720 | 1754 | |
| 1721 | 1755 | // Build the opening tag for the select element |
| 1722 | 1756 | if ( empty( $r['options_only'] ) ) { |
| 1723 | 1757 | |
| @@ -1787,111 +1821,121 @@ | ||
| 1787 | 1821 | return apply_filters( 'bbp_get_dropdown', $retval, $r, $args ); |
| 1788 | 1822 | } |
| 1789 | 1823 | |
| 1790 | 1824 | /** |
| 1791 | - * Output the required hidden fields when creating/editing a forum. | |
| 1825 | + * Output the required hidden fields when creating/editing a forum | |
| 1792 | 1826 | * |
| 1793 | 1827 | * @since 2.1.0 bbPress (r3553) |
| 1794 | 1828 | */ |
| 1795 | 1829 | function bbp_forum_form_fields() { |
| 1796 | - if ( bbp_is_forum_edit() ) { ?> | |
| 1797 | 1830 | |
| 1831 | + if ( bbp_is_forum_edit() ) : ?> | |
| 1832 | + | |
| 1798 | 1833 | <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-forum" /> |
| 1799 | 1834 | <input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="<?php bbp_forum_id(); ?>" /> |
| 1800 | 1835 | |
| 1801 | - <?php if ( current_user_can( 'unfiltered_html' ) ) { | |
| 1836 | + <?php if ( current_user_can( 'unfiltered_html' ) ) : | |
| 1802 | 1837 | wp_nonce_field( 'bbp-unfiltered-html-forum_' . bbp_get_forum_id(), '_bbp_unfiltered_html_forum', false ); |
| 1803 | - } ?> | |
| 1838 | + endif; ?> | |
| 1804 | 1839 | |
| 1805 | 1840 | <?php wp_nonce_field( 'bbp-edit-forum_' . bbp_get_forum_id() ); |
| 1806 | - } else { | |
| 1807 | - if ( bbp_is_single_forum() ) { ?> | |
| 1808 | 1841 | |
| 1842 | + else : | |
| 1843 | + | |
| 1844 | + if ( bbp_is_single_forum() ) : ?> | |
| 1845 | + | |
| 1809 | 1846 | <input type="hidden" name="bbp_forum_parent_id" id="bbp_forum_parent_id" value="<?php bbp_forum_parent_id(); ?>" /> |
| 1810 | 1847 | |
| 1811 | - <?php } ?> | |
| 1848 | + <?php endif; ?> | |
| 1812 | 1849 | |
| 1813 | 1850 | <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-forum" /> |
| 1814 | 1851 | |
| 1815 | - <?php if ( current_user_can( 'unfiltered_html' ) ) { | |
| 1852 | + <?php if ( current_user_can( 'unfiltered_html' ) ) : | |
| 1816 | 1853 | wp_nonce_field( 'bbp-unfiltered-html-forum_new', '_bbp_unfiltered_html_forum', false ); |
| 1817 | - } ?> | |
| 1854 | + endif; ?> | |
| 1818 | 1855 | |
| 1819 | 1856 | <?php wp_nonce_field( 'bbp-new-forum' ); |
| 1820 | - } | |
| 1857 | + | |
| 1858 | + endif; | |
| 1821 | 1859 | } |
| 1822 | 1860 | |
| 1823 | 1861 | /** |
| 1824 | - * Output the required hidden fields when creating/editing a topic. | |
| 1862 | + * Output the required hidden fields when creating/editing a topic | |
| 1825 | 1863 | * |
| 1826 | 1864 | * @since 2.0.0 bbPress (r2753) |
| 1827 | 1865 | */ |
| 1828 | 1866 | function bbp_topic_form_fields() { |
| 1829 | - if ( bbp_is_topic_edit() ) { ?> | |
| 1830 | 1867 | |
| 1868 | + if ( bbp_is_topic_edit() ) : ?> | |
| 1869 | + | |
| 1831 | 1870 | <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-topic" /> |
| 1832 | 1871 | <input type="hidden" name="bbp_topic_id" id="bbp_topic_id" value="<?php bbp_topic_id(); ?>" /> |
| 1833 | 1872 | |
| 1834 | - <?php if ( current_user_can( 'unfiltered_html' ) ) { | |
| 1873 | + <?php if ( current_user_can( 'unfiltered_html' ) ) : | |
| 1835 | 1874 | wp_nonce_field( 'bbp-unfiltered-html-topic_' . bbp_get_topic_id(), '_bbp_unfiltered_html_topic', false ); |
| 1836 | - } ?> | |
| 1875 | + endif; ?> | |
| 1837 | 1876 | |
| 1838 | 1877 | <?php wp_nonce_field( 'bbp-edit-topic_' . bbp_get_topic_id() ); |
| 1839 | - } else { | |
| 1840 | - if ( bbp_is_single_forum() ) { ?> | |
| 1841 | 1878 | |
| 1879 | + else : | |
| 1880 | + | |
| 1881 | + if ( bbp_is_single_forum() ) : ?> | |
| 1882 | + | |
| 1842 | 1883 | <input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="<?php bbp_forum_id(); ?>" /> |
| 1843 | 1884 | |
| 1844 | - <?php } ?> | |
| 1885 | + <?php endif; ?> | |
| 1845 | 1886 | |
| 1846 | 1887 | <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-topic" /> |
| 1847 | 1888 | |
| 1848 | - <?php if ( current_user_can( 'unfiltered_html' ) ) { | |
| 1889 | + <?php if ( current_user_can( 'unfiltered_html' ) ) : | |
| 1849 | 1890 | wp_nonce_field( 'bbp-unfiltered-html-topic_new', '_bbp_unfiltered_html_topic', false ); |
| 1850 | - } ?> | |
| 1891 | + endif; ?> | |
| 1851 | 1892 | |
| 1852 | 1893 | <?php wp_nonce_field( 'bbp-new-topic' ); |
| 1853 | - } | |
| 1894 | + | |
| 1895 | + endif; | |
| 1854 | 1896 | } |
| 1855 | 1897 | |
| 1856 | 1898 | /** |
| 1857 | - * Output the required hidden fields when creating/editing a reply. | |
| 1899 | + * Output the required hidden fields when creating/editing a reply | |
| 1858 | 1900 | * |
| 1859 | 1901 | * @since 2.0.0 bbPress (r2753) |
| 1860 | 1902 | */ |
| 1861 | 1903 | function bbp_reply_form_fields() { |
| 1862 | - if ( bbp_is_reply_edit() ) { ?> | |
| 1863 | 1904 | |
| 1905 | + if ( bbp_is_reply_edit() ) : ?> | |
| 1906 | + | |
| 1864 | 1907 | <input type="hidden" name="bbp_reply_id" id="bbp_reply_id" value="<?php bbp_reply_id(); ?>" /> |
| 1865 | 1908 | <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-reply" /> |
| 1866 | 1909 | |
| 1867 | - <?php if ( current_user_can( 'unfiltered_html' ) ) { | |
| 1910 | + <?php if ( current_user_can( 'unfiltered_html' ) ) : | |
| 1868 | 1911 | wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_reply_id(), '_bbp_unfiltered_html_reply', false ); |
| 1869 | - } ?> | |
| 1912 | + endif; ?> | |
| 1870 | 1913 | |
| 1871 | 1914 | <?php wp_nonce_field( 'bbp-edit-reply_' . bbp_get_reply_id() ); |
| 1872 | - } else { ?> | |
| 1873 | 1915 | |
| 1916 | + else : ?> | |
| 1917 | + | |
| 1874 | 1918 | <input type="hidden" name="bbp_topic_id" id="bbp_topic_id" value="<?php bbp_topic_id(); ?>" /> |
| 1875 | 1919 | <input type="hidden" name="bbp_reply_to" id="bbp_reply_to" value="<?php bbp_form_reply_to(); ?>" /> |
| 1876 | 1920 | <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-reply" /> |
| 1877 | 1921 | |
| 1878 | - <?php if ( current_user_can( 'unfiltered_html' ) ) { | |
| 1922 | + <?php if ( current_user_can( 'unfiltered_html' ) ) : | |
| 1879 | 1923 | wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_topic_id(), '_bbp_unfiltered_html_reply', false ); |
| 1880 | - } ?> | |
| 1924 | + endif; ?> | |
| 1881 | 1925 | |
| 1882 | 1926 | <?php wp_nonce_field( 'bbp-new-reply' ); |
| 1883 | 1927 | |
| 1884 | 1928 | // Show redirect field if not viewing a specific topic |
| 1885 | - if ( bbp_is_query_name( 'bbp_single_topic' ) ) { | |
| 1929 | + if ( bbp_is_query_name( 'bbp_single_topic' ) ) : | |
| 1886 | 1930 | $redirect_to = apply_filters( 'bbp_reply_form_redirect_to', get_permalink() ); |
| 1887 | 1931 | bbp_redirect_to_field( $redirect_to ); |
| 1888 | - } | |
| 1889 | - } | |
| 1932 | + endif; | |
| 1933 | + endif; | |
| 1890 | 1934 | } |
| 1891 | 1935 | |
| 1892 | 1936 | /** |
| 1893 | - * Output the required hidden fields when editing a user. | |
| 1937 | + * Output the required hidden fields when editing a user | |
| 1894 | 1938 | * |
| 1895 | 1939 | * @since 2.0.0 bbPress (r2690) |
| 1896 | 1940 | */ |
| 1897 | 1941 | function bbp_edit_user_form_fields() { |
| @@ -1903,11 +1947,11 @@ | ||
| 1903 | 1947 | <?php wp_nonce_field( 'update-user_' . bbp_get_displayed_user_id() ); |
| 1904 | 1948 | } |
| 1905 | 1949 | |
| 1906 | 1950 | /** |
| 1907 | - * Merge topic form fields. | |
| 1951 | + * Merge topic form fields | |
| 1908 | 1952 | * |
| 1909 | - * Output the required hidden fields when merging a topic. | |
| 1953 | + * Output the required hidden fields when merging a topic | |
| 1910 | 1954 | * |
| 1911 | 1955 | * @since 2.0.0 bbPress (r2756) |
| 1912 | 1956 | */ |
| 1913 | 1957 | function bbp_merge_topic_form_fields() { |
| @@ -1919,11 +1963,11 @@ | ||
| 1919 | 1963 | <?php wp_nonce_field( 'bbp-merge-topic_' . bbp_get_topic_id() ); |
| 1920 | 1964 | } |
| 1921 | 1965 | |
| 1922 | 1966 | /** |
| 1923 | - * Split topic form fields. | |
| 1967 | + * Split topic form fields | |
| 1924 | 1968 | * |
| 1925 | - * Output the required hidden fields when splitting a topic. | |
| 1969 | + * Output the required hidden fields when splitting a topic | |
| 1926 | 1970 | * |
| 1927 | 1971 | * @since 2.0.0 bbPress (r2756) |
| 1928 | 1972 | */ |
| 1929 | 1973 | function bbp_split_topic_form_fields() { |
| @@ -1935,13 +1979,11 @@ | ||
| 1935 | 1979 | <?php wp_nonce_field( 'bbp-split-topic_' . bbp_get_topic_id() ); |
| 1936 | 1980 | } |
| 1937 | 1981 | |
| 1938 | 1982 | /** |
| 1939 | - * Move reply form fields. | |
| 1983 | + * Move reply form fields | |
| 1940 | 1984 | * |
| 1941 | - * Output the required hidden fields when moving a reply. | |
| 1942 | - * | |
| 1943 | - * @since 2.3.0 bbPress (r4522) | |
| 1985 | + * Output the required hidden fields when moving a reply | |
| 1944 | 1986 | */ |
| 1945 | 1987 | function bbp_move_reply_form_fields() { |
| 1946 | 1988 | ?> |
| 1947 | 1989 | |
| @@ -1951,9 +1993,9 @@ | ||
| 1951 | 1993 | <?php wp_nonce_field( 'bbp-move-reply_' . bbp_get_reply_id() ); |
| 1952 | 1994 | } |
| 1953 | 1995 | |
| 1954 | 1996 | /** |
| 1955 | - * Output a textarea or TinyMCE if enabled. | |
| 1997 | + * Output a textarea or TinyMCE if enabled | |
| 1956 | 1998 | * |
| 1957 | 1999 | * @since 2.1.0 bbPress (r3586) |
| 1958 | 2000 | * |
| 1959 | 2001 | * @param array $args |
| @@ -1960,18 +2002,17 @@ | ||
| 1960 | 2002 | */ |
| 1961 | 2003 | function bbp_the_content( $args = array() ) { |
| 1962 | 2004 | echo bbp_get_the_content( $args ); |
| 1963 | 2005 | } |
| 1964 | - | |
| 1965 | -/** | |
| 1966 | - * Return a textarea or TinyMCE if enabled. | |
| 1967 | - * | |
| 1968 | - * @since 2.1.0 bbPress (r3586) | |
| 1969 | - * | |
| 1970 | - * @param array $args | |
| 1971 | - * | |
| 1972 | - * @return string HTML from output buffer | |
| 1973 | - */ | |
| 2006 | + /** | |
| 2007 | + * Return a textarea or TinyMCE if enabled | |
| 2008 | + * | |
| 2009 | + * @since 2.1.0 bbPress (r3586) | |
| 2010 | + * | |
| 2011 | + * @param array $args | |
| 2012 | + * | |
| 2013 | + * @return string HTML from output buffer | |
| 2014 | + */ | |
| 1974 | 2015 | function bbp_get_the_content( $args = array() ) { |
| 1975 | 2016 | |
| 1976 | 2017 | // Parse arguments against default values |
| 1977 | 2018 | $r = bbp_parse_args( |
| @@ -1988,9 +2029,9 @@ | ||
| 1988 | 2029 | 'editor_class' => 'bbp-the-content', |
| 1989 | 2030 | 'tinymce' => false, |
| 1990 | 2031 | 'teeny' => true, |
| 1991 | 2032 | 'quicktags' => true, |
| 1992 | - 'dfw' => false, | |
| 2033 | + 'dfw' => false | |
| 1993 | 2034 | ), |
| 1994 | 2035 | 'get_the_content' |
| 1995 | 2036 | ); |
| 1996 | 2037 | |
| @@ -2012,9 +2053,9 @@ | ||
| 2012 | 2053 | echo $r['before']; |
| 2013 | 2054 | } |
| 2014 | 2055 | |
| 2015 | 2056 | // Use TinyMCE if available |
| 2016 | - if ( bbp_use_wp_editor() ) { | |
| 2057 | + if ( bbp_use_wp_editor() ) : | |
| 2017 | 2058 | |
| 2018 | 2059 | // Enable additional TinyMCE plugins before outputting the editor |
| 2019 | 2060 | add_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); |
| 2020 | 2061 | add_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); |
| @@ -2044,41 +2085,39 @@ | ||
| 2044 | 2085 | remove_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); |
| 2045 | 2086 | remove_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' ); |
| 2046 | 2087 | remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' ); |
| 2047 | 2088 | |
| 2048 | - /* | |
| 2049 | - * Fallback to normal textarea. | |
| 2050 | - * | |
| 2051 | - * Note that we do not use esc_textarea() here to prevent double | |
| 2052 | - * escaping the editable output, mucking up existing content. | |
| 2053 | - */ | |
| 2054 | - } else { ?> | |
| 2089 | + /** | |
| 2090 | + * Fallback to normal textarea. | |
| 2091 | + * | |
| 2092 | + * Note that we do not use esc_textarea() here to prevent double | |
| 2093 | + * escaping the editable output, mucking up existing content. | |
| 2094 | + */ | |
| 2095 | + else : ?> | |
| 2055 | 2096 | |
| 2056 | - <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> | |
| 2097 | + <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> | |
| 2057 | 2098 | |
| 2058 | - <?php } | |
| 2099 | + <?php endif; | |
| 2059 | 2100 | |
| 2060 | - // Output something after the editor | |
| 2061 | - if ( ! empty( $r['after'] ) ) { | |
| 2062 | - echo $r['after']; | |
| 2063 | - } | |
| 2101 | + // Output something after the editor | |
| 2102 | + if ( ! empty( $r['after'] ) ) { | |
| 2103 | + echo $r['after']; | |
| 2104 | + } | |
| 2064 | 2105 | |
| 2065 | - // Put the output into a usable variable | |
| 2066 | - $output = ob_get_clean(); | |
| 2106 | + // Put the output into a usable variable | |
| 2107 | + $output = ob_get_clean(); | |
| 2067 | 2108 | |
| 2068 | - // Filter & return | |
| 2069 | - return apply_filters( 'bbp_get_the_content', $output, $args, $post_content ); | |
| 2070 | -} | |
| 2109 | + // Filter & return | |
| 2110 | + return apply_filters( 'bbp_get_the_content', $output, $args, $post_content ); | |
| 2111 | + } | |
| 2071 | 2112 | |
| 2072 | 2113 | /** |
| 2073 | - * Edit TinyMCE plugins to match core behaviour. | |
| 2114 | + * Edit TinyMCE plugins to match core behaviour | |
| 2074 | 2115 | * |
| 2075 | 2116 | * @since 2.3.0 bbPress (r4576) |
| 2076 | 2117 | * |
| 2077 | 2118 | * @param array $plugins |
| 2078 | - * | |
| 2079 | 2119 | * @see tiny_mce_plugins, teeny_mce_plugins |
| 2080 | - * | |
| 2081 | 2120 | * @return array |
| 2082 | 2121 | */ |
| 2083 | 2122 | function bbp_get_tiny_mce_plugins( $plugins = array() ) { |
| 2084 | 2123 | |
| @@ -2097,16 +2136,14 @@ | ||
| 2097 | 2136 | return apply_filters( 'bbp_get_tiny_mce_plugins', $plugins ); |
| 2098 | 2137 | } |
| 2099 | 2138 | |
| 2100 | 2139 | /** |
| 2101 | - * Edit TeenyMCE buttons to match allowedtags. | |
| 2140 | + * Edit TeenyMCE buttons to match allowedtags | |
| 2102 | 2141 | * |
| 2103 | 2142 | * @since 2.3.0 bbPress (r4606) |
| 2104 | 2143 | * |
| 2105 | 2144 | * @param array $buttons |
| 2106 | - * | |
| 2107 | 2145 | * @see teeny_mce_buttons |
| 2108 | - * | |
| 2109 | 2146 | * @return array |
| 2110 | 2147 | */ |
| 2111 | 2148 | function bbp_get_teeny_mce_buttons( $buttons = array() ) { |
| 2112 | 2149 | |
| @@ -2116,9 +2153,9 @@ | ||
| 2116 | 2153 | array( |
| 2117 | 2154 | 'underline', |
| 2118 | 2155 | 'justifyleft', |
| 2119 | 2156 | 'justifycenter', |
| 2120 | - 'justifyright', | |
| 2157 | + 'justifyright' | |
| 2121 | 2158 | ) |
| 2122 | 2159 | ); |
| 2123 | 2160 | |
| 2124 | 2161 | // Images |
| @@ -2128,16 +2165,14 @@ | ||
| 2128 | 2165 | return apply_filters( 'bbp_get_teeny_mce_buttons', $buttons ); |
| 2129 | 2166 | } |
| 2130 | 2167 | |
| 2131 | 2168 | /** |
| 2132 | - * Edit TinyMCE quicktags buttons to match allowedtags. | |
| 2169 | + * Edit TinyMCE quicktags buttons to match allowedtags | |
| 2133 | 2170 | * |
| 2134 | 2171 | * @since 2.3.0 bbPress (r4607) |
| 2135 | 2172 | * |
| 2136 | 2173 | * @param array $settings |
| 2137 | - * | |
| 2138 | 2174 | * @see quicktags_settings |
| 2139 | - * | |
| 2140 | 2175 | * @return array Quicktags settings |
| 2141 | 2176 | */ |
| 2142 | 2177 | function bbp_get_quicktags_settings( $settings = array() ) { |
| 2143 | 2178 | |
| @@ -2149,9 +2184,9 @@ | ||
| 2149 | 2184 | $buttons_array, |
| 2150 | 2185 | array( |
| 2151 | 2186 | 'ins', |
| 2152 | 2187 | 'more', |
| 2153 | - 'spell', | |
| 2188 | + 'spell' | |
| 2154 | 2189 | ) |
| 2155 | 2190 | ); |
| 2156 | 2191 | |
| 2157 | 2192 | // Put them back into a string in the $settings array |
| @@ -2163,102 +2198,100 @@ | ||
| 2163 | 2198 | |
| 2164 | 2199 | /** Views *********************************************************************/ |
| 2165 | 2200 | |
| 2166 | 2201 | /** |
| 2167 | - * Output the view id. | |
| 2202 | + * Output the view id | |
| 2168 | 2203 | * |
| 2169 | 2204 | * @since 2.0.0 bbPress (r2789) |
| 2170 | 2205 | * |
| 2171 | - * @param string $view Optional. View id. | |
| 2206 | + * @param string $view Optional. View id | |
| 2172 | 2207 | */ |
| 2173 | 2208 | function bbp_view_id( $view = '' ) { |
| 2174 | 2209 | echo bbp_get_view_id( $view ); |
| 2175 | 2210 | } |
| 2176 | 2211 | |
| 2177 | -/** | |
| 2178 | - * Get the view id. | |
| 2179 | - * | |
| 2180 | - * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var. | |
| 2181 | - * | |
| 2182 | - * @since 2.0.0 bbPress (r2789) | |
| 2183 | - * | |
| 2184 | - * @param string $view Optional. View id. | |
| 2185 | - * | |
| 2186 | - * @return bool|string ID on success, false on failure. | |
| 2187 | - */ | |
| 2188 | -function bbp_get_view_id( $view = '' ) { | |
| 2189 | - $bbp = bbpress(); | |
| 2212 | + /** | |
| 2213 | + * Get the view id | |
| 2214 | + * | |
| 2215 | + * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var. | |
| 2216 | + * | |
| 2217 | + * @since 2.0.0 bbPress (r2789) | |
| 2218 | + * | |
| 2219 | + * @param string $view Optional. View id. | |
| 2220 | + * @return bool|string ID on success, false on failure | |
| 2221 | + */ | |
| 2222 | + function bbp_get_view_id( $view = '' ) { | |
| 2223 | + $bbp = bbpress(); | |
| 2190 | 2224 | |
| 2191 | - // User supplied string | |
| 2192 | - if ( ! empty( $view ) && is_string( $view ) ) { | |
| 2193 | - $view_id = $view; | |
| 2225 | + // User supplied string | |
| 2226 | + if ( ! empty( $view ) && is_string( $view ) ) { | |
| 2227 | + $view_id = $view; | |
| 2194 | 2228 | |
| 2195 | - // Current view ID | |
| 2196 | - } elseif ( ! empty( $bbp->current_view_id ) ) { | |
| 2197 | - $view_id = $bbp->current_view_id; | |
| 2229 | + // Current view ID | |
| 2230 | + } elseif ( ! empty( $bbp->current_view_id ) ) { | |
| 2231 | + $view_id = $bbp->current_view_id; | |
| 2198 | 2232 | |
| 2199 | - // Querying for view | |
| 2200 | - } else { | |
| 2201 | - $view_id = get_query_var( bbp_get_view_rewrite_id() ); | |
| 2233 | + // Querying for view | |
| 2234 | + } else { | |
| 2235 | + $view_id = get_query_var( bbp_get_view_rewrite_id() ); | |
| 2236 | + } | |
| 2237 | + | |
| 2238 | + // Filter & return | |
| 2239 | + return apply_filters( 'bbp_get_view_id', $view_id, $view ); | |
| 2202 | 2240 | } |
| 2203 | 2241 | |
| 2204 | - // Filter & return | |
| 2205 | - return apply_filters( 'bbp_get_view_id', $view_id, $view ); | |
| 2206 | -} | |
| 2207 | - | |
| 2208 | 2242 | /** |
| 2209 | - * Output the view name aka title. | |
| 2243 | + * Output the view name aka title | |
| 2210 | 2244 | * |
| 2211 | 2245 | * @since 2.0.0 bbPress (r2789) |
| 2212 | 2246 | * |
| 2213 | - * @param string $view Optional. View id. | |
| 2247 | + * @param string $view Optional. View id | |
| 2214 | 2248 | */ |
| 2215 | 2249 | function bbp_view_title( $view = '' ) { |
| 2216 | 2250 | echo bbp_get_view_title( $view ); |
| 2217 | 2251 | } |
| 2218 | 2252 | |
| 2219 | -/** | |
| 2220 | - * Get the view name aka title. | |
| 2221 | - * | |
| 2222 | - * If a view id is supplied, that is used. Otherwise the bbp_view | |
| 2223 | - * query var is checked for. | |
| 2224 | - * | |
| 2225 | - * @since 2.0.0 bbPress (r2789) | |
| 2226 | - * | |
| 2227 | - * @param string $view Optional. View id. | |
| 2228 | - * | |
| 2229 | - * @return bool|string Title on success, false on failure. | |
| 2230 | - */ | |
| 2231 | -function bbp_get_view_title( $view = '' ) { | |
| 2232 | - $bbp = bbpress(); | |
| 2253 | + /** | |
| 2254 | + * Get the view name aka title | |
| 2255 | + * | |
| 2256 | + * If a view id is supplied, that is used. Otherwise the bbp_view | |
| 2257 | + * query var is checked for. | |
| 2258 | + * | |
| 2259 | + * @since 2.0.0 bbPress (r2789) | |
| 2260 | + * | |
| 2261 | + * @param string $view Optional. View id | |
| 2262 | + * @return bool|string Title on success, false on failure | |
| 2263 | + */ | |
| 2264 | + function bbp_get_view_title( $view = '' ) { | |
| 2265 | + $bbp = bbpress(); | |
| 2233 | 2266 | |
| 2234 | - $view = bbp_get_view_id( $view ); | |
| 2235 | - if ( empty( $view ) ) { | |
| 2236 | - return false; | |
| 2267 | + $view = bbp_get_view_id( $view ); | |
| 2268 | + if ( empty( $view ) ) { | |
| 2269 | + return false; | |
| 2270 | + } | |
| 2271 | + | |
| 2272 | + return $bbp->views[ $view ]['title']; | |
| 2237 | 2273 | } |
| 2238 | 2274 | |
| 2239 | - return $bbp->views[ $view ]['title']; | |
| 2240 | -} | |
| 2241 | - | |
| 2242 | 2275 | /** |
| 2243 | - * Output the view url. | |
| 2276 | + * Output the view url | |
| 2244 | 2277 | * |
| 2245 | 2278 | * @since 2.0.0 bbPress (r2789) |
| 2246 | 2279 | * |
| 2247 | - * @param string $view Optional. View id. | |
| 2280 | + * @param string $view Optional. View id | |
| 2248 | 2281 | */ |
| 2249 | 2282 | function bbp_view_url( $view = false ) { |
| 2250 | 2283 | echo esc_url( bbp_get_view_url( $view ) ); |
| 2251 | 2284 | } |
| 2252 | -/** | |
| 2253 | - * Return the view url. | |
| 2254 | - * | |
| 2255 | - * @since 2.0.0 bbPress (r2789) | |
| 2256 | - * | |
| 2257 | - * @param string $view Optional. View id. | |
| 2258 | - * | |
| 2259 | - * @return string View url (or home url if the view was not found). | |
| 2260 | - */ | |
| 2285 | + /** | |
| 2286 | + * Return the view url | |
| 2287 | + * | |
| 2288 | + * @since 2.0.0 bbPress (r2789) | |
| 2289 | + * | |
| 2290 | + * @param string $view Optional. View id | |
| 2291 | + * used view id | |
| 2292 | + * @return string View url (or home url if the view was not found) | |
| 2293 | + */ | |
| 2261 | 2294 | function bbp_get_view_url( $view = false ) { |
| 2262 | 2295 | |
| 2263 | 2296 | $view = bbp_get_view_id( $view ); |
| 2264 | 2297 | if ( empty( $view ) ) { |
| @@ -2275,9 +2308,9 @@ | ||
| 2275 | 2308 | // Unpretty permalinks |
| 2276 | 2309 | } else { |
| 2277 | 2310 | $url = add_query_arg( |
| 2278 | 2311 | array( |
| 2279 | - bbp_get_view_rewrite_id() => $view, | |
| 2312 | + bbp_get_view_rewrite_id() => $view | |
| 2280 | 2313 | ), |
| 2281 | 2314 | home_url( '/' ) |
| 2282 | 2315 | ); |
| 2283 | 2316 | } |
| @@ -2288,13 +2321,13 @@ | ||
| 2288 | 2321 | |
| 2289 | 2322 | /** Query *********************************************************************/ |
| 2290 | 2323 | |
| 2291 | 2324 | /** |
| 2292 | - * Check the passed parameter against the current _bbp_query_name. | |
| 2325 | + * Check the passed parameter against the current _bbp_query_name | |
| 2293 | 2326 | * |
| 2294 | 2327 | * @since 2.0.0 bbPress (r2980) |
| 2295 | 2328 | * |
| 2296 | - * @return bool True if match, false if not. | |
| 2329 | + * @return bool True if match, false if not | |
| 2297 | 2330 | */ |
| 2298 | 2331 | function bbp_is_query_name( $name = '' ) { |
| 2299 | 2332 | return (bool) ( bbp_get_query_name() === $name ); |
| 2300 | 2333 | } |
| @@ -2299,13 +2332,13 @@ | ||
| 2299 | 2332 | return (bool) ( bbp_get_query_name() === $name ); |
| 2300 | 2333 | } |
| 2301 | 2334 | |
| 2302 | 2335 | /** |
| 2303 | - * Get the '_bbp_query_name' setting. | |
| 2336 | + * Get the '_bbp_query_name' setting | |
| 2304 | 2337 | * |
| 2305 | 2338 | * @since 2.0.0 bbPress (r2695) |
| 2306 | 2339 | * |
| 2307 | - * @return string To return the query var value. | |
| 2340 | + * @return string To return the query var value | |
| 2308 | 2341 | */ |
| 2309 | 2342 | function bbp_get_query_name() { |
| 2310 | 2343 | return get_query_var( '_bbp_query_name' ); |
| 2311 | 2344 | } |
| @@ -2310,13 +2343,13 @@ | ||
| 2310 | 2343 | return get_query_var( '_bbp_query_name' ); |
| 2311 | 2344 | } |
| 2312 | 2345 | |
| 2313 | 2346 | /** |
| 2314 | - * Set the '_bbp_query_name' setting to $name. | |
| 2347 | + * Set the '_bbp_query_name' setting to $name | |
| 2315 | 2348 | * |
| 2316 | 2349 | * @since 2.0.0 bbPress (r2692) |
| 2317 | 2350 | * |
| 2318 | - * @param string $name What to set the query var to. | |
| 2351 | + * @param string $name What to set the query var to | |
| 2319 | 2352 | */ |
| 2320 | 2353 | function bbp_set_query_name( $name = '' ) { |
| 2321 | 2354 | set_query_var( '_bbp_query_name', $name ); |
| 2322 | 2355 | } |
| @@ -2321,11 +2354,12 @@ | ||
| 2321 | 2354 | set_query_var( '_bbp_query_name', $name ); |
| 2322 | 2355 | } |
| 2323 | 2356 | |
| 2324 | 2357 | /** |
| 2325 | - * Used to clear the '_bbp_query_name' setting. | |
| 2358 | + * Used to clear the '_bbp_query_name' setting | |
| 2326 | 2359 | * |
| 2327 | 2360 | * @since 2.0.0 bbPress (r2692) |
| 2361 | + * | |
| 2328 | 2362 | */ |
| 2329 | 2363 | function bbp_reset_query_name() { |
| 2330 | 2364 | bbp_set_query_name(); |
| 2331 | 2365 | } |
| @@ -2332,11 +2366,15 @@ | ||
| 2332 | 2366 | |
| 2333 | 2367 | /** Breadcrumbs ***************************************************************/ |
| 2334 | 2368 | |
| 2335 | 2369 | /** |
| 2336 | - * Output the page title as a breadcrumb. | |
| 2370 | + * Output the page title as a breadcrumb | |
| 2337 | 2371 | * |
| 2338 | 2372 | * @since 2.0.0 bbPress (r2583) |
| 2373 | + * | |
| 2374 | + * @param string $sep Separator. Defaults to '←' | |
| 2375 | + * @param bool $current_page Include the current item | |
| 2376 | + * @param bool $root Include the root page if one exists | |
| 2339 | 2377 | */ |
| 2340 | 2378 | function bbp_title_breadcrumb( $args = array() ) { |
| 2341 | 2379 | echo bbp_get_breadcrumb( $args ); |
| 2342 | 2380 | } |
| @@ -2341,27 +2379,30 @@ | ||
| 2341 | 2379 | echo bbp_get_breadcrumb( $args ); |
| 2342 | 2380 | } |
| 2343 | 2381 | |
| 2344 | 2382 | /** |
| 2345 | - * Output a breadcrumb. | |
| 2383 | + * Output a breadcrumb | |
| 2346 | 2384 | * |
| 2347 | 2385 | * @since 2.0.0 bbPress (r2589) |
| 2386 | + * | |
| 2387 | + * @param string $sep Separator. Defaults to '←' | |
| 2388 | + * @param bool $current_page Include the current item | |
| 2389 | + * @param bool $root Include the root page if one exists | |
| 2348 | 2390 | */ |
| 2349 | 2391 | function bbp_breadcrumb( $args = array() ) { |
| 2350 | 2392 | echo bbp_get_breadcrumb( $args ); |
| 2351 | 2393 | } |
| 2352 | - | |
| 2353 | -/** | |
| 2354 | - * Return a breadcrumb ( forum -> topic -> reply ) | |
| 2355 | - * | |
| 2356 | - * @since 2.0.0 bbPress (r2589) | |
| 2357 | - * | |
| 2358 | - * @param string $sep Separator. Defaults to '←'. | |
| 2359 | - * @param bool $current_page Include the current item. | |
| 2360 | - * @param bool $root Include the root page if one exists. | |
| 2361 | - * | |
| 2362 | - * @return string Breadcrumbs. | |
| 2363 | - */ | |
| 2394 | + /** | |
| 2395 | + * Return a breadcrumb ( forum -> topic -> reply ) | |
| 2396 | + * | |
| 2397 | + * @since 2.0.0 bbPress (r2589) | |
| 2398 | + * | |
| 2399 | + * @param string $sep Separator. Defaults to '←' | |
| 2400 | + * @param bool $current_page Include the current item | |
| 2401 | + * @param bool $root Include the root page if one exists | |
| 2402 | + * | |
| 2403 | + * @return string Breadcrumbs | |
| 2404 | + */ | |
| 2364 | 2405 | function bbp_get_breadcrumb( $args = array() ) { |
| 2365 | 2406 | |
| 2366 | 2407 | // Turn off breadcrumbs |
| 2367 | 2408 | if ( apply_filters( 'bbp_no_breadcrumb', is_front_page() ) ) { |
| @@ -2368,14 +2409,14 @@ | ||
| 2368 | 2409 | return; |
| 2369 | 2410 | } |
| 2370 | 2411 | |
| 2371 | 2412 | // Define variables |
| 2372 | - $front_id = $root_id = $remove_root_id = 0; | |
| 2413 | + $front_id = $root_id = 0; | |
| 2373 | 2414 | $ancestors = $crumbs = $tag_data = array(); |
| 2374 | 2415 | $pre_root_text = $pre_front_text = $pre_current_text = ''; |
| 2375 | 2416 | $pre_include_root = $pre_include_home = $pre_include_current = true; |
| 2376 | 2417 | |
| 2377 | - /** Home Text *************************************************************/ | |
| 2418 | + /** Home Text *********************************************************/ | |
| 2378 | 2419 | |
| 2379 | 2420 | // No custom home text |
| 2380 | 2421 | if ( empty( $args['home_text'] ) ) { |
| 2381 | 2422 | |
| @@ -2390,9 +2431,9 @@ | ||
| 2390 | 2431 | $pre_front_text = esc_html__( 'Home', 'bbpress' ); |
| 2391 | 2432 | } |
| 2392 | 2433 | } |
| 2393 | 2434 | |
| 2394 | - /** Root Text *************************************************************/ | |
| 2435 | + /** Root Text *********************************************************/ | |
| 2395 | 2436 | |
| 2396 | 2437 | // No custom root text |
| 2397 | 2438 | if ( empty( $args['root_text'] ) ) { |
| 2398 | 2439 | $page = bbp_get_page_by_path( bbp_get_root_slug() ); |
| @@ -2401,9 +2442,9 @@ | ||
| 2401 | 2442 | } |
| 2402 | 2443 | $pre_root_text = bbp_get_forum_archive_title(); |
| 2403 | 2444 | } |
| 2404 | 2445 | |
| 2405 | - /** Includes **************************************************************/ | |
| 2446 | + /** Includes **********************************************************/ | |
| 2406 | 2447 | |
| 2407 | 2448 | // Root slug is also the front page |
| 2408 | 2449 | if ( ! empty( $front_id ) && ( $front_id === $root_id ) ) { |
| 2409 | 2450 | $pre_include_root = false; |
| @@ -2418,9 +2459,9 @@ | ||
| 2418 | 2459 | if ( ! empty( $root_id ) && ( ( is_single() || is_page() ) && ( get_the_ID() === $root_id ) ) ) { |
| 2419 | 2460 | $pre_include_root = false; |
| 2420 | 2461 | } |
| 2421 | 2462 | |
| 2422 | - /** Current Text **********************************************************/ | |
| 2463 | + /** Current Text ******************************************************/ | |
| 2423 | 2464 | |
| 2424 | 2465 | // Search page |
| 2425 | 2466 | if ( bbp_is_search() ) { |
| 2426 | 2467 | $pre_current_text = bbp_get_search_title(); |
| @@ -2472,9 +2513,9 @@ | ||
| 2472 | 2513 | } else { |
| 2473 | 2514 | $pre_current_text = get_the_title(); |
| 2474 | 2515 | } |
| 2475 | 2516 | |
| 2476 | - /** Parse Args ************************************************************/ | |
| 2517 | + /** Parse Args ********************************************************/ | |
| 2477 | 2518 | |
| 2478 | 2519 | // Parse args |
| 2479 | 2520 | $r = bbp_parse_args( |
| 2480 | 2521 | $args, |
| @@ -2510,9 +2551,9 @@ | ||
| 2510 | 2551 | ), |
| 2511 | 2552 | 'get_breadcrumb' |
| 2512 | 2553 | ); |
| 2513 | 2554 | |
| 2514 | - /** Ancestors *********************************************************/ | |
| 2555 | + /** Ancestors *********************************************************/ | |
| 2515 | 2556 | |
| 2516 | 2557 | // Get post ancestors |
| 2517 | 2558 | if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() ) { |
| 2518 | 2559 | $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) ); |
| @@ -2529,9 +2570,8 @@ | ||
| 2529 | 2570 | // Page exists at root slug path, so use its permalink |
| 2530 | 2571 | $page = bbp_get_page_by_path( bbp_get_root_slug() ); |
| 2531 | 2572 | if ( ! empty( $page ) ) { |
| 2532 | 2573 | $root_url = get_permalink( $page->ID ); |
| 2533 | - $remove_root_id = $page->ID; | |
| 2534 | 2574 | |
| 2535 | 2575 | // Use the root slug |
| 2536 | 2576 | } else { |
| 2537 | 2577 | $root_url = get_post_type_archive_link( bbp_get_forum_post_type() ); |
| @@ -2554,13 +2594,8 @@ | ||
| 2554 | 2594 | if ( empty( $parent ) || is_wp_error( $parent ) ) { |
| 2555 | 2595 | continue; |
| 2556 | 2596 | } |
| 2557 | 2597 | |
| 2558 | - // Skip to prevent duplicate root on subpages | |
| 2559 | - if ( ! empty( $remove_root_id ) && ( $parent->ID === $remove_root_id ) ) { | |
| 2560 | - continue; | |
| 2561 | - } | |
| 2562 | - | |
| 2563 | 2598 | // Switch through post_type to ensure correct filters are applied |
| 2564 | 2599 | switch ( $parent->post_type ) { |
| 2565 | 2600 | |
| 2566 | 2601 | // Forum |
| @@ -2572,9 +2607,9 @@ | ||
| 2572 | 2607 | case bbp_get_topic_post_type() : |
| 2573 | 2608 | $crumbs[] = '<a href="' . esc_url( bbp_get_topic_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>'; |
| 2574 | 2609 | break; |
| 2575 | 2610 | |
| 2576 | - // Reply (Note: not in most themes ) | |
| 2611 | + // Reply (Note: not in most themes) | |
| 2577 | 2612 | case bbp_get_reply_post_type() : |
| 2578 | 2613 | $crumbs[] = '<a href="' . esc_url( bbp_get_reply_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>'; |
| 2579 | 2614 | break; |
| 2580 | 2615 | |
| @@ -2594,9 +2629,9 @@ | ||
| 2594 | 2629 | } elseif ( bbp_is_search() && bbp_get_search_terms() ) { |
| 2595 | 2630 | $crumbs[] = '<a href="' . esc_url( bbp_get_search_url() ) . '" class="bbp-breadcrumb-search">' . esc_html__( 'Search', 'bbpress' ) . '</a>'; |
| 2596 | 2631 | } |
| 2597 | 2632 | |
| 2598 | - /** Current ***********************************************************/ | |
| 2633 | + /** Current ***********************************************************/ | |
| 2599 | 2634 | |
| 2600 | 2635 | // Add current page to breadcrumb |
| 2601 | 2636 | if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) { |
| 2602 | 2637 | $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after']; |
| @@ -2601,9 +2636,9 @@ | ||
| 2601 | 2636 | if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) { |
| 2602 | 2637 | $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after']; |
| 2603 | 2638 | } |
| 2604 | 2639 | |
| 2605 | - /** Separator *********************************************************/ | |
| 2640 | + /** Separator *********************************************************/ | |
| 2606 | 2641 | |
| 2607 | 2642 | // Wrap the separator in before/after before padding and filter |
| 2608 | 2643 | if ( ! empty( $r['sep'] ) ) { |
| 2609 | 2644 | $sep = $r['sep_before'] . $r['sep'] . $r['sep_after']; |
| @@ -2619,9 +2654,9 @@ | ||
| 2619 | 2654 | $sep = str_pad( $sep, strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH ); |
| 2620 | 2655 | } |
| 2621 | 2656 | } |
| 2622 | 2657 | |
| 2623 | - /** Finish Up *********************************************************/ | |
| 2658 | + /** Finish Up *********************************************************/ | |
| 2624 | 2659 | |
| 2625 | 2660 | // Filter the separator and breadcrumb |
| 2626 | 2661 | $sep = apply_filters( 'bbp_breadcrumb_separator', $sep ); |
| 2627 | 2662 | $crumbs = apply_filters( 'bbp_breadcrumbs', $crumbs ); |
| @@ -2647,42 +2682,40 @@ | ||
| 2647 | 2682 | */ |
| 2648 | 2683 | function bbp_allowed_tags() { |
| 2649 | 2684 | echo bbp_get_allowed_tags(); |
| 2650 | 2685 | } |
| 2686 | + /** | |
| 2687 | + * Display all of the allowed tags in HTML format with attributes. | |
| 2688 | + * | |
| 2689 | + * This is useful for displaying in the post area, which elements and | |
| 2690 | + * attributes are supported. As well as any plugins which want to display it. | |
| 2691 | + * | |
| 2692 | + * @since 2.0.0 bbPress (r2782) | |
| 2693 | + * | |
| 2694 | + * @return string HTML allowed tags entity encoded. | |
| 2695 | + */ | |
| 2696 | + function bbp_get_allowed_tags() { | |
| 2651 | 2697 | |
| 2652 | -/** | |
| 2653 | - * Display all of the allowed tags in HTML format with attributes. | |
| 2654 | - * | |
| 2655 | - * This is useful for displaying in the post area, which elements and | |
| 2656 | - * attributes are supported. As well as any plugins which want to display it. | |
| 2657 | - * | |
| 2658 | - * @since 2.0.0 bbPress (r2782) | |
| 2659 | - * | |
| 2660 | - * @return string HTML allowed tags entity encoded. | |
| 2661 | - */ | |
| 2662 | -function bbp_get_allowed_tags() { | |
| 2663 | - $allowed = ''; | |
| 2698 | + $allowed = ''; | |
| 2664 | 2699 | |
| 2665 | - foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) { | |
| 2666 | - $allowed .= '<' . $tag; | |
| 2667 | - | |
| 2668 | - if ( 0 < count( $attributes ) ) { | |
| 2669 | - foreach ( array_keys( $attributes ) as $attribute ) { | |
| 2670 | - $allowed .= ' ' . $attribute. '=""'; | |
| 2700 | + foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) { | |
| 2701 | + $allowed .= '<' . $tag; | |
| 2702 | + if ( 0 < count( $attributes ) ) { | |
| 2703 | + foreach ( array_keys( $attributes ) as $attribute ) { | |
| 2704 | + $allowed .= ' ' . $attribute . '=""'; | |
| 2705 | + } | |
| 2671 | 2706 | } |
| 2707 | + $allowed .= '> '; | |
| 2672 | 2708 | } |
| 2673 | 2709 | |
| 2674 | - $allowed .= '> '; | |
| 2710 | + // Filter & return | |
| 2711 | + return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) ); | |
| 2675 | 2712 | } |
| 2676 | 2713 | |
| 2677 | - // Filter & return | |
| 2678 | - return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) ); | |
| 2679 | -} | |
| 2680 | - | |
| 2681 | 2714 | /** Errors & Messages *********************************************************/ |
| 2682 | 2715 | |
| 2683 | 2716 | /** |
| 2684 | - * Display possible errors & messages inside a template file. | |
| 2717 | + * Display possible errors & messages inside a template file | |
| 2685 | 2718 | * |
| 2686 | 2719 | * @since 2.0.0 bbPress (r2970) |
| 2687 | 2720 | */ |
| 2688 | 2721 | function bbp_template_notices() { |
| @@ -2691,9 +2724,9 @@ | ||
| 2691 | 2724 | if ( ! bbp_has_errors() ) { |
| 2692 | 2725 | return; |
| 2693 | 2726 | } |
| 2694 | 2727 | |
| 2695 | - // Define local variable(s ) | |
| 2728 | + // Define local variable(s) | |
| 2696 | 2729 | $errors = $messages = array(); |
| 2697 | 2730 | |
| 2698 | 2731 | // Get bbPress |
| 2699 | 2732 | $bbp = bbpress(); |
| @@ -2708,15 +2741,15 @@ | ||
| 2708 | 2741 | foreach ( $bbp->errors->get_error_messages( $code ) as $error ) { |
| 2709 | 2742 | if ( 'message' === $severity ) { |
| 2710 | 2743 | $messages[] = $error; |
| 2711 | 2744 | } else { |
| 2712 | - $errors[] = $error; | |
| 2745 | + $errors[] = $error; | |
| 2713 | 2746 | } |
| 2714 | 2747 | } |
| 2715 | 2748 | } |
| 2716 | 2749 | |
| 2717 | 2750 | // Display errors first... |
| 2718 | - if ( ! empty( $errors ) ) { ?> | |
| 2751 | + if ( ! empty( $errors ) ) : ?> | |
| 2719 | 2752 | |
| 2720 | 2753 | <div class="bbp-template-notice error" role="alert" tabindex="-1"> |
| 2721 | 2754 | <ul> |
| 2722 | 2755 | <li><?php echo implode( "</li>\n<li>", $errors ); ?></li> |
| @@ -2722,12 +2755,12 @@ | ||
| 2722 | 2755 | <li><?php echo implode( "</li>\n<li>", $errors ); ?></li> |
| 2723 | 2756 | </ul> |
| 2724 | 2757 | </div> |
| 2725 | 2758 | |
| 2726 | - <?php } | |
| 2759 | + <?php endif; | |
| 2727 | 2760 | |
| 2728 | 2761 | // ...and messages last |
| 2729 | - if ( ! empty( $messages ) ) { ?> | |
| 2762 | + if ( ! empty( $messages ) ) : ?> | |
| 2730 | 2763 | |
| 2731 | 2764 | <div class="bbp-template-notice"> |
| 2732 | 2765 | <ul> |
| 2733 | 2766 | <li><?php echo implode( "</li>\n<li>", $messages ); ?></li> |
| @@ -2733,59 +2766,54 @@ | ||
| 2733 | 2766 | <li><?php echo implode( "</li>\n<li>", $messages ); ?></li> |
| 2734 | 2767 | </ul> |
| 2735 | 2768 | </div> |
| 2736 | 2769 | |
| 2737 | - <?php | |
| 2738 | - | |
| 2739 | - } | |
| 2770 | + <?php endif; | |
| 2740 | 2771 | } |
| 2741 | 2772 | |
| 2742 | 2773 | /** Login/logout/register/lost pass *******************************************/ |
| 2743 | 2774 | |
| 2744 | 2775 | /** |
| 2745 | - * Output the logout link. | |
| 2776 | + * Output the logout link | |
| 2746 | 2777 | * |
| 2747 | 2778 | * @since 2.0.0 bbPress (r2827) |
| 2748 | 2779 | * |
| 2749 | - * @param string $redirect_to Redirect to url. | |
| 2780 | + * @param string $redirect_to Redirect to url | |
| 2750 | 2781 | */ |
| 2751 | 2782 | function bbp_logout_link( $redirect_to = '' ) { |
| 2752 | 2783 | echo bbp_get_logout_link( $redirect_to ); |
| 2753 | 2784 | } |
| 2785 | + /** | |
| 2786 | + * Return the logout link | |
| 2787 | + * | |
| 2788 | + * @since 2.0.0 bbPress (r2827) | |
| 2789 | + * | |
| 2790 | + * @param string $redirect_to Redirect to url | |
| 2791 | + * redirect to url | |
| 2792 | + * @return string The logout link | |
| 2793 | + */ | |
| 2794 | + function bbp_get_logout_link( $redirect_to = '' ) { | |
| 2754 | 2795 | |
| 2755 | -/** | |
| 2756 | - * Return the logout link. | |
| 2757 | - * | |
| 2758 | - * @since 2.0.0 bbPress (r2827) | |
| 2759 | - * | |
| 2760 | - * @param string $redirect_to Redirect to url. | |
| 2761 | - * redirect to url. | |
| 2762 | - * | |
| 2763 | - * @return string The logout link. | |
| 2764 | - */ | |
| 2765 | -function bbp_get_logout_link( $redirect_to = '' ) { | |
| 2796 | + // Build the link | |
| 2797 | + $link = '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>'; | |
| 2766 | 2798 | |
| 2767 | - // Build the link | |
| 2768 | - $link = '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>'; | |
| 2799 | + // Filter & return | |
| 2800 | + return apply_filters( 'bbp_get_logout_link', $link, $redirect_to ); | |
| 2801 | + } | |
| 2769 | 2802 | |
| 2770 | - // Filter & return | |
| 2771 | - return apply_filters( 'bbp_get_logout_link', $link, $redirect_to ); | |
| 2772 | -} | |
| 2773 | - | |
| 2774 | 2803 | /** Title *********************************************************************/ |
| 2775 | 2804 | |
| 2776 | 2805 | /** |
| 2777 | - * Custom page title for bbPress pages. | |
| 2806 | + * Custom page title for bbPress pages | |
| 2778 | 2807 | * |
| 2779 | 2808 | * @since 2.0.0 bbPress (r2788) |
| 2780 | 2809 | * |
| 2781 | - * @param string $title Optional. The title (not used). | |
| 2782 | - * @param string $sep Optional, default is '»'. How to separate the | |
| 2783 | - * various items within the page title. | |
| 2810 | + * @param string $title Optional. The title (not used). | |
| 2811 | + * @param string $sep Optional, default is '»'. How to separate the | |
| 2812 | + * various items within the page title. | |
| 2784 | 2813 | * @param string $seplocation Optional. Direction to display title, 'right'. |
| 2785 | - * separator and separator location. | |
| 2786 | - * | |
| 2787 | - * @return string The title. | |
| 2814 | + * separator and separator location | |
| 2815 | + * @return string The title | |
| 2788 | 2816 | */ |
| 2789 | 2817 | function bbp_title( $title = '', $sep = '»', $seplocation = '' ) { |
| 2790 | 2818 | |
| 2791 | 2819 | // Title array |
| @@ -2790,9 +2818,9 @@ | ||
| 2790 | 2818 | |
| 2791 | 2819 | // Title array |
| 2792 | 2820 | $new_title = array(); |
| 2793 | 2821 | |
| 2794 | - /* Archives ************************************************************* */ | |
| 2822 | + /** Archives **************************************************************/ | |
| 2795 | 2823 | |
| 2796 | 2824 | // Forum Archive |
| 2797 | 2825 | if ( bbp_is_forum_archive() ) { |
| 2798 | 2826 | $new_title['text'] = bbp_get_forum_archive_title(); |
| @@ -2800,9 +2828,9 @@ | ||
| 2800 | 2828 | // Topic Archive |
| 2801 | 2829 | } elseif ( bbp_is_topic_archive() ) { |
| 2802 | 2830 | $new_title['text'] = bbp_get_topic_archive_title(); |
| 2803 | 2831 | |
| 2804 | - /* Edit ***************************************************************** */ | |
| 2832 | + /** Edit ******************************************************************/ | |
| 2805 | 2833 | |
| 2806 | 2834 | // Forum edit page |
| 2807 | 2835 | } elseif ( bbp_is_forum_edit() ) { |
| 2808 | 2836 | $new_title['text'] = bbp_get_forum_title(); |
| @@ -2826,9 +2854,9 @@ | ||
| 2826 | 2854 | $new_title['text'] = bbp_get_topic_tag_name(); |
| 2827 | 2855 | /* translators: %s: Topic tag name */ |
| 2828 | 2856 | $new_title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' ); |
| 2829 | 2857 | |
| 2830 | - /* Singles ************************************************************** */ | |
| 2858 | + /** Singles ***************************************************************/ | |
| 2831 | 2859 | |
| 2832 | 2860 | // Forum page |
| 2833 | 2861 | } elseif ( bbp_is_single_forum() ) { |
| 2834 | 2862 | $new_title['text'] = bbp_get_forum_title(); |
| @@ -2850,12 +2878,13 @@ | ||
| 2850 | 2878 | $new_title['text'] = bbp_get_topic_tag_name(); |
| 2851 | 2879 | /* translators: %s: Topic tag name */ |
| 2852 | 2880 | $new_title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' ); |
| 2853 | 2881 | |
| 2854 | - /* Users **************************************************************** */ | |
| 2882 | + /** Users *****************************************************************/ | |
| 2855 | 2883 | |
| 2856 | 2884 | // Profile page |
| 2857 | 2885 | } elseif ( bbp_is_single_user() ) { |
| 2886 | + | |
| 2858 | 2887 | // Is user viewing their own profile? |
| 2859 | 2888 | $is_user_home = bbp_is_user_home(); |
| 2860 | 2889 | |
| 2861 | 2890 | // User topics created |
| @@ -2898,17 +2927,14 @@ | ||
| 2898 | 2927 | $new_title['format'] = esc_attr__( "%s's Subscriptions", 'bbpress' ); |
| 2899 | 2928 | } |
| 2900 | 2929 | |
| 2901 | 2930 | // User "home" |
| 2902 | - // phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found | |
| 2903 | - } else { | |
| 2904 | - if ( true === $is_user_home ) { | |
| 2931 | + } elseif ( true === $is_user_home ) { | |
| 2905 | 2932 | $new_title['text'] = esc_attr__( 'Your Profile', 'bbpress' ); |
| 2906 | 2933 | } else { |
| 2907 | - $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name; | |
| 2908 | - /* translators: user's display name */ | |
| 2909 | - $new_title['format'] = esc_attr__( "%s's Profile", 'bbpress' ); | |
| 2910 | - } | |
| 2934 | + $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name; | |
| 2935 | + /* translators: user's display name */ | |
| 2936 | + $new_title['format'] = esc_attr__( "%s's Profile", 'bbpress' ); | |
| 2911 | 2937 | } |
| 2912 | 2938 | |
| 2913 | 2939 | // Profile edit page |
| 2914 | 2940 | } elseif ( bbp_is_single_user_edit() ) { |
| @@ -2922,9 +2948,9 @@ | ||
| 2922 | 2948 | /* translators: %s: User's display name */ |
| 2923 | 2949 | $new_title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' ); |
| 2924 | 2950 | } |
| 2925 | 2951 | |
| 2926 | - /* Views **************************************************************** */ | |
| 2952 | + /** Views *****************************************************************/ | |
| 2927 | 2953 | |
| 2928 | 2954 | // Views |
| 2929 | 2955 | } elseif ( bbp_is_single_view() ) { |
| 2930 | 2956 | $new_title['text'] = bbp_get_view_title(); |
| @@ -2930,9 +2956,9 @@ | ||
| 2930 | 2956 | $new_title['text'] = bbp_get_view_title(); |
| 2931 | 2957 | /* translators: %s: View title */ |
| 2932 | 2958 | $new_title['format'] = esc_attr__( 'View: %s', 'bbpress' ); |
| 2933 | 2959 | |
| 2934 | - /* Search *************************************************************** */ | |
| 2960 | + /** Search ****************************************************************/ | |
| 2935 | 2961 | |
| 2936 | 2962 | // Search |
| 2937 | 2963 | } elseif ( bbp_is_search() ) { |
| 2938 | 2964 | $new_title['text'] = bbp_get_search_title(); |
| @@ -2945,9 +2971,9 @@ | ||
| 2945 | 2971 | $new_title = bbp_parse_args( |
| 2946 | 2972 | $new_title, |
| 2947 | 2973 | array( |
| 2948 | 2974 | 'text' => $title, |
| 2949 | - 'format' => '%s', | |
| 2975 | + 'format' => '%s' | |
| 2950 | 2976 | ), |
| 2951 | 2977 | 'title' |
| 2952 | 2978 | ); |
| 2953 | 2979 | |
| @@ -2982,40 +3008,5 @@ | ||
| 2982 | 3008 | } |
| 2983 | 3009 | |
| 2984 | 3010 | // Filter & return |
| 2985 | 3011 | return apply_filters( 'bbp_title', $new_title, $sep, $seplocation ); |
| 2986 | -} | |
| 2987 | - | |
| 2988 | -/** | |
| 2989 | - * Removes Protected/Private post title hints. | |
| 2990 | - * | |
| 2991 | - * This function is hooked to 2 WordPress filters that are responsible for | |
| 2992 | - * prepending hints to the beginning of Protected & Private post titles. | |
| 2993 | - * | |
| 2994 | - * These hints are a bit unsightly when used in functions like | |
| 2995 | - * bbp_get_breadcrumb(), so we strip them back out for bbPress post types. | |
| 2996 | - * | |
| 2997 | - * @since 2.7.0 bbPress (r7276) | |
| 2998 | - * | |
| 2999 | - * @param string $prepend text displayed before a post title. | |
| 3000 | - * @param int|WP_Post $post current post object. | |
| 3001 | - * | |
| 3002 | - * @return string | |
| 3003 | - */ | |
| 3004 | -function bbp_no_title_status_hints( $prepend = '', $post = 0 ) { | |
| 3005 | - | |
| 3006 | - // Bail if empty | |
| 3007 | - if ( empty( $prepend ) || empty( $post ) ) { | |
| 3008 | - return $prepend; | |
| 3009 | - } | |
| 3010 | - | |
| 3011 | - // Get post type | |
| 3012 | - $post_type = get_post_type( $post ); | |
| 3013 | - | |
| 3014 | - // Maybe override return value | |
| 3015 | - $retval = in_array( $post_type, bbp_get_post_types(), true ) | |
| 3016 | - ? '%s' | |
| 3017 | - : $prepend; | |
| 3018 | - | |
| 3019 | - // Filter & return | |
| 3020 | - return (string) apply_filters( 'bbp_no_special_title_formatting', $retval, $prepend, $post ); | |
| 3021 | 3012 | } |