WordPress.org

Make WordPress Core

Ticket #18619: 18619.patch

File 18619.patch, 3.9 KB (added by SergeyBiryukov, 7 years ago)
  • wp-includes/ms-deprecated.php

     
    200200        }
    201201        return array_slice( $most_active, 0, $num );
    202202}
    203 ?>
     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
     274?>
     275 No newline at end of file
  • wp-includes/ms-functions.php

     
    396396// Admin functions
    397397
    398398/**
    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 }
    459 
    460 /**
    461399 * Checks an email address against a list of banned domains.
    462400 *
    463401 * This function checks against the Banned Email Domains list