wpmu_admin_do_redirect

函数
wpmu_admin_do_redirect ( $url = '' )
参数
  • (string) $url Optional. Redirect URL. Default empty.
    Required:
    Default: (empty)
相关
  • wp_redirect()
定义位置
相关方法
wp_validate_redirectwp_admin_bar_renderwp_safe_redirectwp_sanitize_redirectwp_redirect
引入
-
弃用
3.3.0

wpmu_admin_do_redirect – 这个函数用来在用户在WordPress多站点管理界面采取特定的行动后,将其重定向到正确的页面。

根据$_GET或$_POST参数重定向一个用户。

该函数按照以下顺序寻找重定向参数。
1) $_GET[‘ref’]
2) $_POST[‘ref’]
3) $_SERVER[‘HTTP_REFERER’]
4) $_GET[‘redirect’]
5) $_POST[‘redirect’]
6) $url

function wpmu_admin_do_redirect( $url = '' ) {
	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_redirect()' );

	$ref = '';
	if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
	} elseif ( isset( $_POST['ref'] ) ) {
		$ref = $_POST['ref'];
	} elseif ( isset( $_GET['ref'] ) ) {
		$ref = $_GET['ref'];
	}

	if ( $ref ) {
		$ref = wpmu_admin_redirect_add_updated_param( $ref );
		wp_redirect( $ref );
		exit;
	}
	if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
		wp_redirect( $_SERVER['HTTP_REFERER'] );
		exit;
	}

	$url = wpmu_admin_redirect_add_updated_param( $url );
	if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['redirect'] ) {
		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
	} elseif ( isset( $_GET['redirect'] ) ) {
		if ( 's_' === substr( $_GET['redirect'], 0, 2 ) )
			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
	} elseif ( isset( $_POST['redirect'] ) ) {
		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
	}
	wp_redirect( $url );
	exit;
}

常见问题

FAQs
查看更多 >