Skip to:
Content

bbPress.org


Ignore:
Timestamp:
12/16/2012 08:19:21 AM (13 years ago)
Author:
jmdodd
Message:

Introduce dedicated forum search.

  • Search forums, topics, and replies.
  • Add new search functions, including bbp_has_search_results().
  • Provide templates for search results.
  • Fixes #1575.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/common/shortcodes.php

    r4510 r4579  
    8080            'bbp-single-view'      => array( $this, 'display_view'          ), // Single view
    8181
     82            /** Search ********************************************************/
     83
     84            'bbp-search'           => array( $this, 'display_search'        ), // Search
     85
    8286            /** Account *******************************************************/
    8387
     
    115119
    116120        // Unset global queries
    117         $bbp->forum_query = new stdClass;
    118         $bbp->topic_query = new stdClass;
    119         $bbp->reply_query = new stdClass;
     121        $bbp->forum_query  = new stdClass;
     122        $bbp->topic_query  = new stdClass;
     123        $bbp->reply_query  = new stdClass;
     124        $bbp->search_query = new stdClass;
    120125
    121126        // Unset global ID's
     
    603608    }
    604609
     610    /** Search ****************************************************************/
     611
     612    /**
     613     * Display the contents of search results in an output buffer and return to
     614     * ensure that post/page contents are displayed first.
     615     *
     616     * @since bbPress (r4579)
     617     *
     618     * @param array $attr
     619     * @param string $content
     620     * @uses bbp_search_query()
     621     * @uses get_template_part()
     622     */
     623    public function display_search( $attr, $content = '' ) {
     624
     625        // Set passed attribute to $search_terms for clarity
     626        $search_terms = $attr['search'];
     627
     628        // Start output buffer
     629        $this->start( 'bbp_search' );
     630
     631        // Unset globals
     632        $this->unset_globals();
     633
     634        // Load the search
     635        bbp_search_query( array( 's' => $search_terms ) );
     636
     637        // Output template
     638        bbp_get_template_part( 'content', 'search' );
     639
     640        // Return contents of output buffer
     641        return $this->end();
     642    }
     643
    605644    /** Account ***************************************************************/
    606645
Note: See TracChangeset for help on using the changeset viewer.