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

    r5815 r5827  
    336336     * @param string $user_nicename Optional. User nicename
    337337     * @uses bbp_get_user_id() To get user id
    338      * @uses WP_Rewrite::using_permalinks() To check if the blog is using
    339      *                                       permalinks
     338     * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs
    340339     * @uses add_query_arg() To add custom args to the url
    341340     * @uses home_url() To get blog home url
     
    345344     */
    346345    function bbp_get_user_profile_url( $user_id = 0, $user_nicename = '' ) {
    347         global $wp_rewrite;
    348346
    349347        // Use displayed user ID if there is one, and one isn't requested
     
    360358
    361359        // Pretty permalinks
    362         if ( $wp_rewrite->using_permalinks() ) {
     360        if ( bbp_use_pretty_urls() ) {
    363361
    364362            // Get username if not passed
     
    367365            }
    368366
    369             $url = trailingslashit( $wp_rewrite->root . bbp_get_user_slug() ) . $user_nicename;
     367            $url = trailingslashit( bbp_get_root_url() . bbp_get_user_slug() ) . $user_nicename;
    370368            $url = user_trailingslashit( $url );
    371369            $url = home_url( $url );
     
    439437     * @uses bbp_get_user_id() To get user id
    440438     * @uses bbp_get_user_profile_url() To get the user profile url
    441      * @uses WP_Rewrite::using_permalinks() To check if the blog is using
    442      *                                       permalinks
     439     * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs
    443440     * @uses add_query_arg() To add custom args to the url
    444441     * @uses home_url() To get blog home url
     
    448445     */
    449446    function bbp_get_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) {
    450         global $wp_rewrite;
    451447
    452448        $user_id = bbp_get_user_id( $user_id );
     
    465461
    466462        // Pretty permalinks
    467         if ( $wp_rewrite->using_permalinks() ) {
     463        if ( bbp_use_pretty_urls() ) {
    468464            $url = trailingslashit( $profile_url ) . 'edit';
    469465            $url = user_trailingslashit( $url );
     
    820816     */
    821817    function bbp_get_favorites_permalink( $user_id = 0 ) {
    822         global $wp_rewrite;
    823818
    824819        // Use displayed user ID if there is one, and one isn't requested
     
    838833
    839834        // Pretty permalinks
    840         if ( $wp_rewrite->using_permalinks() ) {
     835        if ( bbp_use_pretty_urls() ) {
    841836            $url = trailingslashit( $profile_url ) . bbp_get_user_favorites_rewrite_id();
    842837            $url = user_trailingslashit( $url );
     
    980975     */
    981976    function bbp_get_subscriptions_permalink( $user_id = 0 ) {
    982         global $wp_rewrite;
    983977
    984978        // Use displayed user ID if there is one, and one isn't requested
     
    998992
    999993        // Pretty permalinks
    1000         if ( $wp_rewrite->using_permalinks() ) {
     994        if ( bbp_use_pretty_urls() ) {
    1001995            $url = trailingslashit( $profile_url ) . bbp_get_user_subscriptions_slug();
    1002996            $url = user_trailingslashit( $url );
     
    14211415     */
    14221416    function bbp_get_user_topics_created_url( $user_id = 0 ) {
    1423         global $wp_rewrite;
    14241417
    14251418        // Use displayed user ID if there is one, and one isn't requested
     
    14391432
    14401433        // Pretty permalinks
    1441         if ( $wp_rewrite->using_permalinks() ) {
     1434        if ( bbp_use_pretty_urls() ) {
    14421435            $url = trailingslashit( $profile_url ) . bbp_get_topic_archive_slug();
    14431436            $url = user_trailingslashit( $url );
     
    14791472     */
    14801473    function bbp_get_user_replies_created_url( $user_id = 0 ) {
    1481         global $wp_rewrite;
    14821474
    14831475        // Use displayed user ID if there is one, and one isn't requested
     
    14971489
    14981490        // Pretty permalinks
    1499         if ( $wp_rewrite->using_permalinks() ) {
     1491        if ( bbp_use_pretty_urls() ) {
    15001492            $url = trailingslashit( $profile_url ) . bbp_get_reply_archive_slug();
    15011493            $url = user_trailingslashit( $url );
Note: See TracChangeset for help on using the changeset viewer.