Skip to:
Content

bbPress.org


Ignore:
Timestamp:
12/18/2012 02:56:01 AM (9 years ago)
Author:
jmdodd
Message:

Shortcode iteration for search introduced in #1575.

  • Fix bbp-search shortcode.
  • Introduce bbp-search-form shortcode.
  • Fixes #2107.
File:
1 edited

Legend:

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

    r4579 r4586  
    8282            /** Search ********************************************************/
    8383
     84            'bbp-search-form'      => array( $this, 'display_search_form'   ), // Search form
    8485            'bbp-search'           => array( $this, 'display_search'        ), // Search
    8586
     
    611612
    612613    /**
     614     * Display the search form in an output buffer and return to ensure
     615     * post/page contents are displayed first.
     616     *
     617     * @since bbPress (r4585)
     618     *
     619     * @uses get_template_part()
     620     */
     621    public function display_search_form() {
     622
     623        // Start output buffer
     624        $this->start( 'bbp_search_form' );
     625
     626        // Output templates
     627        bbp_get_template_part( 'form', 'search' );
     628
     629        // Return contents of output buffer
     630        return $this->end();
     631    }
     632
     633    /**
    613634     * Display the contents of search results in an output buffer and return to
    614635     * ensure that post/page contents are displayed first.
     
    623644    public function display_search( $attr, $content = '' ) {
    624645
     646        // Sanity check required info
     647        if ( !empty( $content ) )
     648            return $content;
     649
    625650        // Set passed attribute to $search_terms for clarity
    626         $search_terms = $attr['search'];
     651        $search_terms = empty( $attr['search'] ) ? bbp_get_search_terms() : $attr['search'];
     652
     653        // Unset globals
     654        $this->unset_globals();
     655
     656        // Set terms for query
     657        set_query_var( bbp_get_search_rewrite_id(), $search_terms );
    627658
    628659        // Start output buffer
    629660        $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 ) );
    636661
    637662        // Output template
Note: See TracChangeset for help on using the changeset viewer.