Skip to:
Content

bbPress.org

Changeset 6745


Ignore:
Timestamp:
11/29/2017 12:46:17 AM (3 years ago)
Author:
johnjamesjacoby
Message:

URLs: Audit the usage of trailingslashit().

This change ensures that trailing slashes are only used at the end of URLs where they're expected, and avoids adding slashes at the end of URLs when permalinks are configured not to include them.

See #3181.

Location:
trunk/src/includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/ajax.php

    r6583 r6745  
    3333        global $wp;
    3434
    35         $base_url = home_url( trailingslashit( $wp->request ), ( is_ssl() ? 'https' : 'http' ) );
     35        $ssl      = is_ssl() ? 'https' : 'http';
     36        $url      = trailingslashit( $wp->request );
     37        $base_url = home_url( $url, $ssl );
    3638        $ajaxurl  = add_query_arg( array( 'bbp-ajax' => 'true' ), $base_url );
    3739
  • trunk/src/includes/common/template.php

    r6728 r6745  
    20542054        // Pretty permalinks
    20552055        if ( bbp_use_pretty_urls() ) {
     2056
     2057            // Run through home_url()
    20562058            $url = trailingslashit( bbp_get_root_url() . bbp_get_view_slug() ) . $view;
    20572059            $url = user_trailingslashit( $url );
     
    23062308        // Do we want to include a link to home?
    23072309        if ( ! empty( $r['include_home'] ) || empty( $r['home_text'] ) ) {
    2308             $crumbs[] = '<a href="' . trailingslashit( home_url() ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';
     2310            $crumbs[] = '<a href="' . esc_url( home_url() ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';
    23092311        }
    23102312
  • trunk/src/includes/replies/template.php

    r6737 r6745  
    459459        // Don't include pagination if on first page
    460460        if ( 1 >= $reply_page ) {
    461             $url = trailingslashit( $topic_url ) . $reply_hash;
     461            $url = user_trailingslashit( $topic_url ) . $reply_hash;
    462462
    463463        // Include pagination
     
    466466            // Pretty permalinks
    467467            if ( bbp_use_pretty_urls() ) {
    468                 $url = trailingslashit( $topic_url ) . trailingslashit( bbp_get_paged_slug() ) . trailingslashit( $reply_page ) . $reply_hash;
     468                $url = trailingslashit( $topic_url ) . trailingslashit( bbp_get_paged_slug() ) . $reply_page;
     469                $url = user_trailingslashit( $url ) . $reply_hash;
    469470
    470471            // Yucky links
  • trunk/src/includes/search/template.php

    r6700 r6745  
    203203        // Pretty permalinks
    204204        if ( bbp_use_pretty_urls() ) {
     205
     206            // Run through home_url()
    205207            $url = bbp_get_root_url() . bbp_get_search_slug();
    206208            $url = user_trailingslashit( $url );
     
    334336        // Shortcode territory
    335337        if ( is_page() || is_single() ) {
    336             $base = trailingslashit( get_permalink() );
     338            $base = get_permalink();
    337339
    338340        // Default search location
    339341        } else {
    340             $base = trailingslashit( bbp_get_search_results_url() );
     342            $base = bbp_get_search_results_url();
    341343        }
    342344
    343345        // Add pagination base
    344         $base = $base . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' );
     346        $base = trailingslashit( $base ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' );
    345347
    346348    // Unpretty permalinks
  • trunk/src/includes/users/template.php

    r6741 r6745  
    549549            }
    550550
     551            // Run through home_url()
    551552            $url = trailingslashit( bbp_get_root_url() . bbp_get_user_slug() ) . $user_nicename;
    552553            $url = user_trailingslashit( $url );
Note: See TracChangeset for help on using the changeset viewer.