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/replies/template.php

    r5770 r5827  
    109109 *                           others' replies
    110110 * @uses WP_Query To make query and get the replies
    111  * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
     111 * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs
    112112 * @uses get_permalink() To get the permalink
    113113 * @uses add_query_arg() To add custom args to the url
    … …  
    120120 */
    121121function bbp_has_replies( $args = array() ) {
    122         global $wp_rewrite;
    123122
    124123        /** Defaults **************************************************************/
    … …  
    226225
    227226                // If pretty permalinks are enabled, make our pagination pretty
    228                 if ( $wp_rewrite->using_permalinks() ) {
     227                if ( bbp_use_pretty_urls() ) {
    229228
    230229                        // User's replies
    … …  
    245244                        }
    246245
    247                         $base = trailingslashit( $base ) . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
     246                        $base = trailingslashit( $base ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' );
    248247
    249248                // Unpretty permalinks
    … …  
    272271
    273272                        // Remove first page from pagination
    274                         if ( $wp_rewrite->using_permalinks() ) {
    275                                 $bbp->reply_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links );
     273                        if ( bbp_use_pretty_urls() ) {
     274                                $bbp->reply_query->pagination_links = str_replace( bbp_get_paged_slug() . '/1/', '', $bbp->reply_query->pagination_links );
    276275                        } else {
    277276                                $bbp->reply_query->pagination_links = str_replace( '&paged=1', '', $bbp->reply_query->pagination_links );
    … …  
    474473         * @uses bbp_get_reply_position() To get the reply position
    475474         * @uses get_option() To get the replies per page option
    476          * @uses WP_Rewrite::using_permalinks() To check if the blog uses
    477          *                                       permalinks
     475         * @uses bbp_use_pretty_urls() To check if the site uses pretty URLs
    478476         * @uses add_query_arg() To add custom args to the url
    479477         * @uses apply_filters() Calls 'bbp_get_reply_url' with the reply url,
    … …  
    506504                // Include pagination
    507505                } else {
    508                         global $wp_rewrite;
    509506
    510507                        // Pretty permalinks
    511                         if ( $wp_rewrite->using_permalinks() ) {
    512                                 $url = trailingslashit( $topic_url ) . trailingslashit( $wp_rewrite->pagination_base ) . trailingslashit( $reply_page ) . $reply_hash;
     508                        if ( bbp_use_pretty_urls() ) {
     509                                $url = trailingslashit( $topic_url ) . trailingslashit( bbp_get_paged_slug() ) . trailingslashit( $reply_page ) . $reply_hash;
    513510
    514511                        // Yucky links
    … …  
    20222019         */
    20232020        function bbp_get_reply_edit_url( $reply_id = 0 ) {
    2024                 global $wp_rewrite;
    20252021
    20262022                $reply = bbp_get_reply( $reply_id );
    … …  
    20322028
    20332029                // Pretty permalinks
    2034                 if ( $wp_rewrite->using_permalinks() ) {
     2030                if ( bbp_use_pretty_urls() ) {
    20352031                        $url = trailingslashit( $reply_link ) . bbp_get_edit_rewrite_id();
    2036                         $url = trailingslashit( $url );
     2032                        $url = user_trailingslashit( $url );
    20372033
    20382034                // Unpretty permalinks
    20392035                } else {
    2040                         $url = add_query_arg( array( bbp_get_reply_post_type() => $reply->post_name, bbp_get_edit_rewrite_id() => '1' ), $reply_link );
     2036                        $url = add_query_arg( array(
     2037                                bbp_get_reply_post_type() => $reply->post_name,
     2038                                bbp_get_edit_rewrite_id() => '1'
     2039                        ), $reply_link );
    20412040                }
    20422041
Note: See TracChangeset for help on using the changeset viewer.