Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/14/2015 12:31:42 AM (11 years ago)
Author:
johnjamesjacoby
Message:

Abstraction: Use bbp_db(), bbp_rewrite() & friends, introduced in r5823 & r5826.

This commit improves the stability of bbPress in the WordPress environment by reducing global variable exposure. It also comes with minimal opcode improvements in some circumstances where $GLOBALS is preferred over defining via global statements.

Some additional surrounding cleanup directly related to functions & methods being altered is also being performed here.

Fixes #2786.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/search/template.php

    r5770 r5827  
    3131 * @uses bbp_get_search_terms() To get the search terms
    3232 * @uses WP_Query To make query and get the search results
    33  * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
     33 * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs
    3434 * @uses bbp_get_search_url() To get the forum search url
    3535 * @uses paginate_links() To paginate search results
     
    4040 */
    4141function bbp_has_search_results( $args = array() ) {
    42     global $wp_rewrite;
    4342
    4443    /** Defaults **************************************************************/
     
    115114
    116115        // If pretty permalinks are enabled, make our pagination pretty
    117         if ( $wp_rewrite->using_permalinks() ) {
     116        if ( bbp_use_pretty_urls() ) {
    118117
    119118            // Shortcode territory
     
    127126
    128127            // Add pagination base
    129             $base = $base . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
     128            $base = $base . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' );
    130129
    131130        // Unpretty permalinks
     
    154153
    155154        // Remove first page from pagination
    156         if ( $wp_rewrite->using_permalinks() ) {
    157             $bbp->search_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->search_query->pagination_links );
     155        if ( bbp_use_pretty_urls() ) {
     156            $bbp->search_query->pagination_links = str_replace( bbp_get_paged_slug() . '/1/', '', $bbp->search_query->pagination_links );
    158157        } else {
    159158            $bbp->search_query->pagination_links = str_replace( '&paged=1', '', $bbp->search_query->pagination_links );
     
    264263     */
    265264    function bbp_get_search_url() {
    266         global $wp_rewrite;
    267265
    268266        // Pretty permalinks
    269         if ( $wp_rewrite->using_permalinks() ) {
    270             $url = $wp_rewrite->root . bbp_get_search_slug();
    271             $url = home_url( user_trailingslashit( $url ) );
     267        if ( bbp_use_pretty_urls() ) {
     268            $url = bbp_get_root_url() . bbp_get_search_slug();
     269            $url = user_trailingslashit( $url );
     270            $url = home_url( $url );
    272271
    273272        // Unpretty permalinks
    274273        } else {
    275             $url = add_query_arg( array( bbp_get_search_rewrite_id() => '' ), home_url( '/' ) );
     274            $url = add_query_arg( array(
     275                bbp_get_search_rewrite_id() => ''
     276            ), home_url( '/' ) );
    276277        }
    277278
     
    302303     */
    303304    function bbp_get_search_results_url() {
    304         global $wp_rewrite;
    305305
    306306        // Get the search terms
     
    308308
    309309        // Pretty permalinks
    310         if ( $wp_rewrite->using_permalinks() ) {
     310        if ( bbp_use_pretty_urls() ) {
    311311
    312312            // Root search URL
    313             $url = $wp_rewrite->root . bbp_get_search_slug();
     313            $url = bbp_get_root_url() . bbp_get_search_slug();
    314314
    315315            // Append search terms
    316316            if ( ! empty( $search_terms ) ) {
    317                 $url = trailingslashit( $url ) . user_trailingslashit( urlencode( $search_terms ) );
     317                $url = trailingslashit( $url ) . urlencode( $search_terms );
    318318            }
    319319
    320320            // Run through home_url()
    321             $url = home_url( user_trailingslashit( $url ) );
     321            $url = user_trailingslashit( $url );
     322            $url = home_url( $url );
    322323
    323324        // Unpretty permalinks
    324325        } else {
    325             $url = add_query_arg( array( bbp_get_search_rewrite_id() => urlencode( $search_terms ) ), home_url( '/' ) );
     326            $url = add_query_arg( array(
     327                bbp_get_search_rewrite_id() => urlencode( $search_terms )
     328            ), home_url( '/' ) );
    326329        }
    327330
Note: See TracChangeset for help on using the changeset viewer.