WordPress.org

Make WordPress Core

Changeset 18834


Ignore:
Timestamp:
09/30/2011 03:13:13 PM (7 years ago)
Author:
ryan
Message:

Deprecate wpmu_admin_redirect_add_updated_param() and wpmu_admin_do_redirect(). Props SergeyBiryukov. fixes #18619

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-deprecated.php

    r18460 r18834  
    201201    return array_slice( $most_active, 0, $num );
    202202}
     203
     204/**
     205 * Redirect a user based on $_GET or $_POST arguments.
     206 *
     207 * The function looks for redirect arguments in the following order:
     208 * 1) $_GET['ref']
     209 * 2) $_POST['ref']
     210 * 3) $_SERVER['HTTP_REFERER']
     211 * 4) $_GET['redirect']
     212 * 5) $_POST['redirect']
     213 * 6) $url
     214 *
     215 * @since MU
     216 * @deprecated 3.3.0
     217 * @deprecated Use wp_redirect()
     218 * @uses wpmu_admin_redirect_add_updated_param()
     219 *
     220 * @param string $url
     221 */
     222function wpmu_admin_do_redirect( $url = '' ) {
     223    _deprecated_function( __FUNCTION__, '3.3' );
     224
     225    $ref = '';
     226    if ( isset( $_GET['ref'] ) )
     227        $ref = $_GET['ref'];
     228    if ( isset( $_POST['ref'] ) )
     229        $ref = $_POST['ref'];
     230
     231    if ( $ref ) {
     232        $ref = wpmu_admin_redirect_add_updated_param( $ref );
     233        wp_redirect( $ref );
     234        exit();
     235    }
     236    if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
     237        wp_redirect( $_SERVER['HTTP_REFERER'] );
     238        exit();
     239    }
     240
     241    $url = wpmu_admin_redirect_add_updated_param( $url );
     242    if ( isset( $_GET['redirect'] ) ) {
     243        if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
     244            $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
     245    } elseif ( isset( $_POST['redirect'] ) ) {
     246        $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
     247    }
     248    wp_redirect( $url );
     249    exit();
     250}
     251
     252/**
     253 * Adds an 'updated=true' argument to a URL.
     254 *
     255 * @since MU
     256 * @deprecated 3.3.0
     257 * @deprecated Use add_query_arg()
     258 *
     259 * @param string $url
     260 * @return string
     261 */
     262function wpmu_admin_redirect_add_updated_param( $url = '' ) {
     263    _deprecated_function( __FUNCTION__, '3.3' );
     264
     265    if ( strpos( $url, 'updated=true' ) === false ) {
     266        if ( strpos( $url, '?' ) === false )
     267            return $url . '?updated=true';
     268        else
     269            return $url . '&updated=true';
     270    }
     271    return $url;
     272}
     273
    203274?>
  • trunk/wp-includes/ms-functions.php

    r18791 r18834  
    395395
    396396// Admin functions
    397 
    398 /**
    399  * Redirect a user based on $_GET or $_POST arguments.
    400  *
    401  * The function looks for redirect arguments in the following order:
    402  * 1) $_GET['ref']
    403  * 2) $_POST['ref']
    404  * 3) $_SERVER['HTTP_REFERER']
    405  * 4) $_GET['redirect']
    406  * 5) $_POST['redirect']
    407  * 6) $url
    408  *
    409  * @since MU
    410  * @uses wpmu_admin_redirect_add_updated_param()
    411  *
    412  * @param string $url
    413  */
    414 function wpmu_admin_do_redirect( $url = '' ) {
    415     $ref = '';
    416     if ( isset( $_GET['ref'] ) )
    417         $ref = $_GET['ref'];
    418     if ( isset( $_POST['ref'] ) )
    419         $ref = $_POST['ref'];
    420 
    421     if ( $ref ) {
    422         $ref = wpmu_admin_redirect_add_updated_param( $ref );
    423         wp_redirect( $ref );
    424         exit();
    425     }
    426     if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
    427         wp_redirect( $_SERVER['HTTP_REFERER'] );
    428         exit();
    429     }
    430 
    431     $url = wpmu_admin_redirect_add_updated_param( $url );
    432     if ( isset( $_GET['redirect'] ) ) {
    433         if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
    434             $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
    435     } elseif ( isset( $_POST['redirect'] ) ) {
    436         $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
    437     }
    438     wp_redirect( $url );
    439     exit();
    440 }
    441 
    442 /**
    443  * Adds an 'updated=true' argument to a URL.
    444  *
    445  * @since MU
    446  *
    447  * @param string $url
    448  * @return string
    449  */
    450 function wpmu_admin_redirect_add_updated_param( $url = '' ) {
    451     if ( strpos( $url, 'updated=true' ) === false ) {
    452         if ( strpos( $url, '?' ) === false )
    453             return $url . '?updated=true';
    454         else
    455             return $url . '&updated=true';
    456     }
    457     return $url;
    458 }
    459397
    460398/**
Note: See TracChangeset for help on using the changeset viewer.