document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /**
  2.  *  Add bbpress dropdown list of forums
  3.  */
  4. function prefix_bbpress_dropdown_forum_list() {
  5.     if( ( !$prefix_bbpress_dropdown_forum_list = get_transient( \'prefix_bbpress_dropdown_forum_list\' ) ) ) {
  6.             $query = new WP_Query( array(
  7.                 \'post_type\'           => bbp_get_forum_post_type(),
  8.                 \'post_status\'         => bbp_get_public_status_id(),
  9.                 \'ignore_sticky_posts\' => true,
  10.                 \'no_found_rows\'       => true,
  11.                 \'orderby\'             => \'menu_order title\',
  12.                 \'order\'               => \'ASC\',
  13.                 \'posts_per_page\'      => -1 //Set Unlimited number of posts
  14.             ) );
  15.  
  16.             // Bail if no posts
  17.             if ( ! $query->have_posts() ) {
  18.                 return;
  19.             }
  20.            
  21.             $prefix_bbpress_dropdown_forum_list = \'
  22.                <select id="select-theme" onChange="window.location.href=this.value">
  23.                    <option value="#">\' .esc_html__( \'Select a theme\', \'theme-palace\' ). \'</option>\';
  24.                
  25.                 while ( $query->have_posts() ) {
  26.                     $query->the_post();
  27.                    
  28.                     $forum_permalink     = bbp_get_forum_permalink( $query->post->ID );
  29.                     $forum_title         = bbp_get_forum_title( $query->post->ID );
  30.  
  31.                     $prefix_bbpress_dropdown_forum_list .= \'
  32.                    <option value="\' . esc_url( $forum_permalink ) . \'">\' . $forum_title . \'</option>\';
  33.                 }
  34.             $prefix_bbpress_dropdown_forum_list .= \'</select>\';
  35.  
  36.             set_transient( \'prefix_bbpress_dropdown_forum_list\', $prefix_bbpress_dropdown_forum_list, 365 * DAY_IN_SECONDS );
  37.         }
  38.     echo $prefix_bbpress_dropdown_forum_list;
  39. }
');