[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/common/ -> template.php (source)

   1  <?php
   2  
   3  /**
   4   * bbPress Common Template Tags
   5   *
   6   * Common template tags are ones that are used by more than one component, like
   7   * forums, topics, replies, users, topic tags, etc...
   8   *
   9   * @package bbPress
  10   * @subpackage TemplateTags
  11   */
  12  
  13  // Exit if accessed directly
  14  defined( 'ABSPATH' ) || exit;
  15  
  16  /** URLs **********************************************************************/
  17  
  18  /**
  19   * Output the forum URL
  20   *
  21   * @since 2.1.0 bbPress (r3979)
  22   *
  23   * @param string $path Additional path with leading slash
  24   */
  25  function bbp_forums_url( $path = '/' ) {
  26      echo esc_url( bbp_get_forums_url( $path ) );
  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      }
  38  
  39  /**
  40   * Output the forum URL
  41   *
  42   * @since 2.1.0 bbPress (r3979)
  43   *
  44   * @param string $path Additional path with leading slash
  45   */
  46  function bbp_topics_url( $path = '/' ) {
  47      echo esc_url( bbp_get_topics_url( $path ) );
  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      }
  60  
  61  /** Add-on Actions ************************************************************/
  62  
  63  /**
  64   * Add our custom head action to wp_head
  65   *
  66   * @since 2.0.0 bbPress (r2464)
  67   */
  68  function bbp_head() {
  69      do_action( 'bbp_head' );
  70  }
  71  
  72  /**
  73   * Add our custom head action to wp_head
  74   *
  75   * @since 2.0.0 bbPress (r2464)
  76   */
  77  function bbp_footer() {
  78      do_action( 'bbp_footer' );
  79  }
  80  
  81  /** is_ ***********************************************************************/
  82  
  83  /**
  84   * Check if current site is public
  85   *
  86   * @since 2.0.0 bbPress (r3398)
  87   *
  88   * @param int $site_id
  89   * @return bool True if site is public, false if private
  90   */
  91  function bbp_is_site_public( $site_id = 0 ) {
  92  
  93      // Get the current site ID
  94      if ( empty( $site_id ) ) {
  95          $site_id = get_current_blog_id();
  96      }
  97  
  98      // Get the site visibility setting
  99      $public = is_multisite()
 100          ? get_blog_option( $site_id, 'blog_public', 1 )
 101          : get_option( 'blog_public', 1 );
 102  
 103      // Filter & return
 104      return (bool) apply_filters( 'bbp_is_site_public', $public, $site_id );
 105  }
 106  
 107  /**
 108   * Check if current page is a bbPress forum
 109   *
 110   * @since 2.0.0 bbPress (r2549)
 111   *
 112   * @param int $post_id Possible post_id to check
 113   * @return bool True if it's a forum page, false if not
 114   */
 115  function bbp_is_forum( $post_id = 0 ) {
 116  
 117      // Assume false
 118      $retval = false;
 119  
 120      // Supplied ID is a forum
 121      if ( ! empty( $post_id ) && ( bbp_get_forum_post_type() === get_post_type( $post_id ) ) ) {
 122          $retval = true;
 123      }
 124  
 125      // Filter & return
 126      return (bool) apply_filters( 'bbp_is_forum', $retval, $post_id );
 127  }
 128  
 129  /**
 130   * Check if we are viewing a forum archive.
 131   *
 132   * @since 2.0.0 bbPress (r3251)
 133   *
 134   * @return bool
 135   */
 136  function bbp_is_forum_archive() {
 137      global $wp_query;
 138  
 139      // Default to false
 140      $retval = false;
 141  
 142      // In forum archive
 143      if ( is_post_type_archive( bbp_get_forum_post_type() ) || bbp_is_query_name( 'bbp_forum_archive' ) || ! empty( $wp_query->bbp_show_topics_on_root ) ) {
 144          $retval = true;
 145      }
 146  
 147      // Filter & return
 148      return (bool) apply_filters( 'bbp_is_forum_archive', $retval );
 149  }
 150  
 151  /**
 152   * Viewing a single forum
 153   *
 154   * @since 2.0.0 bbPress (r3338)
 155   *
 156   * @return bool
 157   */
 158  function bbp_is_single_forum() {
 159  
 160      // Assume false
 161      $retval = false;
 162  
 163      // Edit is not a single forum
 164      if ( bbp_is_forum_edit() ) {
 165          return false;
 166      }
 167  
 168      // Single and a match
 169      if ( is_singular( bbp_get_forum_post_type() ) || bbp_is_query_name( 'bbp_single_forum' ) ) {
 170          $retval = true;
 171      }
 172  
 173      // Filter & return
 174      return (bool) apply_filters( 'bbp_is_single_forum', $retval );
 175  }
 176  
 177  /**
 178   * Check if current page is a forum edit page
 179   *
 180   * @since 2.1.0 bbPress (r3553)
 181   *
 182   * @return bool True if it's the forum edit page, false if not
 183   */
 184  function bbp_is_forum_edit() {
 185      global $wp_query, $pagenow;
 186  
 187      // Assume false
 188      $retval = false;
 189  
 190      // Check query
 191      if ( ! empty( $wp_query->bbp_is_forum_edit ) && ( $wp_query->bbp_is_forum_edit === true ) ) {
 192          $retval = true;
 193  
 194      // Editing in admin
 195      } elseif ( is_admin() && ( 'post.php' === $pagenow ) && ( get_post_type() === bbp_get_forum_post_type() ) && ( ! empty( $_GET['action'] ) && ( 'edit' === $_GET['action'] ) ) ) {
 196          $retval = true;
 197      }
 198  
 199      // Filter & return
 200      return (bool) apply_filters( 'bbp_is_forum_edit', $retval );
 201  }
 202  
 203  /**
 204   * Check if current page is a bbPress topic
 205   *
 206   * @since 2.0.0 bbPress (r2549)
 207   *
 208   * @param int $post_id Possible post_id to check
 209   * @return bool True if it's a topic page, false if not
 210   */
 211  function bbp_is_topic( $post_id = 0 ) {
 212  
 213      // Assume false
 214      $retval = false;
 215  
 216      // Supplied ID is a topic
 217      if ( ! empty( $post_id ) && ( bbp_get_topic_post_type() === get_post_type( $post_id ) ) ) {
 218          $retval = true;
 219      }
 220  
 221      // Filter & return
 222      return (bool) apply_filters( 'bbp_is_topic', $retval, $post_id );
 223  }
 224  
 225  /**
 226   * Viewing a single topic
 227   *
 228   * @since 2.0.0 bbPress (r3338)
 229   *
 230   * @return bool
 231   */
 232  function bbp_is_single_topic() {
 233  
 234      // Assume false
 235      $retval = false;
 236  
 237      // Edit is not a single topic
 238      if ( bbp_is_topic_edit() ) {
 239          return false;
 240      }
 241  
 242      // Single and a match
 243      if ( is_singular( bbp_get_topic_post_type() ) || bbp_is_query_name( 'bbp_single_topic' ) ) {
 244          $retval = true;
 245      }
 246  
 247      // Filter & return
 248      return (bool) apply_filters( 'bbp_is_single_topic', $retval );
 249  }
 250  
 251  /**
 252   * Check if we are viewing a topic archive.
 253   *
 254   * @since 2.0.0 bbPress (r3251)
 255   *
 256   * @return bool
 257   */
 258  function bbp_is_topic_archive() {
 259  
 260      // Default to false
 261      $retval = false;
 262  
 263      // In topic archive
 264      if ( is_post_type_archive( bbp_get_topic_post_type() ) || bbp_is_query_name( 'bbp_topic_archive' ) ) {
 265          $retval = true;
 266      }
 267  
 268      // Filter & return
 269      return (bool) apply_filters( 'bbp_is_topic_archive', $retval );
 270  }
 271  
 272  /**
 273   * Check if current page is a topic edit page
 274   *
 275   * @since 2.0.0 bbPress (r2753)
 276   *
 277   * @return bool True if it's the topic edit page, false if not
 278   */
 279  function bbp_is_topic_edit() {
 280      global $wp_query, $pagenow;
 281  
 282      // Assume false
 283      $retval = false;
 284  
 285      // Check query
 286      if ( ! empty( $wp_query->bbp_is_topic_edit ) && ( $wp_query->bbp_is_topic_edit === true ) ) {
 287          $retval = true;
 288  
 289      // Editing in admin
 290      } elseif ( is_admin() && ( 'post.php' === $pagenow ) && ( get_post_type() === bbp_get_topic_post_type() ) && ( ! empty( $_GET['action'] ) && ( 'edit' === $_GET['action'] ) ) ) {
 291          $retval = true;
 292      }
 293  
 294      // Filter & return
 295      return (bool) apply_filters( 'bbp_is_topic_edit', $retval );
 296  }
 297  
 298  /**
 299   * Check if current page is a topic merge page
 300   *
 301   * @since 2.0.0 bbPress (r2756)
 302   *
 303   * @return bool True if it's the topic merge page, false if not
 304   */
 305  function bbp_is_topic_merge() {
 306  
 307      // Assume false
 308      $retval = false;
 309  
 310      // Check topic edit and GET params
 311      if ( bbp_is_topic_edit() && ! empty( $_GET['action'] ) && ( 'merge' === $_GET['action'] ) ) {
 312          return true;
 313      }
 314  
 315      // Filter & return
 316      return (bool) apply_filters( 'bbp_is_topic_merge', $retval );
 317  }
 318  
 319  /**
 320   * Check if current page is a topic split page
 321   *
 322   * @since 2.0.0 bbPress (r2756)
 323   *
 324   * @return bool True if it's the topic split page, false if not
 325   */
 326  function bbp_is_topic_split() {
 327  
 328      // Assume false
 329      $retval = false;
 330  
 331      // Check topic edit and GET params
 332      if ( bbp_is_topic_edit() && ! empty( $_GET['action'] ) && ( 'split' === $_GET['action'] ) ) {
 333          $retval = true;
 334      }
 335  
 336      // Filter & return
 337      return (bool) apply_filters( 'bbp_is_topic_split', $retval );
 338  }
 339  
 340  /**
 341   * Check if the current page is a topic tag
 342   *
 343   * @since 2.0.0 bbPress (r3311)
 344   *
 345   * @return bool True if it's a topic tag, false if not
 346   */
 347  function bbp_is_topic_tag() {
 348  
 349      // Bail if topic-tags are off
 350      if ( ! bbp_allow_topic_tags() ) {
 351          return false;
 352      }
 353  
 354      // Return false if editing a topic tag
 355      if ( bbp_is_topic_tag_edit() ) {
 356          return false;
 357      }
 358  
 359      // Assume false
 360      $retval = false;
 361  
 362      // Check tax and query vars
 363      if ( is_tax( bbp_get_topic_tag_tax_id() ) || ! empty( bbpress()->topic_query->is_tax ) || get_query_var( 'bbp_topic_tag' ) ) {
 364          $retval = true;
 365      }
 366  
 367      // Filter & return
 368      return (bool) apply_filters( 'bbp_is_topic_tag', $retval );
 369  }
 370  
 371  /**
 372   * Check if the current page is editing a topic tag
 373   *
 374   * @since 2.0.0 bbPress (r3346)
 375   *
 376   * @return bool True if editing a topic tag, false if not
 377   */
 378  function bbp_is_topic_tag_edit() {
 379      global $wp_query, $pagenow, $taxnow;
 380  
 381      // Bail if topic-tags are off
 382      if ( ! bbp_allow_topic_tags() ) {
 383          return false;
 384      }
 385  
 386      // Assume false
 387      $retval = false;
 388  
 389      // Check query
 390      if ( ! empty( $wp_query->bbp_is_topic_tag_edit ) && ( true === $wp_query->bbp_is_topic_tag_edit ) ) {
 391          $retval = true;
 392  
 393      // Editing in admin
 394      } elseif ( is_admin() && ( 'edit-tags.php' === $pagenow ) && ( bbp_get_topic_tag_tax_id() === $taxnow ) && ( ! empty( $_GET['action'] ) && ( 'edit' === $_GET['action'] ) ) ) {
 395          $retval = true;
 396      }
 397  
 398      // Filter & return
 399      return (bool) apply_filters( 'bbp_is_topic_tag_edit', $retval );
 400  }
 401  
 402  /**
 403   * Check if the current post type is one that comes with bbPress
 404   *
 405   * @since 2.0.0 bbPress (r3311)
 406   *
 407   * @param mixed $the_post Optional. Post object or post ID.
 408   *
 409   * @return bool
 410   */
 411  function bbp_is_custom_post_type( $the_post = false ) {
 412  
 413      // Assume false
 414      $retval = false;
 415  
 416      // Viewing one of the bbPress post types
 417      if ( in_array( get_post_type( $the_post ), array(
 418          bbp_get_forum_post_type(),
 419          bbp_get_topic_post_type(),
 420          bbp_get_reply_post_type()
 421      ), true ) ) {
 422          $retval = true;
 423      }
 424  
 425      // Filter & return
 426      return (bool) apply_filters( 'bbp_is_custom_post_type', $retval, $the_post );
 427  }
 428  
 429  /**
 430   * Check if current page is a bbPress reply
 431   *
 432   * @since 2.0.0 bbPress (r2549)
 433   *
 434   * @param int $post_id Possible post_id to check
 435   * @return bool True if it's a reply page, false if not
 436   */
 437  function bbp_is_reply( $post_id = 0 ) {
 438  
 439      // Assume false
 440      $retval = false;
 441  
 442      // Supplied ID is a reply
 443      if ( ! empty( $post_id ) && ( bbp_get_reply_post_type() === get_post_type( $post_id ) ) ) {
 444          $retval = true;
 445      }
 446  
 447      // Filter & return
 448      return (bool) apply_filters( 'bbp_is_reply', $retval, $post_id );
 449  }
 450  
 451  /**
 452   * Check if current page is a reply edit page
 453   *
 454   * @since 2.0.0 bbPress (r2753)
 455   *
 456   * @return bool True if it's the reply edit page, false if not
 457   */
 458  function bbp_is_reply_edit() {
 459      global $wp_query, $pagenow;
 460  
 461      // Assume false
 462      $retval = false;
 463  
 464      // Check query
 465      if ( ! empty( $wp_query->bbp_is_reply_edit ) && ( true === $wp_query->bbp_is_reply_edit ) ) {
 466          $retval = true;
 467  
 468      // Editing in admin
 469      } elseif ( is_admin() && ( 'post.php' === $pagenow ) && ( get_post_type() === bbp_get_reply_post_type() ) && ( ! empty( $_GET['action'] ) && ( 'edit' === $_GET['action'] ) ) ) {
 470          $retval = true;
 471      }
 472  
 473      // Filter & return
 474      return (bool) apply_filters( 'bbp_is_reply_edit', $retval );
 475  }
 476  
 477  /**
 478   * Check if current page is a reply move page
 479   *
 480   * @return bool True if it's the reply move page, false if not
 481   */
 482  function bbp_is_reply_move() {
 483  
 484      // Assume false
 485      $retval = false;
 486  
 487      // Check reply edit and GET params
 488      if ( bbp_is_reply_edit() && ! empty( $_GET['action'] ) && ( 'move' === $_GET['action'] ) ) {
 489          $retval = true;
 490      }
 491  
 492      // Filter & return
 493      return (bool) apply_filters( 'bbp_is_reply_move', $retval );
 494  }
 495  
 496  /**
 497   * Viewing a single reply
 498   *
 499   * @since 2.0.0 bbPress (r3344)
 500   *
 501   * @return bool
 502   */
 503  function bbp_is_single_reply() {
 504  
 505      // Assume false
 506      $retval = false;
 507  
 508      // Edit is not a single reply
 509      if ( bbp_is_reply_edit() ) {
 510          return false;
 511      }
 512  
 513      // Single and a match
 514      if ( is_singular( bbp_get_reply_post_type() ) || ( bbp_is_query_name( 'bbp_single_reply' ) ) ) {
 515          $retval = true;
 516      }
 517  
 518      // Filter & return
 519      return (bool) apply_filters( 'bbp_is_single_reply', $retval );
 520  }
 521  
 522  /**
 523   * Check if current page is a bbPress user's favorites page (profile page)
 524   *
 525   * @since 2.0.0 bbPress (r2652)
 526   *
 527   * @return bool True if it's the favorites page, false if not
 528   */
 529  function bbp_is_favorites() {
 530      global $wp_query;
 531  
 532      // Assume false
 533      $retval = false;
 534  
 535      // Check query
 536      if ( ! empty( $wp_query->bbp_is_single_user_favs ) && ( true === $wp_query->bbp_is_single_user_favs ) ) {
 537          $retval = true;
 538      }
 539  
 540      // Filter & return
 541      return (bool) apply_filters( 'bbp_is_favorites', $retval );
 542  }
 543  
 544  /**
 545   * Check if current page is a bbPress user's subscriptions page (profile page)
 546   *
 547   * @since 2.0.0 bbPress (r2652)
 548   *
 549   * @return bool True if it's the subscriptions page, false if not
 550   */
 551  function bbp_is_subscriptions() {
 552      global $wp_query;
 553  
 554      // Assume false
 555      $retval = false;
 556  
 557      // Check query
 558      if ( ! empty( $wp_query->bbp_is_single_user_subs ) && ( true === $wp_query->bbp_is_single_user_subs ) ) {
 559          $retval = true;
 560      }
 561  
 562      // Filter & return
 563      return (bool) apply_filters( 'bbp_is_subscriptions', $retval );
 564  }
 565  
 566  /**
 567   * Check if current page shows the topics created by a bbPress user (profile
 568   * page)
 569   *
 570   * @since 2.0.0 bbPress (r2688)
 571   *
 572   * @return bool True if it's the topics created page, false if not
 573   */
 574  function bbp_is_topics_created() {
 575      global $wp_query;
 576  
 577      // Assume false
 578      $retval = false;
 579  
 580      // Check query
 581      if ( ! empty( $wp_query->bbp_is_single_user_topics ) && ( true === $wp_query->bbp_is_single_user_topics ) ) {
 582          $retval = true;
 583      }
 584  
 585      // Filter & return
 586      return (bool) apply_filters( 'bbp_is_topics_created', $retval );
 587  }
 588  
 589  /**
 590   * Check if current page shows the replies created by a bbPress user (profile
 591   * page)
 592   *
 593   * @since 2.2.0 bbPress (r4225)
 594   *
 595   * @return bool True if it's the replies created page, false if not
 596   */
 597  function bbp_is_replies_created() {
 598      global $wp_query;
 599  
 600      // Assume false
 601      $retval = false;
 602  
 603      // Check query
 604      if ( ! empty( $wp_query->bbp_is_single_user_replies ) && ( true === $wp_query->bbp_is_single_user_replies ) ) {
 605          $retval = true;
 606      }
 607  
 608      // Filter & return
 609      return (bool) apply_filters( 'bbp_is_replies_created', $retval );
 610  }
 611  
 612  /**
 613   * Check if current page is the currently logged in users author page
 614   *
 615   * @since 2.0.0 bbPress (r2688)
 616   *
 617   * @return bool True if it's the user's home, false if not
 618   */
 619  function bbp_is_user_home() {
 620      global $wp_query;
 621  
 622      // Assume false
 623      $retval = false;
 624  
 625      // Check query
 626      if ( ! empty( $wp_query->bbp_is_single_user_home ) && ( true === $wp_query->bbp_is_single_user_home ) ) {
 627          $retval = true;
 628      }
 629  
 630      // Filter & return
 631      return (bool) apply_filters( 'bbp_is_user_home', $retval );
 632  }
 633  
 634  /**
 635   * Check if current page is the currently logged in users author edit page
 636   *
 637   * @since 2.1.0 bbPress (r3918)
 638   *
 639   * @return bool True if it's the user's home, false if not
 640   */
 641  function bbp_is_user_home_edit() {
 642  
 643      // Assume false
 644      $retval = false;
 645  
 646      if ( bbp_is_user_home() && bbp_is_single_user_edit() ) {
 647          $retval = true;
 648      }
 649  
 650      // Filter & return
 651      return (bool) apply_filters( 'bbp_is_user_home_edit', $retval );
 652  }
 653  
 654  /**
 655   * Check if current page is a user profile page
 656   *
 657   * @since 2.0.0 bbPress (r2688)
 658   *
 659   * @return bool True if it's a user's profile page, false if not
 660   */
 661  function bbp_is_single_user() {
 662      global $wp_query;
 663  
 664      // Assume false
 665      $retval = false;
 666  
 667      // Check query
 668      if ( ! empty( $wp_query->bbp_is_single_user ) && ( true === $wp_query->bbp_is_single_user ) ) {
 669          $retval = true;
 670      }
 671  
 672      // Filter & return
 673      return (bool) apply_filters( 'bbp_is_single_user', $retval );
 674  }
 675  
 676  /**
 677   * Check if current page is a user profile edit page
 678   *
 679   * @since 2.0.0 bbPress (r2688)
 680   *
 681   * @return bool True if it's a user's profile edit page, false if not
 682   */
 683  function bbp_is_single_user_edit() {
 684      global $wp_query;
 685  
 686      // Assume false
 687      $retval = false;
 688  
 689      // Check query
 690      if ( ! empty( $wp_query->bbp_is_single_user_edit ) && ( true === $wp_query->bbp_is_single_user_edit ) ) {
 691          $retval = true;
 692      }
 693  
 694      // Filter & return
 695      return (bool) apply_filters( 'bbp_is_single_user_edit', $retval );
 696  }
 697  
 698  /**
 699   * Check if current page is a user profile page
 700   *
 701   * @since 2.2.0 bbPress (r4225)
 702   *
 703   * @return bool True if it's a user's profile page, false if not
 704   */
 705  function bbp_is_single_user_profile() {
 706      global $wp_query;
 707  
 708      // Assume false
 709      $retval = false;
 710  
 711      // Check query
 712      if ( ! empty( $wp_query->bbp_is_single_user_profile ) && ( true === $wp_query->bbp_is_single_user_profile ) ) {
 713          $retval = true;
 714      }
 715  
 716      // Filter & return
 717      return (bool) apply_filters( 'bbp_is_single_user_profile', $retval );
 718  }
 719  
 720  /**
 721   * Check if current page is a user topics created page
 722   *
 723   * @since 2.2.0 bbPress (r4225)
 724   *
 725   * @return bool True if it's a user's topics page, false if not
 726   */
 727  function bbp_is_single_user_topics() {
 728      global $wp_query;
 729  
 730      // Assume false
 731      $retval = false;
 732  
 733      // Check query
 734      if ( ! empty( $wp_query->bbp_is_single_user_topics ) && ( true === $wp_query->bbp_is_single_user_topics ) ) {
 735          $retval = true;
 736      }
 737  
 738      // Filter & return
 739      return (bool) apply_filters( 'bbp_is_single_user_topics', $retval );
 740  }
 741  
 742  /**
 743   * Check if current page is a user replies created page
 744   *
 745   * @since 2.2.0 bbPress (r4225)
 746   *
 747   * @return bool True if it's a user's replies page, false if not
 748   */
 749  function bbp_is_single_user_replies() {
 750      global $wp_query;
 751  
 752      // Assume false
 753      $retval = false;
 754  
 755      // Check query
 756      if ( ! empty( $wp_query->bbp_is_single_user_replies ) && ( true === $wp_query->bbp_is_single_user_replies ) ) {
 757          $retval = true;
 758      }
 759  
 760      // Filter & return
 761      return (bool) apply_filters( 'bbp_is_single_user_replies', $retval );
 762  }
 763  
 764  /**
 765   * Check if current page is a user engagements page
 766   *
 767   * @since 2.6.0 bbPress (r6320)
 768   *
 769   * @return bool True if it's a user's replies page, false if not
 770   */
 771  function bbp_is_single_user_engagements() {
 772      global $wp_query;
 773  
 774      // Assume false
 775      $retval = false;
 776  
 777      // Check query
 778      if ( ! empty( $wp_query->bbp_is_single_user_engagements ) && ( true === $wp_query->bbp_is_single_user_engagements ) ) {
 779          $retval = true;
 780      }
 781  
 782      // Filter & return
 783      return (bool) apply_filters( 'bbp_is_single_user_engagements', $retval );
 784  }
 785  
 786  /**
 787   * Check if current page is a view page
 788   *
 789   * @since 2.0.0 bbPress (r2789)
 790   *
 791   * @global WP_Query $wp_query To check if WP_Query::bbp_is_view is true
 792   * @return bool Is it a view page?
 793   */
 794  function bbp_is_single_view() {
 795      global $wp_query;
 796  
 797      // Assume false
 798      $retval = false;
 799  
 800      // Check query
 801      if ( ! empty( $wp_query->bbp_is_view ) && ( true === $wp_query->bbp_is_view ) ) {
 802          $retval = true;
 803      }
 804  
 805      // Check query name
 806      if ( empty( $retval ) && bbp_is_query_name( 'bbp_single_view' ) ) {
 807          $retval = true;
 808      }
 809  
 810      // Filter & return
 811      return (bool) apply_filters( 'bbp_is_single_view', $retval );
 812  }
 813  
 814  /**
 815   * Check if current page is a search page
 816   *
 817   * @since 2.3.0 bbPress (r4579)
 818   *
 819   * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true
 820   * @return bool Is it a search page?
 821   */
 822  function bbp_is_search() {
 823      global $wp_query;
 824  
 825      // Bail if search is disabled
 826      if ( ! bbp_allow_search() ) {
 827          return false;
 828      }
 829  
 830      // Assume false
 831      $retval = false;
 832  
 833      // Check query
 834      if ( ! empty( $wp_query->bbp_is_search ) && ( true === $wp_query->bbp_is_search ) ) {
 835          $retval = true;
 836      }
 837  
 838      // Check query name
 839      if ( empty( $retval ) && bbp_is_query_name( bbp_get_search_rewrite_id() ) ) {
 840          $retval = true;
 841      }
 842  
 843      // Check $_GET
 844      if ( empty( $retval ) && isset( $_REQUEST[ bbp_get_search_rewrite_id() ] ) && empty( $_REQUEST[ bbp_get_search_rewrite_id() ] ) ) {
 845          $retval = true;
 846      }
 847  
 848      // Filter & return
 849      return (bool) apply_filters( 'bbp_is_search', $retval );
 850  }
 851  
 852  /**
 853   * Check if current page is a search results page
 854   *
 855   * @since 2.4.0 bbPress (r4919)
 856   *
 857   * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true
 858   * @return bool Is it a search page?
 859   */
 860  function bbp_is_search_results() {
 861      global $wp_query;
 862  
 863      // Bail if search is disabled
 864      if ( ! bbp_allow_search() ) {
 865          return false;
 866      }
 867  
 868      // Assume false
 869      $retval = false;
 870  
 871      // Check query
 872      if ( ! empty( $wp_query->bbp_search_terms ) ) {
 873          $retval = true;
 874      }
 875  
 876      // Check query name
 877      if ( empty( $retval ) && bbp_is_query_name( 'bbp_search_results' ) ) {
 878          $retval = true;
 879      }
 880  
 881      // Check $_REQUEST
 882      if ( empty( $retval ) && ! empty( $_REQUEST[ bbp_get_search_rewrite_id() ] ) ) {
 883          $retval = true;
 884      }
 885  
 886      // Filter & return
 887      return (bool) apply_filters( 'bbp_is_search_results', $retval );
 888  }
 889  
 890  /**
 891   * Check if current page is an edit page
 892   *
 893   * @since 2.1.0 bbPress (r3585)
 894   *
 895   * @return bool True if it's the edit page, false if not
 896   */
 897  function bbp_is_edit() {
 898      global $wp_query;
 899  
 900      // Assume false
 901      $retval = false;
 902  
 903      // Check query
 904      if ( ! empty( $wp_query->bbp_is_edit ) && ( $wp_query->bbp_is_edit === true ) ) {
 905          $retval = true;
 906      }
 907  
 908      // Filter & return
 909      return (bool) apply_filters( 'bbp_is_edit', $retval );
 910  }
 911  
 912  /**
 913   * Use the above is_() functions to output a body class for each scenario
 914   *
 915   * @since 2.0.0 bbPress (r2926)
 916   *
 917   * @param array $wp_classes
 918   * @param array $custom_classes
 919   * @return array Body Classes
 920   */
 921  function bbp_body_class( $wp_classes, $custom_classes = false ) {
 922  
 923      $bbp_classes = array();
 924  
 925      /** Archives **************************************************************/
 926  
 927      if ( bbp_is_forum_archive() ) {
 928          $bbp_classes[] = bbp_get_forum_post_type() . '-archive';
 929  
 930      } elseif ( bbp_is_topic_archive() ) {
 931          $bbp_classes[] = bbp_get_topic_post_type() . '-archive';
 932  
 933      /** Topic Tags ************************************************************/
 934  
 935      } elseif ( bbp_is_topic_tag() ) {
 936          $bbp_classes[] = bbp_get_topic_tag_tax_id();
 937          $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_slug();
 938          $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id();
 939      } elseif ( bbp_is_topic_tag_edit() ) {
 940          $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-edit';
 941          $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_slug() . '-edit';
 942          $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id()   . '-edit';
 943  
 944      /** Components ************************************************************/
 945  
 946      } elseif ( bbp_is_single_forum() ) {
 947          $bbp_classes[] = bbp_get_forum_post_type();
 948  
 949      } elseif ( bbp_is_single_topic() ) {
 950          $bbp_classes[] = bbp_get_topic_post_type();
 951  
 952      } elseif ( bbp_is_single_reply() ) {
 953          $bbp_classes[] = bbp_get_reply_post_type();
 954  
 955      } elseif ( bbp_is_topic_edit() ) {
 956          $bbp_classes[] = bbp_get_topic_post_type() . '-edit';
 957  
 958      } elseif ( bbp_is_topic_merge() ) {
 959          $bbp_classes[] = bbp_get_topic_post_type() . '-merge';
 960  
 961      } elseif ( bbp_is_topic_split() ) {
 962          $bbp_classes[] = bbp_get_topic_post_type() . '-split';
 963  
 964      } elseif ( bbp_is_reply_edit() ) {
 965          $bbp_classes[] = bbp_get_reply_post_type() . '-edit';
 966  
 967      } elseif ( bbp_is_reply_move() ) {
 968          $bbp_classes[] = bbp_get_reply_post_type() . '-move';
 969  
 970      } elseif ( bbp_is_single_view() ) {
 971          $bbp_classes[] = 'bbp-view';
 972          $bbp_classes[] = 'bbp-view-' . bbp_get_view_id();
 973  
 974      /** User ******************************************************************/
 975  
 976      } elseif ( bbp_is_single_user_edit() ) {
 977          $bbp_classes[] = 'bbp-user-edit';
 978          $bbp_classes[] = 'single';
 979          $bbp_classes[] = 'singular';
 980  
 981      } elseif ( bbp_is_single_user() ) {
 982          $bbp_classes[] = 'bbp-user-page';
 983          $bbp_classes[] = 'single';
 984          $bbp_classes[] = 'singular';
 985  
 986      } elseif ( bbp_is_user_home() ) {
 987          $bbp_classes[] = 'bbp-user-home';
 988          $bbp_classes[] = 'single';
 989          $bbp_classes[] = 'singular';
 990  
 991      } elseif ( bbp_is_user_home_edit() ) {
 992          $bbp_classes[] = 'bbp-user-home-edit';
 993          $bbp_classes[] = 'single';
 994          $bbp_classes[] = 'singular';
 995  
 996      } elseif ( bbp_is_topics_created() ) {
 997          $bbp_classes[] = 'bbp-topics-created';
 998          $bbp_classes[] = 'single';
 999          $bbp_classes[] = 'singular';
1000  
1001      } elseif ( bbp_is_replies_created() ) {
1002          $bbp_classes[] = 'bbp-replies-created';
1003          $bbp_classes[] = 'single';
1004          $bbp_classes[] = 'singular';
1005  
1006      } elseif ( bbp_is_favorites() ) {
1007          $bbp_classes[] = 'bbp-favorites';
1008          $bbp_classes[] = 'single';
1009          $bbp_classes[] = 'singular';
1010  
1011      } elseif ( bbp_is_subscriptions() ) {
1012          $bbp_classes[] = 'bbp-subscriptions';
1013          $bbp_classes[] = 'single';
1014          $bbp_classes[] = 'singular';
1015  
1016      /** Search ****************************************************************/
1017  
1018      } elseif ( bbp_is_search() ) {
1019          $bbp_classes[] = 'bbp-search';
1020          $bbp_classes[] = 'forum-search';
1021  
1022      } elseif ( bbp_is_search_results() ) {
1023          $bbp_classes[] = 'bbp-search-results';
1024          $bbp_classes[] = 'forum-search-results';
1025  
1026      /** Shortcodes ************************************************************/
1027  
1028      } elseif ( bbp_has_shortcode() ) {
1029          $bbp_classes[] = 'bbp-shortcode';
1030      }
1031  
1032      /** Clean up **************************************************************/
1033  
1034      // Add bbPress class if we are within a bbPress page
1035      if ( ! empty( $bbp_classes ) ) {
1036          $bbp_classes[] = 'bbpress';
1037      }
1038  
1039      // Merge WP classes with bbPress classes and remove any duplicates
1040      $classes = array_unique( array_merge( (array) $bbp_classes, (array) $wp_classes ) );
1041  
1042      // Deprecated filter (do not use)
1043      $classes = apply_filters( 'bbp_get_the_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes );
1044  
1045      // Filter & return
1046      return (array) apply_filters( 'bbp_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes );
1047  }
1048  
1049  /**
1050   * Check if text contains a bbPress shortcode.
1051   *
1052   * Loops through registered bbPress shortcodes and keeps track of which ones
1053   * were used in a blob of text. If no text is passed, the current global post
1054   * content is assumed.
1055   *
1056   * A preliminary strpos() is performed before looping through each shortcode, to
1057   * prevent unnecessarily processing.
1058   *
1059   * @since 2.6.0
1060   *
1061   * @param string $text
1062   * @return bool
1063   */
1064  function bbp_has_shortcode( $text = '' ) {
1065  
1066      // Default return value
1067      $retval = false;
1068      $found  = array();
1069  
1070      // Fallback to global post_content
1071      if ( empty( $text ) && is_singular() ) {
1072          $text = bbp_get_global_post_field( 'post_content', 'raw' );
1073      }
1074  
1075      // Skip if empty, or string doesn't contain the bbPress shortcode prefix
1076      if ( ! empty( $text ) && ( false !== strpos( $text, '[bbp' ) ) ) {
1077  
1078          // Get possible shortcodes
1079          $codes = array_keys( bbpress()->shortcodes->codes );
1080  
1081          // Loop through codes
1082          foreach ( $codes as $code ) {
1083  
1084              // Looking for shortcode in text
1085              if ( has_shortcode( $text, $code ) ) {
1086                  $retval  = true;
1087                  $found[] = $code;
1088              }
1089          }
1090      }
1091  
1092      // Filter & return
1093      return (bool) apply_filters( 'bbp_has_shortcode', $retval, $found, $text );
1094  }
1095  
1096  /**
1097   * Use the above is_() functions to return if in any bbPress page
1098   *
1099   * @since 2.0.0 bbPress (r3344)
1100   *
1101   * @return bool In a bbPress page
1102   */
1103  function is_bbpress() {
1104  
1105      // Defalt to false
1106      $retval = false;
1107  
1108      /** Archives **************************************************************/
1109  
1110      if ( bbp_is_forum_archive() ) {
1111          $retval = true;
1112  
1113      } elseif ( bbp_is_topic_archive() ) {
1114          $retval = true;
1115  
1116      /** Topic Tags ************************************************************/
1117  
1118      } elseif ( bbp_is_topic_tag() ) {
1119          $retval = true;
1120  
1121      } elseif ( bbp_is_topic_tag_edit() ) {
1122          $retval = true;
1123  
1124      /** Components ************************************************************/
1125  
1126      } elseif ( bbp_is_single_forum() ) {
1127          $retval = true;
1128  
1129      } elseif ( bbp_is_single_topic() ) {
1130          $retval = true;
1131  
1132      } elseif ( bbp_is_single_reply() ) {
1133          $retval = true;
1134  
1135      } elseif ( bbp_is_topic_edit() ) {
1136          $retval = true;
1137  
1138      } elseif ( bbp_is_topic_merge() ) {
1139          $retval = true;
1140  
1141      } elseif ( bbp_is_topic_split() ) {
1142          $retval = true;
1143  
1144      } elseif ( bbp_is_reply_edit() ) {
1145          $retval = true;
1146  
1147      } elseif ( bbp_is_reply_move() ) {
1148          $retval = true;
1149  
1150      } elseif ( bbp_is_single_view() ) {
1151          $retval = true;
1152  
1153      /** User ******************************************************************/
1154  
1155      } elseif ( bbp_is_single_user_edit() ) {
1156          $retval = true;
1157  
1158      } elseif ( bbp_is_single_user() ) {
1159          $retval = true;
1160  
1161      } elseif ( bbp_is_user_home() ) {
1162          $retval = true;
1163  
1164      } elseif ( bbp_is_user_home_edit() ) {
1165          $retval = true;
1166  
1167      } elseif ( bbp_is_topics_created() ) {
1168          $retval = true;
1169  
1170      } elseif ( bbp_is_replies_created() ) {
1171          $retval = true;
1172  
1173      } elseif ( bbp_is_favorites() ) {
1174          $retval = true;
1175  
1176      } elseif ( bbp_is_subscriptions() ) {
1177          $retval = true;
1178  
1179      /** Search ****************************************************************/
1180  
1181      } elseif ( bbp_is_search() ) {
1182          $retval = true;
1183  
1184      } elseif ( bbp_is_search_results() ) {
1185          $retval = true;
1186  
1187      /** Shortcodes ************************************************************/
1188  
1189      } elseif ( bbp_has_shortcode() ) {
1190          $retval = true;
1191      }
1192  
1193      /** Done ******************************************************************/
1194  
1195      // Filter & return
1196      return (bool) apply_filters( 'is_bbpress', $retval );
1197  }
1198  
1199  /** Forms *********************************************************************/
1200  
1201  /**
1202   * Output the login form action url
1203   *
1204   * @since 2.0.0 bbPress (r2815)
1205   *
1206   * @param array $args This function supports these arguments:
1207   *  - action: The action being taken
1208   *  - context: The context the action is being taken from
1209   */
1210  function bbp_wp_login_action( $args = array() ) {
1211      echo esc_url( bbp_get_wp_login_action( $args ) );
1212  }
1213  
1214      /**
1215       * Return the login form action url
1216       *
1217       * @since 2.6.0 bbPress (r5684)
1218       *
1219       * @param array $args This function supports these arguments:
1220       *  - action: The action being taken
1221       *  - context: The context the action is being taken from
1222       */
1223  	function bbp_get_wp_login_action( $args = array() ) {
1224  
1225          // Parse arguments against default values
1226          $r = bbp_parse_args( $args, array(
1227              'action'  => '',
1228              'context' => '',
1229              'url'     => 'wp-login.php'
1230          ), 'login_action' );
1231  
1232          // Add action as query arg
1233          $login_url = ! empty( $r['action'] )
1234              ? add_query_arg( array( 'action' => $r['action'] ), $r['url'] )
1235              : $r['url'];
1236  
1237          $login_url = site_url( $login_url, $r['context'] );
1238  
1239          // Filter & return
1240          return apply_filters( 'bbp_get_wp_login_action', $login_url, $r, $args );
1241      }
1242  
1243  /**
1244   * Output hidden request URI field for user forms.
1245   *
1246   * The referer link is the current Request URI from the server super global. To
1247   * check the field manually, use bbp_get_redirect_to().
1248   *
1249   * @since 2.0.0 bbPress (r2815)
1250   *
1251   * @param string $redirect_to Pass a URL to redirect to
1252   */
1253  function bbp_redirect_to_field( $redirect_to = '' ) {
1254  
1255      // Make sure we are directing somewhere
1256      if ( empty( $redirect_to ) ) {
1257          if ( isset( $_SERVER['REQUEST_URI'] ) ) {
1258              $redirect_to = bbp_get_url_scheme() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
1259          } else {
1260              $redirect_to = wp_get_referer();
1261          }
1262      }
1263  
1264      // Remove loggedout query arg if it's there
1265      $redirect_to    = remove_query_arg( 'loggedout', $redirect_to );
1266      $redirect_field = '<input type="hidden" id="bbp_redirect_to" name="redirect_to" value="' . esc_url( $redirect_to ) . '" />';
1267  
1268      // Filter & return
1269      echo apply_filters( 'bbp_redirect_to_field', $redirect_field, $redirect_to );
1270  }
1271  
1272  /**
1273   * Echo sanitized $_REQUEST value.
1274   *
1275   * Use the $input_type parameter to properly process the value. This
1276   * ensures correct sanitization of the value for the receiving input.
1277   *
1278   * @since 2.0.0 bbPress (r2815)
1279   *
1280   * @param string $request Name of $_REQUEST to look for
1281   * @param string $input_type Type of input. Default: text. Accepts:
1282   *                            textarea|password|select|radio|checkbox
1283   */
1284  function bbp_sanitize_val( $request = '', $input_type = 'text' ) {
1285      echo bbp_get_sanitize_val( $request, $input_type );
1286  }
1287      /**
1288       * Return sanitized $_REQUEST value.
1289       *
1290       * Use the $input_type parameter to properly process the value. This
1291       * ensures correct sanitization of the value for the receiving input.
1292       *
1293       * @since 2.0.0 bbPress (r2815)
1294       *
1295       * @param string $request Name of $_REQUEST to look for
1296       * @param string $input_type Type of input. Default: text. Accepts:
1297       *                            textarea|password|select|radio|checkbox
1298       *
1299       * @return string Sanitized value ready for screen display
1300       */
1301  	function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) {
1302  
1303          // Check that requested
1304          if ( empty( $_REQUEST[ $request ] ) ) {
1305              return false;
1306          }
1307  
1308          // Set request varaible
1309          $pre_ret_val = $_REQUEST[ $request ];
1310  
1311          // Treat different kinds of fields in different ways
1312          switch ( $input_type ) {
1313              case 'text'     :
1314              case 'textarea' :
1315                  $retval = esc_attr( wp_unslash( $pre_ret_val ) );
1316                  break;
1317  
1318              case 'password' :
1319              case 'select'   :
1320              case 'radio'    :
1321              case 'checkbox' :
1322              default :
1323                  $retval = esc_attr( $pre_ret_val );
1324                  break;
1325          }
1326  
1327          // Filter & return
1328          return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type );
1329      }
1330  
1331  /**
1332   * Output the current tab index of a given form
1333   *
1334   * Use this function to handle the tab indexing of user facing forms within a
1335   * template file. Calling this function will automatically increment the global
1336   * tab index by default.
1337   *
1338   * @since 2.0.0 bbPress (r2810)
1339   *
1340   * @deprecated 2.6.0 bbPress (r5561)
1341   *
1342   * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
1343   * @param int $auto_increment Optional. Default true. Set to false to prevent
1344   *                             increment
1345   */
1346  function bbp_tab_index( $auto_increment = true ) {
1347      echo bbp_get_tab_index( $auto_increment );
1348  }
1349  
1350      /**
1351       * Return the current tab index of a given form
1352       *
1353       * Use this function to handle the tab indexing of user facing forms
1354       * within a template file. Calling this function will automatically
1355       * increment the global tab index by default.
1356       *
1357       * @since 2.0.0 bbPress (r2810)
1358       *
1359       * @deprecated 2.6.0 bbPress (r5561)
1360       *
1361       * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
1362       * @param int $auto_increment Optional. Default true. Set to false to
1363       *                             prevent the increment
1364       * @return int $bbp->tab_index The global tab index
1365       */
1366  	function bbp_get_tab_index( $auto_increment = true ) {
1367          $bbp = bbpress();
1368  
1369          if ( true === $auto_increment ) {
1370              ++$bbp->tab_index;
1371          }
1372  
1373          // Filter & return
1374          return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index );
1375      }
1376  
1377  /**
1378   * Output a "tabindex" attribute for an element, if an index was passed.
1379   *
1380   * This helper function is in use, but it is generally considered impolite to
1381   * override the "tabindex" attribute beyond what the browser naturally assigns.
1382   *
1383   * Most internal usages pass `false` which results in no attribute being used.
1384   *
1385   * @since 2.6.0 bbPress (r6424)
1386   *
1387   * @param mixed $tab False to skip, any integer to use
1388   */
1389  function bbp_tab_index_attribute( $tab = false ) {
1390      echo bbp_get_tab_index_attribute( $tab );
1391  }
1392  
1393      /**
1394       * Return a "tabindex" attribute for an element, if an index was passed.
1395       *
1396       * This helper function is in use, but it is generally considered impolite to
1397       * override the "tabindex" attribute beyond what the browser naturally assigns.
1398       *
1399       * Most internal usages pass `false` which results in no attribute being used.
1400       *
1401       * @since 2.6.0 bbPress (r6424)
1402       *
1403       * @param mixed $tab False to skip, any integer to use
1404       *
1405       * @return string
1406       */
1407  	function bbp_get_tab_index_attribute( $tab = false ) {
1408  
1409          // Get attribute
1410          $attr = is_numeric( $tab )
1411              ? ' tabindex="' . (int) $tab . '"'
1412              : '';
1413  
1414          // Filter & return
1415          return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab );
1416      }
1417  
1418  /**
1419   * Output a select box allowing to pick which forum/topic a new topic/reply
1420   * belongs in.
1421   *
1422   * Can be used for any post type, but is mostly used for topics and forums.
1423   *
1424   * @since 2.0.0 bbPress (r2746)
1425   *
1426   * @param array $args See {@link bbp_get_dropdown()} for arguments
1427   */
1428  function bbp_dropdown( $args = array() ) {
1429      echo bbp_get_dropdown( $args );
1430  }
1431      /**
1432       * Return a select box allowing to pick which forum/topic a new
1433       * topic/reply belongs in.
1434       *
1435       * @since 2.0.0 bbPress (r2746)
1436       *
1437       * @param array $args The function supports these args:
1438       *  - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum)
1439       *  - selected: Selected ID, to not have any value as selected, pass
1440       *               anything smaller than 0 (due to the nature of select
1441       *               box, the first value would of course be selected -
1442       *               though you can have that as none (pass 'show_none' arg))
1443       *  - orderby: Defaults to 'menu_order title'
1444       *  - post_parent: Post parent. Defaults to 0
1445       *  - post_status: Which all post_statuses to find in? Can be an array
1446       *                  or CSV of publish, category, closed, private, spam,
1447       *                  trash (based on post type) - if not set, these are
1448       *                  automatically determined based on the post_type
1449       *  - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get
1450       *                     all posts
1451       *  - walker: Which walker to use? Defaults to
1452       *             {@link BBP_Walker_Dropdown}
1453       *  - select_id: ID of the select box. Defaults to 'bbp_forum_id'
1454       *  - tab: Deprecated. Tabindex value. False or integer
1455       *  - options_only: Show only <options>? No <select>?
1456       *  - show_none: Boolean or String __( '&mdash; No Forum &mdash;', 'bbpress' )
1457       *  - disable_categories: Disable forum categories and closed forums?
1458       *                         Defaults to true. Only for forums and when
1459       * @return string The dropdown
1460       */
1461  	function bbp_get_dropdown( $args = array() ) {
1462  
1463          // Setup return value
1464          $retval = '';
1465  
1466          /** Arguments *********************************************************/
1467  
1468          // Parse arguments against default values
1469          $r = bbp_parse_args( $args, array(
1470  
1471              // Support for get_posts()
1472              'post_type'          => bbp_get_forum_post_type(),
1473              'post_parent'        => null,
1474              'post_status'        => null,
1475              'selected'           => 0,
1476              'include'            => array(),
1477              'exclude'            => array(),
1478              'numberposts'        => -1,
1479              'orderby'            => 'menu_order title',
1480              'order'              => 'ASC',
1481  
1482              // Preloaded content
1483              'posts'              => array(),
1484  
1485              // Custom hierarchy walkers
1486              'walker'             => '',
1487  
1488              // Output-related
1489              'select_id'          => 'bbp_forum_id',
1490              'select_class'       => 'bbp_dropdown',
1491              'tab'                => false,
1492              'options_only'       => false,
1493              'show_none'          => false,
1494              'disable_categories' => true,
1495              'disabled'           => ''
1496          ), 'get_dropdown' );
1497  
1498          // Fallback to our walker
1499          if ( empty( $r['walker'] ) ) {
1500              $r['walker']            = new BBP_Walker_Dropdown();
1501              $r['walker']->tree_type = $r['post_type'];
1502          }
1503  
1504          // Force 0
1505          if ( is_numeric( $r['selected'] ) && ( $r['selected'] < 0 ) ) {
1506              $r['selected'] = 0;
1507          }
1508  
1509          // Force array
1510          if ( ! empty( $r['include'] ) && ! is_array( $r['include'] ) ) {
1511              $r['include'] = explode( ',', $r['include'] );
1512          }
1513  
1514          // Force array
1515          if ( ! empty( $r['exclude'] ) && ! is_array( $r['exclude'] ) ) {
1516              $r['exclude'] = explode( ',', $r['exclude'] );
1517          }
1518  
1519          /** Setup Posts *******************************************************/
1520  
1521          /**
1522           * Allow passing of custom posts data
1523           *
1524           * @see bbp_get_reply_to_dropdown() as an example
1525           */
1526          if ( empty( $r['posts'] ) ) {
1527              $r['posts'] = get_posts( array(
1528                  'post_type'   => $r['post_type'],
1529                  'post_status' => $r['post_status'],
1530                  'post_parent' => $r['post_parent'],
1531                  'include'     => $r['include'],
1532                  'exclude'     => $r['exclude'],
1533                  'numberposts' => $r['numberposts'],
1534                  'orderby'     => $r['orderby'],
1535                  'order'       => $r['order'],
1536              ) );
1537          }
1538  
1539          /** Drop Down *********************************************************/
1540  
1541          // Build the opening tag for the select element
1542          if ( empty( $r['options_only'] ) ) {
1543  
1544              // Should this select appear disabled?
1545              $disabled  = disabled( isset( bbpress()->options[ $r['disabled'] ] ), true, false );
1546  
1547              // Setup the tab index attribute
1548              $tab       = ! empty( $r['tab'] ) ? ' tabindex="' . intval( $r['tab'] ) . '"' : '';
1549  
1550              // Open the select tag
1551              $retval   .= '<select name="' . esc_attr( $r['select_id'] ) . '" id="' . esc_attr( $r['select_id'] ) . '" class="' . esc_attr( $r['select_class'] ) . '"' . $disabled . $tab . '>' . "\n";
1552          }
1553  
1554          // Display a leading 'no-value' option, with or without custom text
1555          if ( ! empty( $r['show_none'] ) || ! empty( $r['none_found'] ) ) {
1556  
1557              // Open the 'no-value' option tag
1558              $retval .= "\t<option value=\"\" class=\"level-0\">";
1559  
1560              // Use deprecated 'none_found' first for backpat
1561              if ( ! empty( $r['none_found'] ) && is_string( $r['none_found'] ) ) {
1562                  $retval .= esc_html( $r['none_found'] );
1563  
1564              // Use 'show_none' second
1565              } elseif ( ! empty( $r['show_none'] ) && is_string( $r['show_none'] ) ) {
1566                  $retval .= esc_html( $r['show_none'] );
1567  
1568              // Otherwise, make some educated guesses
1569              } else {
1570  
1571                  // Switch the response based on post type
1572                  switch ( $r['post_type'] ) {
1573  
1574                      // Topics
1575                      case bbp_get_topic_post_type() :
1576                          $retval .= esc_html__( 'No topics available', 'bbpress' );
1577                          break;
1578  
1579                      // Forums
1580                      case bbp_get_forum_post_type() :
1581                          $retval .= esc_html__( 'No forums available', 'bbpress' );
1582                          break;
1583  
1584                      // Any other
1585                      default :
1586                          $retval .= esc_html__( 'None available', 'bbpress' );
1587                          break;
1588                  }
1589              }
1590  
1591              // Close the 'no-value' option tag
1592              $retval .= '</option>';
1593          }
1594  
1595          // Items found so walk the tree
1596          if ( ! empty( $r['posts'] ) ) {
1597              $retval .= walk_page_dropdown_tree( $r['posts'], 0, $r );
1598          }
1599  
1600          // Close the selecet tag
1601          if ( empty( $r['options_only'] ) ) {
1602              $retval .= '</select>';
1603          }
1604  
1605          // Filter & return
1606          return apply_filters( 'bbp_get_dropdown', $retval, $r, $args );
1607      }
1608  
1609  /**
1610   * Output the required hidden fields when creating/editing a forum
1611   *
1612   * @since 2.1.0 bbPress (r3553)
1613   */
1614  function bbp_forum_form_fields() {
1615  
1616      if ( bbp_is_forum_edit() ) : ?>
1617  
1618          <input type="hidden" name="action"       id="bbp_post_action" value="bbp-edit-forum" />
1619          <input type="hidden" name="bbp_forum_id" id="bbp_forum_id"    value="<?php bbp_forum_id(); ?>" />
1620  
1621          <?php if ( current_user_can( 'unfiltered_html' ) ) :
1622              wp_nonce_field( 'bbp-unfiltered-html-forum_' . bbp_get_forum_id(), '_bbp_unfiltered_html_forum', false );
1623          endif; ?>
1624  
1625          <?php wp_nonce_field( 'bbp-edit-forum_' . bbp_get_forum_id() );
1626  
1627      else :
1628  
1629          if ( bbp_is_single_forum() ) : ?>
1630  
1631              <input type="hidden" name="bbp_forum_parent_id" id="bbp_forum_parent_id" value="<?php bbp_forum_parent_id(); ?>" />
1632  
1633          <?php endif; ?>
1634  
1635          <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-forum" />
1636  
1637          <?php if ( current_user_can( 'unfiltered_html' ) ) :
1638              wp_nonce_field( 'bbp-unfiltered-html-forum_new', '_bbp_unfiltered_html_forum', false );
1639          endif; ?>
1640  
1641          <?php wp_nonce_field( 'bbp-new-forum' );
1642  
1643      endif;
1644  }
1645  
1646  /**
1647   * Output the required hidden fields when creating/editing a topic
1648   *
1649   * @since 2.0.0 bbPress (r2753)
1650   */
1651  function bbp_topic_form_fields() {
1652  
1653      if ( bbp_is_topic_edit() ) : ?>
1654  
1655          <input type="hidden" name="action"       id="bbp_post_action" value="bbp-edit-topic" />
1656          <input type="hidden" name="bbp_topic_id" id="bbp_topic_id"    value="<?php bbp_topic_id(); ?>" />
1657  
1658          <?php if ( current_user_can( 'unfiltered_html' ) ) :
1659              wp_nonce_field( 'bbp-unfiltered-html-topic_' . bbp_get_topic_id(), '_bbp_unfiltered_html_topic', false );
1660          endif; ?>
1661  
1662          <?php wp_nonce_field( 'bbp-edit-topic_' . bbp_get_topic_id() );
1663  
1664      else :
1665  
1666          if ( bbp_is_single_forum() ) : ?>
1667  
1668              <input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="<?php bbp_forum_id(); ?>" />
1669  
1670          <?php endif; ?>
1671  
1672          <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-topic" />
1673  
1674          <?php if ( current_user_can( 'unfiltered_html' ) ) :
1675              wp_nonce_field( 'bbp-unfiltered-html-topic_new', '_bbp_unfiltered_html_topic', false );
1676          endif; ?>
1677  
1678          <?php wp_nonce_field( 'bbp-new-topic' );
1679  
1680      endif;
1681  }
1682  
1683  /**
1684   * Output the required hidden fields when creating/editing a reply
1685   *
1686   * @since 2.0.0 bbPress (r2753)
1687   */
1688  function bbp_reply_form_fields() {
1689  
1690      if ( bbp_is_reply_edit() ) : ?>
1691  
1692          <input type="hidden" name="bbp_reply_id"    id="bbp_reply_id"    value="<?php bbp_reply_id(); ?>" />
1693          <input type="hidden" name="action"          id="bbp_post_action" value="bbp-edit-reply" />
1694  
1695          <?php if ( current_user_can( 'unfiltered_html' ) ) :
1696              wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_reply_id(), '_bbp_unfiltered_html_reply', false );
1697          endif; ?>
1698  
1699          <?php wp_nonce_field( 'bbp-edit-reply_' . bbp_get_reply_id() );
1700  
1701      else : ?>
1702  
1703          <input type="hidden" name="bbp_topic_id"    id="bbp_topic_id"    value="<?php bbp_topic_id(); ?>" />
1704          <input type="hidden" name="bbp_reply_to"    id="bbp_reply_to"    value="<?php bbp_form_reply_to(); ?>" />
1705          <input type="hidden" name="action"          id="bbp_post_action" value="bbp-new-reply" />
1706  
1707          <?php if ( current_user_can( 'unfiltered_html' ) ) :
1708              wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_topic_id(), '_bbp_unfiltered_html_reply', false );
1709          endif; ?>
1710  
1711          <?php wp_nonce_field( 'bbp-new-reply' );
1712  
1713          // Show redirect field if not viewing a specific topic
1714          if ( bbp_is_query_name( 'bbp_single_topic' ) ) :
1715              $redirect_to = apply_filters( 'bbp_reply_form_redirect_to', get_permalink() );
1716              bbp_redirect_to_field( $redirect_to );
1717          endif;
1718      endif;
1719  }
1720  
1721  /**
1722   * Output the required hidden fields when editing a user
1723   *
1724   * @since 2.0.0 bbPress (r2690)
1725   */
1726  function bbp_edit_user_form_fields() {
1727  ?>
1728  
1729      <input type="hidden" name="action"  id="bbp_post_action" value="bbp-update-user" />
1730      <input type="hidden" name="user_id" id="user_id"         value="<?php bbp_displayed_user_id(); ?>" />
1731  
1732      <?php wp_nonce_field( 'update-user_' . bbp_get_displayed_user_id() );
1733  }
1734  
1735  /**
1736   * Merge topic form fields
1737   *
1738   * Output the required hidden fields when merging a topic
1739   *
1740   * @since 2.0.0 bbPress (r2756)
1741   */
1742  function bbp_merge_topic_form_fields() {
1743  ?>
1744  
1745      <input type="hidden" name="action"       id="bbp_post_action" value="bbp-merge-topic" />
1746      <input type="hidden" name="bbp_topic_id" id="bbp_topic_id"    value="<?php bbp_topic_id(); ?>" />
1747  
1748      <?php wp_nonce_field( 'bbp-merge-topic_' . bbp_get_topic_id() );
1749  }
1750  
1751  /**
1752   * Split topic form fields
1753   *
1754   * Output the required hidden fields when splitting a topic
1755   *
1756   * @since 2.0.0 bbPress (r2756)
1757   */
1758  function bbp_split_topic_form_fields() {
1759  ?>
1760  
1761      <input type="hidden" name="action"       id="bbp_post_action" value="bbp-split-topic" />
1762      <input type="hidden" name="bbp_reply_id" id="bbp_reply_id"    value="<?php echo intval( $_GET['reply_id'] ); ?>" />
1763  
1764      <?php wp_nonce_field( 'bbp-split-topic_' . bbp_get_topic_id() );
1765  }
1766  
1767  /**
1768   * Move reply form fields
1769   *
1770   * Output the required hidden fields when moving a reply
1771   */
1772  function bbp_move_reply_form_fields() {
1773  ?>
1774  
1775      <input type="hidden" name="action"       id="bbp_post_action" value="bbp-move-reply" />
1776      <input type="hidden" name="bbp_reply_id" id="bbp_reply_id"    value="<?php echo intval( $_GET['reply_id'] ); ?>" />
1777  
1778      <?php wp_nonce_field( 'bbp-move-reply_' . bbp_get_reply_id() );
1779  }
1780  
1781  /**
1782   * Output a textarea or TinyMCE if enabled
1783   *
1784   * @since 2.1.0 bbPress (r3586)
1785   *
1786   * @param array $args
1787   */
1788  function bbp_the_content( $args = array() ) {
1789      echo bbp_get_the_content( $args );
1790  }
1791      /**
1792       * Return a textarea or TinyMCE if enabled
1793       *
1794       * @since 2.1.0 bbPress (r3586)
1795       *
1796       * @param array $args
1797       *
1798       * @return string HTML from output buffer
1799       */
1800  	function bbp_get_the_content( $args = array() ) {
1801  
1802          // Parse arguments against default values
1803          $r = bbp_parse_args( $args, array(
1804              'context'           => 'topic',
1805              'before'            => '<div class="bbp-the-content-wrapper">',
1806              'after'             => '</div>',
1807              'wpautop'           => true,
1808              'media_buttons'     => false,
1809              'textarea_rows'     => '12',
1810              'tabindex'          => false,
1811              'tabfocus_elements' => 'bbp_topic_title,bbp_topic_tags',
1812              'editor_class'      => 'bbp-the-content',
1813              'tinymce'           => false,
1814              'teeny'             => true,
1815              'quicktags'         => true,
1816              'dfw'               => false
1817          ), 'get_the_content' );
1818  
1819          // If using tinymce, remove our escaping and trust tinymce
1820          if ( bbp_use_wp_editor() && ( false !== $r['tinymce'] ) ) {
1821              remove_filter( 'bbp_get_form_forum_content', 'esc_textarea' );
1822              remove_filter( 'bbp_get_form_topic_content', 'esc_textarea' );
1823              remove_filter( 'bbp_get_form_reply_content', 'esc_textarea' );
1824          }
1825  
1826          // Assume we are not editing
1827          $post_content = call_user_func( 'bbp_get_form_' . $r['context'] . '_content' );
1828  
1829          // Start an output buffor
1830          ob_start();
1831  
1832          // Output something before the editor
1833          if ( ! empty( $r['before'] ) ) {
1834              echo $r['before'];
1835          }
1836  
1837          // Use TinyMCE if available
1838          if ( bbp_use_wp_editor() ) :
1839  
1840              // Enable additional TinyMCE plugins before outputting the editor
1841              add_filter( 'tiny_mce_plugins',   'bbp_get_tiny_mce_plugins'   );
1842              add_filter( 'teeny_mce_plugins',  'bbp_get_tiny_mce_plugins'   );
1843              add_filter( 'teeny_mce_buttons',  'bbp_get_teeny_mce_buttons'  );
1844              add_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
1845  
1846              // Output the editor
1847              wp_editor( $post_content, 'bbp_' . $r['context'] . '_content', array(
1848                  'wpautop'           => $r['wpautop'],
1849                  'media_buttons'     => $r['media_buttons'],
1850                  'textarea_rows'     => $r['textarea_rows'],
1851                  'tabindex'          => $r['tabindex'],
1852                  'tabfocus_elements' => $r['tabfocus_elements'],
1853                  'editor_class'      => $r['editor_class'],
1854                  'tinymce'           => $r['tinymce'],
1855                  'teeny'             => $r['teeny'],
1856                  'quicktags'         => $r['quicktags'],
1857                  'dfw'               => $r['dfw'],
1858              ) );
1859  
1860              // Remove additional TinyMCE plugins after outputting the editor
1861              remove_filter( 'tiny_mce_plugins',   'bbp_get_tiny_mce_plugins'   );
1862              remove_filter( 'teeny_mce_plugins',  'bbp_get_tiny_mce_plugins'   );
1863              remove_filter( 'teeny_mce_buttons',  'bbp_get_teeny_mce_buttons'  );
1864              remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
1865  
1866          /**
1867           * Fallback to normal textarea.
1868           *
1869           * Note that we do not use esc_textarea() here to prevent double
1870           * escaping the editable output, mucking up existing content.
1871           */
1872          else : ?>
1873  
1874              <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>
1875  
1876          <?php endif;
1877  
1878          // Output something after the editor
1879          if ( ! empty( $r['after'] ) ) {
1880              echo $r['after'];
1881          }
1882  
1883          // Put the output into a usable variable
1884          $output = ob_get_clean();
1885  
1886          // Filter & return
1887          return apply_filters( 'bbp_get_the_content', $output, $args, $post_content );
1888      }
1889  
1890  /**
1891   * Edit TinyMCE plugins to match core behaviour
1892   *
1893   * @since 2.3.0 bbPress (r4574)
1894   *
1895   * @param array $plugins
1896   * @see tiny_mce_plugins, teeny_mce_plugins
1897   * @return array
1898   */
1899  function bbp_get_tiny_mce_plugins( $plugins = array() ) {
1900  
1901      // Unset fullscreen
1902      foreach ( $plugins as $key => $value ) {
1903          if ( 'fullscreen' === $value ) {
1904              unset( $plugins[ $key ] );
1905              break;
1906          }
1907      }
1908  
1909      // Add the tabfocus plugin
1910      $plugins[] = 'tabfocus';
1911  
1912      // Filter & return
1913      return apply_filters( 'bbp_get_tiny_mce_plugins', $plugins );
1914  }
1915  
1916  /**
1917   * Edit TeenyMCE buttons to match allowedtags
1918   *
1919   * @since 2.3.0 bbPress (r4605)
1920   *
1921   * @param array $buttons
1922   * @see teeny_mce_buttons
1923   * @return array
1924   */
1925  function bbp_get_teeny_mce_buttons( $buttons = array() ) {
1926  
1927      // Remove some buttons from TeenyMCE
1928      $buttons = array_diff( $buttons, array(
1929          'underline',
1930          'justifyleft',
1931          'justifycenter',
1932          'justifyright'
1933      ) );
1934  
1935      // Images
1936      array_push( $buttons, 'image' );
1937  
1938      // Filter & return
1939      return apply_filters( 'bbp_get_teeny_mce_buttons', $buttons );
1940  }
1941  
1942  /**
1943   * Edit TinyMCE quicktags buttons to match allowedtags
1944   *
1945   * @since 2.3.0 bbPress (r4606)
1946   *
1947   * @param array $settings
1948   * @see quicktags_settings
1949   * @return array Quicktags settings
1950   */
1951  function bbp_get_quicktags_settings( $settings = array() ) {
1952  
1953      // Get buttons out of settings
1954      $buttons_array = explode( ',', $settings['buttons'] );
1955  
1956      // Diff the ones we don't want out
1957      $buttons = array_diff( $buttons_array, array(
1958          'ins',
1959          'more',
1960          'spell'
1961      ) );
1962  
1963      // Put them back into a string in the $settings array
1964      $settings['buttons'] = implode( ',', $buttons );
1965  
1966      // Filter & return
1967      return apply_filters( 'bbp_get_quicktags_settings', $settings );
1968  }
1969  
1970  /** Views *********************************************************************/
1971  
1972  /**
1973   * Output the view id
1974   *
1975   * @since 2.0.0 bbPress (r2789)
1976   *
1977   * @param string $view Optional. View id
1978   */
1979  function bbp_view_id( $view = '' ) {
1980      echo bbp_get_view_id( $view );
1981  }
1982  
1983      /**
1984       * Get the view id
1985       *
1986       * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var.
1987       *
1988       * @since 2.0.0 bbPress (r2789)
1989       *
1990       * @param string $view Optional. View id.
1991       * @return bool|string ID on success, false on failure
1992       */
1993  	function bbp_get_view_id( $view = '' ) {
1994          $bbp = bbpress();
1995  
1996          // User supplied string
1997          if ( ! empty( $view ) ) {
1998              $view_id = sanitize_key( $view );
1999  
2000          // Current view ID
2001          } elseif ( ! empty( $bbp->current_view_id ) ) {
2002              $view_id = $bbp->current_view_id;
2003  
2004          // Querying for view
2005          } else {
2006              $view_id = get_query_var( bbp_get_view_rewrite_id() );
2007          }
2008  
2009          // Filter & return
2010          return apply_filters( 'bbp_get_view_id', $view_id, $view );
2011      }
2012  
2013  /**
2014   * Output the view name aka title
2015   *
2016   * @since 2.0.0 bbPress (r2789)
2017   *
2018   * @param string $view Optional. View id
2019   */
2020  function bbp_view_title( $view = '' ) {
2021      echo bbp_get_view_title( $view );
2022  }
2023  
2024      /**
2025       * Get the view name aka title
2026       *
2027       * If a view id is supplied, that is used. Otherwise the bbp_view
2028       * query var is checked for.
2029       *
2030       * @since 2.0.0 bbPress (r2789)
2031       *
2032       * @param string $view Optional. View id
2033       * @return bool|string Title on success, false on failure
2034       */
2035  	function bbp_get_view_title( $view = '' ) {
2036          $bbp = bbpress();
2037  
2038          $view = bbp_get_view_id( $view );
2039          if ( empty( $view ) ) {
2040              return false;
2041          }
2042  
2043          return $bbp->views[ $view ]['title'];
2044      }
2045  
2046  /**
2047   * Output the view url
2048   *
2049   * @since 2.0.0 bbPress (r2789)
2050   *
2051   * @param string $view Optional. View id
2052   */
2053  function bbp_view_url( $view = false ) {
2054      echo esc_url( bbp_get_view_url( $view ) );
2055  }
2056      /**
2057       * Return the view url
2058       *
2059       * @since 2.0.0 bbPress (r2789)
2060       *
2061       * @param string $view Optional. View id
2062       *                        used view id
2063       * @return string View url (or home url if the view was not found)
2064       */
2065  	function bbp_get_view_url( $view = false ) {
2066  
2067          $view = bbp_get_view_id( $view );
2068          if ( empty( $view ) ) {
2069              return home_url();
2070          }
2071  
2072          // Pretty permalinks
2073          if ( bbp_use_pretty_urls() ) {
2074  
2075              // Run through home_url()
2076              $url = trailingslashit( bbp_get_root_url() . bbp_get_view_slug() ) . $view;
2077              $url = user_trailingslashit( $url );
2078              $url = home_url( $url );
2079  
2080          // Unpretty permalinks
2081          } else {
2082              $url = add_query_arg( array(
2083                  bbp_get_view_rewrite_id() => $view
2084              ), home_url( '/' ) );
2085          }
2086  
2087          // Filter & return
2088          return apply_filters( 'bbp_get_view_link', $url, $view );
2089      }
2090  
2091  /** Query *********************************************************************/
2092  
2093  /**
2094   * Check the passed parameter against the current _bbp_query_name
2095   *
2096   * @since 2.0.0 bbPress (r2980)
2097   *
2098   * @return bool True if match, false if not
2099   */
2100  function bbp_is_query_name( $name = '' ) {
2101      return (bool) ( bbp_get_query_name() === $name );
2102  }
2103  
2104  /**
2105   * Get the '_bbp_query_name' setting
2106   *
2107   * @since 2.0.0 bbPress (r2695)
2108   *
2109   * @return string To return the query var value
2110   */
2111  function bbp_get_query_name() {
2112      return get_query_var( '_bbp_query_name' );
2113  }
2114  
2115  /**
2116   * Set the '_bbp_query_name' setting to $name
2117   *
2118   * @since 2.0.0 bbPress (r2692)
2119   *
2120   * @param string $name What to set the query var to
2121   */
2122  function bbp_set_query_name( $name = '' ) {
2123      set_query_var( '_bbp_query_name', $name );
2124  }
2125  
2126  /**
2127   * Used to clear the '_bbp_query_name' setting
2128   *
2129   * @since 2.0.0 bbPress (r2692)
2130   *
2131   */
2132  function bbp_reset_query_name() {
2133      bbp_set_query_name();
2134  }
2135  
2136  /** Breadcrumbs ***************************************************************/
2137  
2138  /**
2139   * Output the page title as a breadcrumb
2140   *
2141   * @since 2.0.0 bbPress (r2589)
2142   *
2143   * @param string $sep Separator. Defaults to '&larr;'
2144   * @param bool $current_page Include the current item
2145   * @param bool $root Include the root page if one exists
2146   */
2147  function bbp_title_breadcrumb( $args = array() ) {
2148      echo bbp_get_breadcrumb( $args );
2149  }
2150  
2151  /**
2152   * Output a breadcrumb
2153   *
2154   * @since 2.0.0 bbPress (r2589)
2155   *
2156   * @param string $sep Separator. Defaults to '&larr;'
2157   * @param bool $current_page Include the current item
2158   * @param bool $root Include the root page if one exists
2159   */
2160  function bbp_breadcrumb( $args = array() ) {
2161      echo bbp_get_breadcrumb( $args );
2162  }
2163      /**
2164       * Return a breadcrumb ( forum -> topic -> reply )
2165       *
2166       * @since 2.0.0 bbPress (r2589)
2167       *
2168       * @param string $sep Separator. Defaults to '&larr;'
2169       * @param bool $current_page Include the current item
2170       * @param bool $root Include the root page if one exists
2171       *
2172       * @return string Breadcrumbs
2173       */
2174  	function bbp_get_breadcrumb( $args = array() ) {
2175  
2176          // Turn off breadcrumbs
2177          if ( apply_filters( 'bbp_no_breadcrumb', is_front_page() ) ) {
2178              return;
2179          }
2180  
2181          // Define variables
2182          $front_id         = $root_id                                 = 0;
2183          $ancestors        = $crumbs           = $tag_data            = array();
2184          $pre_root_text    = $pre_front_text   = $pre_current_text    = '';
2185          $pre_include_root = $pre_include_home = $pre_include_current = true;
2186  
2187          /** Home Text *********************************************************/
2188  
2189          // No custom home text
2190          if ( empty( $args['home_text'] ) ) {
2191  
2192              $front_id = get_option( 'page_on_front' );
2193  
2194              // Set home text to page title
2195              if ( ! empty( $front_id ) ) {
2196                  $pre_front_text = get_the_title( $front_id );
2197  
2198              // Default to 'Home'
2199              } else {
2200                  $pre_front_text = esc_html__( 'Home', 'bbpress' );
2201              }
2202          }
2203  
2204          /** Root Text *********************************************************/
2205  
2206          // No custom root text
2207          if ( empty( $args['root_text'] ) ) {
2208              $page = bbp_get_page_by_path( bbp_get_root_slug() );
2209              if ( ! empty( $page ) ) {
2210                  $root_id = $page->ID;
2211              }
2212              $pre_root_text = bbp_get_forum_archive_title();
2213          }
2214  
2215          /** Includes **********************************************************/
2216  
2217          // Root slug is also the front page
2218          if ( ! empty( $front_id ) && ( $front_id === $root_id ) ) {
2219              $pre_include_root = false;
2220          }
2221  
2222          // Don't show root if viewing forum archive
2223          if ( bbp_is_forum_archive() ) {
2224              $pre_include_root = false;
2225          }
2226  
2227          // Don't show root if viewing page in place of forum archive
2228          if ( ! empty( $root_id ) && ( ( is_single() || is_page() ) && ( $root_id === get_the_ID() ) ) ) {
2229              $pre_include_root = false;
2230          }
2231  
2232          /** Current Text ******************************************************/
2233  
2234          // Search page
2235          if ( bbp_is_search() ) {
2236              $pre_current_text = bbp_get_search_title();
2237  
2238          // Forum archive
2239          } elseif ( bbp_is_forum_archive() ) {
2240              $pre_current_text = bbp_get_forum_archive_title();
2241  
2242          // Topic archive
2243          } elseif ( bbp_is_topic_archive() ) {
2244              $pre_current_text = bbp_get_topic_archive_title();
2245  
2246          // View
2247          } elseif ( bbp_is_single_view() ) {
2248              $pre_current_text = bbp_get_view_title();
2249  
2250          // Single Forum
2251          } elseif ( bbp_is_single_forum() ) {
2252              $pre_current_text = bbp_get_forum_title();
2253  
2254          // Single Topic
2255          } elseif ( bbp_is_single_topic() ) {
2256              $pre_current_text = bbp_get_topic_title();
2257  
2258          // Single Topic
2259          } elseif ( bbp_is_single_reply() ) {
2260              $pre_current_text = bbp_get_reply_title();
2261  
2262          // Topic Tag (or theme compat topic tag)
2263          } elseif ( bbp_is_topic_tag() || ( get_query_var( 'bbp_topic_tag' ) && ! bbp_is_topic_tag_edit() ) ) {
2264  
2265              // Always include the tag name
2266              $tag_data[] = bbp_get_topic_tag_name();
2267  
2268              // If capable, include a link to edit the tag
2269              if ( current_user_can( 'manage_topic_tags' ) ) {
2270                  $tag_data[] = '<a href="' . esc_url( bbp_get_topic_tag_edit_link() ) . '" class="bbp-edit-topic-tag-link">' . esc_html__( '(Edit)', 'bbpress' ) . '</a>';
2271              }
2272  
2273              // Implode the results of the tag data
2274              $pre_current_text = sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), implode( ' ', $tag_data ) );
2275  
2276          // Edit Topic Tag
2277          } elseif ( bbp_is_topic_tag_edit() ) {
2278              $pre_current_text = esc_html__( 'Edit', 'bbpress' );
2279  
2280          // Single
2281          } else {
2282              $pre_current_text = get_the_title();
2283          }
2284  
2285          /** Parse Args ********************************************************/
2286  
2287          // Parse args
2288          $r = bbp_parse_args( $args, array(
2289  
2290              // HTML
2291              'before'          => '<div class="bbp-breadcrumb"><p>',
2292              'after'           => '</p></div>',
2293  
2294              // Separator
2295              'sep'             => is_rtl() ? __( '&lsaquo;', 'bbpress' ) : __( '&rsaquo;', 'bbpress' ),
2296              'pad_sep'         => 1,
2297              'sep_before'      => '<span class="bbp-breadcrumb-sep">',
2298              'sep_after'       => '</span>',
2299  
2300              // Crumbs
2301              'crumb_before'    => '',
2302              'crumb_after'     => '',
2303  
2304              // Home
2305              'include_home'    => $pre_include_home,
2306              'home_text'       => $pre_front_text,
2307  
2308              // Forum root
2309              'include_root'    => $pre_include_root,
2310              'root_text'       => $pre_root_text,
2311  
2312              // Current
2313              'include_current' => $pre_include_current,
2314              'current_text'    => $pre_current_text,
2315              'current_before'  => '<span class="bbp-breadcrumb-current">',
2316              'current_after'   => '</span>',
2317          ), 'get_breadcrumb' );
2318  
2319          /** Ancestors *********************************************************/
2320  
2321          // Get post ancestors
2322          if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() ) {
2323              $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) );
2324          }
2325  
2326          // Do we want to include a link to home?
2327          if ( ! empty( $r['include_home'] ) || empty( $r['home_text'] ) ) {
2328              $crumbs[] = '<a href="' . esc_url( home_url() ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';
2329          }
2330  
2331          // Do we want to include a link to the forum root?
2332          if ( ! empty( $r['include_root'] ) || empty( $r['root_text'] ) ) {
2333  
2334              // Page exists at root slug path, so use its permalink
2335              $page = bbp_get_page_by_path( bbp_get_root_slug() );
2336              if ( ! empty( $page ) ) {
2337                  $root_url = get_permalink( $page->ID );
2338  
2339              // Use the root slug
2340              } else {
2341                  $root_url = get_post_type_archive_link( bbp_get_forum_post_type() );
2342              }
2343  
2344              // Add the breadcrumb
2345              $crumbs[] = '<a href="' . esc_url( $root_url ) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>';
2346          }
2347  
2348          // Ancestors exist
2349          if ( ! empty( $ancestors ) ) {
2350  
2351              // Loop through parents
2352              foreach ( (array) $ancestors as $parent_id ) {
2353  
2354                  // Parents
2355                  $parent = get_post( $parent_id );
2356  
2357                  // Skip parent if empty or error
2358                  if ( empty( $parent ) || is_wp_error( $parent ) ) {
2359                      continue;
2360                  }
2361  
2362                  // Switch through post_type to ensure correct filters are applied
2363                  switch ( $parent->post_type ) {
2364  
2365                      // Forum
2366                      case bbp_get_forum_post_type() :
2367                          $crumbs[] = '<a href="' . esc_url( bbp_get_forum_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $parent->ID ) . '</a>';
2368                          break;
2369  
2370                      // Topic
2371                      case bbp_get_topic_post_type() :
2372                          $crumbs[] = '<a href="' . esc_url( bbp_get_topic_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>';
2373                          break;
2374  
2375                      // Reply (Note: not in most themes)
2376                      case bbp_get_reply_post_type() :
2377                          $crumbs[] = '<a href="' . esc_url( bbp_get_reply_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>';
2378                          break;
2379  
2380                      // WordPress Post/Page/Other
2381                      default :
2382                          $crumbs[] = '<a href="' . esc_url( get_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-item">' . get_the_title( $parent->ID ) . '</a>';
2383                          break;
2384                  }
2385              }
2386  
2387          // Edit topic tag
2388          } elseif ( bbp_is_topic_tag_edit() ) {
2389              $crumbs[] = '<a href="' . esc_url( get_term_link( bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id() ) ) . '" class="bbp-breadcrumb-topic-tag">' . sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ) . '</a>';
2390  
2391          // Search
2392          } elseif ( bbp_is_search() && bbp_get_search_terms() ) {
2393              $crumbs[] = '<a href="' . esc_url( bbp_get_search_url() ) . '" class="bbp-breadcrumb-search">' . esc_html__( 'Search', 'bbpress' ) . '</a>';
2394          }
2395  
2396          /** Current ***********************************************************/
2397  
2398          // Add current page to breadcrumb
2399          if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) {
2400              $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after'];
2401          }
2402  
2403          /** Separator *********************************************************/
2404  
2405          // Wrap the separator in before/after before padding and filter
2406          if ( ! empty( $r['sep'] ) ) {
2407              $sep = $r['sep_before'] . $r['sep'] . $r['sep_after'];
2408          } else {
2409              $sep = '';
2410          }
2411  
2412          // Pad the separator
2413          if ( ! empty( $r['pad_sep'] ) ) {
2414              if ( function_exists( 'mb_strlen' ) ) {
2415                  $sep = str_pad( $sep, mb_strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH );
2416              } else {
2417                  $sep = str_pad( $sep, strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH );
2418              }
2419          }
2420  
2421          /** Finish Up *********************************************************/
2422  
2423          // Filter the separator and breadcrumb
2424          $sep    = apply_filters( 'bbp_breadcrumb_separator', $sep    );
2425          $crumbs = apply_filters( 'bbp_breadcrumbs',          $crumbs );
2426  
2427          // Build the trail
2428          $trail  = ! empty( $crumbs ) ? ( $r['before'] . $r['crumb_before'] . implode( $sep . $r['crumb_after'] . $r['crumb_before'], $crumbs ) . $r['crumb_after'] . $r['after'] ) : '';
2429  
2430          // Filter & return
2431          return apply_filters( 'bbp_get_breadcrumb', $trail, $crumbs, $r, $args );
2432      }
2433  
2434  /** Topic Tags ***************************************************************/
2435  
2436  /**
2437   * Output all of the allowed tags in HTML format with attributes.
2438   *
2439   * This is useful for displaying in the post area, which elements and
2440   * attributes are supported. As well as any plugins which want to display it.
2441   *
2442   * @since 2.0.0 bbPress (r2780)
2443   */
2444  function bbp_allowed_tags() {
2445      echo bbp_get_allowed_tags();
2446  }
2447      /**
2448       * Display all of the allowed tags in HTML format with attributes.
2449       *
2450       * This is useful for displaying in the post area, which elements and
2451       * attributes are supported. As well as any plugins which want to display it.
2452       *
2453       * @since 2.0.0 bbPress (r2780)
2454       *
2455       * @return string HTML allowed tags entity encoded.
2456       */
2457  	function bbp_get_allowed_tags() {
2458  
2459          $allowed = '';
2460  
2461          foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) {
2462              $allowed .= '<' . $tag;
2463              if ( 0 < count( $attributes ) ) {
2464                  foreach ( array_keys( $attributes ) as $attribute ) {
2465                      $allowed .= ' ' . $attribute . '=""';
2466                  }
2467              }
2468              $allowed .= '> ';
2469          }
2470  
2471          // Filter & return
2472          return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) );
2473      }
2474  
2475  /** Errors & Messages *********************************************************/
2476  
2477  /**
2478   * Display possible errors & messages inside a template file
2479   *
2480   * @since 2.0.0 bbPress (r2688)
2481   */
2482  function bbp_template_notices() {
2483  
2484      // Bail if no notices or errors
2485      if ( ! bbp_has_errors() ) {
2486          return;
2487      }
2488  
2489      // Define local variable(s)
2490      $errors = $messages = array();
2491  
2492      // Get bbPress
2493      $bbp = bbpress();
2494  
2495      // Loop through notices
2496      foreach ( $bbp->errors->get_error_codes() as $code ) {
2497  
2498          // Get notice severity
2499          $severity = $bbp->errors->get_error_data( $code );
2500  
2501          // Loop through notices and separate errors from messages
2502          foreach ( $bbp->errors->get_error_messages( $code ) as $error ) {
2503              if ( 'message' === $severity ) {
2504                  $messages[] = $error;
2505              } else {
2506                  $errors[]   = $error;
2507              }
2508          }
2509      }
2510  
2511      // Display errors first...
2512      if ( ! empty( $errors ) ) : ?>
2513  
2514          <div class="bbp-template-notice error" role="alert" tabindex="-1">
2515              <ul>
2516                  <li><?php echo implode( "</li>\n<li>", $errors ); ?></li>
2517              </ul>
2518          </div>
2519  
2520      <?php endif;
2521  
2522      // ...and messages last
2523      if ( ! empty( $messages ) ) : ?>
2524  
2525          <div class="bbp-template-notice">
2526              <ul>
2527                  <li><?php echo implode( "</li>\n<li>", $messages ); ?></li>
2528              </ul>
2529          </div>
2530  
2531      <?php endif;
2532  }
2533  
2534  /** Login/logout/register/lost pass *******************************************/
2535  
2536  /**
2537   * Output the logout link
2538   *
2539   * @since 2.0.0 bbPress (r2827)
2540   *
2541   * @param string $redirect_to Redirect to url
2542   */
2543  function bbp_logout_link( $redirect_to = '' ) {
2544      echo bbp_get_logout_link( $redirect_to );
2545  }
2546      /**
2547       * Return the logout link
2548       *
2549       * @since 2.0.0 bbPress (r2827)
2550       *
2551       * @param string $redirect_to Redirect to url
2552       *                        redirect to url
2553       * @return string The logout link
2554       */
2555  	function bbp_get_logout_link( $redirect_to = '' ) {
2556  
2557          // Build the link
2558          $link = '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>';
2559  
2560          // Filter & return
2561          return apply_filters( 'bbp_get_logout_link', $link, $redirect_to );
2562      }
2563  
2564  /** Title *********************************************************************/
2565  
2566  /**
2567   * Custom page title for bbPress pages
2568   *
2569   * @since 2.0.0 bbPress (r2788)
2570   *
2571   * @param string $title Optional. The title (not used).
2572   * @param string $sep Optional, default is '&raquo;'. How to separate the
2573   *                     various items within the page title.
2574   * @param string $seplocation Optional. Direction to display title, 'right'.
2575   *                        separator and separator location
2576   * @return string The title
2577   */
2578  function bbp_title( $title = '', $sep = '&raquo;', $seplocation = '' ) {
2579  
2580      // Title array
2581      $new_title = array();
2582  
2583      /** Archives **************************************************************/
2584  
2585      // Forum Archive
2586      if ( bbp_is_forum_archive() ) {
2587          $new_title['text'] = bbp_get_forum_archive_title();
2588  
2589      // Topic Archive
2590      } elseif ( bbp_is_topic_archive() ) {
2591          $new_title['text'] = bbp_get_topic_archive_title();
2592  
2593      /** Edit ******************************************************************/
2594  
2595      // Forum edit page
2596      } elseif ( bbp_is_forum_edit() ) {
2597          $new_title['text']   = bbp_get_forum_title();
2598          $new_title['format'] = esc_attr__( 'Forum Edit: %s', 'bbpress' );
2599  
2600      // Topic edit page
2601      } elseif ( bbp_is_topic_edit() ) {
2602          $new_title['text']   = bbp_get_topic_title();
2603          $new_title['format'] = esc_attr__( 'Topic Edit: %s', 'bbpress' );
2604  
2605      // Reply edit page
2606      } elseif ( bbp_is_reply_edit() ) {
2607          $new_title['text']   = bbp_get_reply_title();
2608          $new_title['format'] = esc_attr__( 'Reply Edit: %s', 'bbpress' );
2609  
2610      // Topic tag edit page
2611      } elseif ( bbp_is_topic_tag_edit() ) {
2612          $new_title['text']   = bbp_get_topic_tag_name();
2613          $new_title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' );
2614  
2615      /** Singles ***************************************************************/
2616  
2617      // Forum page
2618      } elseif ( bbp_is_single_forum() ) {
2619          $new_title['text']   = bbp_get_forum_title();
2620          $new_title['format'] = esc_attr__( 'Forum: %s', 'bbpress' );
2621  
2622      // Topic page
2623      } elseif ( bbp_is_single_topic() ) {
2624          $new_title['text']   = bbp_get_topic_title();
2625          $new_title['format'] = esc_attr__( 'Topic: %s', 'bbpress' );
2626  
2627      // Replies
2628      } elseif ( bbp_is_single_reply() ) {
2629          $new_title['text']   = bbp_get_reply_title();
2630  
2631      // Topic tag page
2632      } elseif ( bbp_is_topic_tag() || get_query_var( 'bbp_topic_tag' ) ) {
2633          $new_title['text']   = bbp_get_topic_tag_name();
2634          $new_title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' );
2635  
2636      /** Users *****************************************************************/
2637  
2638      // Profile page
2639      } elseif ( bbp_is_single_user() ) {
2640  
2641          // Is user viewing their own profile?
2642          $is_user_home = bbp_is_user_home();
2643  
2644          // User topics created
2645          if ( bbp_is_single_user_topics() ) {
2646              if ( true === $is_user_home ) {
2647                  $new_title['text'] = esc_attr__( 'Your Topics', 'bbpress' );
2648              } else {
2649                  $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name;
2650                  /* translators: user's display name */
2651                  $new_title['format'] = esc_attr__( "%s's Topics", 'bbpress' );
2652              }
2653  
2654          // User replies created
2655          } elseif ( bbp_is_single_user_replies() ) {
2656              if ( true === $is_user_home ) {
2657                  $new_title['text'] = esc_attr__( 'Your Replies', 'bbpress' );
2658              } else {
2659                  $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name;
2660                  /* translators: user's display name */
2661                  $new_title['format'] = esc_attr__( "%s's Replies", 'bbpress' );
2662              }
2663  
2664          // User favorites
2665          } elseif ( bbp_is_favorites() ) {
2666              if ( true === $is_user_home ) {
2667                  $new_title['text'] = esc_attr__( 'Your Favorites', 'bbpress' );
2668              } else {
2669                  $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name;
2670                  /* translators: user's display name */
2671                  $new_title['format'] = esc_attr__( "%s's Favorites", 'bbpress' );
2672              }
2673  
2674          // User subscriptions
2675          } elseif ( bbp_is_subscriptions() ) {
2676              if ( true === $is_user_home ) {
2677                  $new_title['text'] = esc_attr__( 'Your Subscriptions', 'bbpress' );
2678              } else {
2679                  $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name;
2680                  /* translators: user's display name */
2681                  $new_title['format'] = esc_attr__( "%s's Subscriptions", 'bbpress' );
2682              }
2683  
2684          // User "home"
2685          } else {
2686              if ( true === $is_user_home ) {
2687                  $new_title['text'] = esc_attr__( 'Your Profile', 'bbpress' );
2688              } else {
2689                  $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name;
2690                  /* translators: user's display name */
2691                  $new_title['format'] = esc_attr__( "%s's Profile", 'bbpress' );
2692              }
2693          }
2694  
2695      // Profile edit page
2696      } elseif ( bbp_is_single_user_edit() ) {
2697  
2698          // Current user
2699          if ( bbp_is_user_home_edit() ) {
2700              $new_title['text']   = esc_attr__( 'Edit Your Profile', 'bbpress' );
2701  
2702          // Other user
2703          } else {
2704              $new_title['text']   = get_userdata( bbp_get_user_id() )->display_name;
2705              $new_title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' );
2706          }
2707  
2708      /** Views *****************************************************************/
2709  
2710      // Views
2711      } elseif ( bbp_is_single_view() ) {
2712          $new_title['text']   = bbp_get_view_title();
2713          $new_title['format'] = esc_attr__( 'View: %s', 'bbpress' );
2714  
2715      /** Search ****************************************************************/
2716  
2717      // Search
2718      } elseif ( bbp_is_search() ) {
2719          $new_title['text'] = bbp_get_search_title();
2720      }
2721  
2722      // This filter is deprecated. Use 'bbp_before_title_parse_args' instead.
2723      $new_title = apply_filters( 'bbp_raw_title_array', $new_title );
2724  
2725      // Set title array defaults
2726      $new_title = bbp_parse_args( $new_title, array(
2727          'text'   => $title,
2728          'format' => '%s'
2729      ), 'title' );
2730  
2731      // Get the formatted raw title
2732      $new_title = sprintf( $new_title['format'], $new_title['text'] );
2733  
2734      // Filter the raw title
2735      $new_title = apply_filters( 'bbp_raw_title', $new_title, $sep, $seplocation );
2736  
2737      // Compare new title with original title
2738      if ( $new_title === $title ) {
2739          return $title;
2740      }
2741  
2742      // Temporary separator, for accurate flipping, if necessary
2743      $t_sep  = '%WP_TITILE_SEP%';
2744      $prefix = '';
2745  
2746      if ( ! empty( $new_title ) ) {
2747          $prefix = " $sep ";
2748      }
2749  
2750      // sep on right, so reverse the order
2751      if ( 'right' === $seplocation ) {
2752          $new_title_array = array_reverse( explode( $t_sep, $new_title ) );
2753          $new_title       = implode( " $sep ", $new_title_array ) . $prefix;
2754  
2755      // sep on left, do not reverse
2756      } else {
2757          $new_title_array = explode( $t_sep, $new_title );
2758          $new_title       = $prefix . implode( " $sep ", $new_title_array );
2759      }
2760  
2761      // Filter & return
2762      return apply_filters( 'bbp_title', $new_title, $sep, $seplocation );
2763  }


Generated: Sat Jan 25 01:01:31 2020 Cross-referenced by PHPXref 0.7.1