| 1 | Index: wp-includes/class-wp-customize.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/class-wp-customize.php (revision 20782) |
|---|
| 4 | +++ wp-includes/class-wp-customize.php (working copy) |
|---|
| 5 | @@ -71,12 +71,9 @@ |
|---|
| 6 | if ( ! isset( $_REQUEST['customize'] ) || 'on' != $_REQUEST['customize'] ) |
|---|
| 7 | return; |
|---|
| 8 | |
|---|
| 9 | - $url = parse_url( admin_url() ); |
|---|
| 10 | - $allowed_origins = array( 'http://' . $url[ 'host' ], 'https://' . $url[ 'host' ] ); |
|---|
| 11 | - // @todo preserve port? |
|---|
| 12 | - if ( isset( $_SERVER[ 'HTTP_ORIGIN' ] ) && in_array( $_SERVER[ 'HTTP_ORIGIN' ], $allowed_origins ) ) { |
|---|
| 13 | - $origin = $_SERVER[ 'HTTP_ORIGIN' ]; |
|---|
| 14 | - } else { |
|---|
| 15 | + if ( ! $origin = get_allowed_http_origin() ) { |
|---|
| 16 | + // @todo Maybe kill this fallback since fallbacks aren't to spec. |
|---|
| 17 | + $url = parse_url( admin_url() ); |
|---|
| 18 | $origin = $url[ 'scheme' ] . '://' . $url[ 'host' ]; |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | Index: wp-includes/http.php |
|---|
| 22 | =================================================================== |
|---|
| 23 | --- wp-includes/http.php (revision 20782) |
|---|
| 24 | +++ wp-includes/http.php (working copy) |
|---|
| 25 | @@ -222,3 +222,35 @@ |
|---|
| 26 | |
|---|
| 27 | return (bool) $objFetchSite->_get_first_available_transport( $capabilities ); |
|---|
| 28 | } |
|---|
| 29 | + |
|---|
| 30 | +function get_http_origin() { |
|---|
| 31 | + $origin = ''; |
|---|
| 32 | + if ( ! empty ( $_SERVER[ 'HTTP_ORIGIN' ] ) ) |
|---|
| 33 | + $origin = $_SERVER[ 'HTTP_ORIGIN' ]; |
|---|
| 34 | + |
|---|
| 35 | + return apply_filters( 'http_origin', $origin ); |
|---|
| 36 | +} |
|---|
| 37 | + |
|---|
| 38 | +function get_allowed_http_origins() { |
|---|
| 39 | + $admin_origin = parse_url( admin_url() ); |
|---|
| 40 | + $home_origin = parse_url( home_url() ); |
|---|
| 41 | + |
|---|
| 42 | + // @todo preserve port? |
|---|
| 43 | + $allowed_origins = array( |
|---|
| 44 | + 'http://' . $admin_origin[ 'host' ], |
|---|
| 45 | + 'https://' . $admin_origin[ 'host' ], |
|---|
| 46 | + 'http://' . $home_origin[ 'host' ], |
|---|
| 47 | + 'https://' . $home_origin[ 'host' ], |
|---|
| 48 | + ); |
|---|
| 49 | + |
|---|
| 50 | + return apply_filters( 'allowed_http_origins' , $allowed_origins ); |
|---|
| 51 | +} |
|---|
| 52 | + |
|---|
| 53 | +function get_allowed_http_origin() { |
|---|
| 54 | + $origin = get_http_origin(); |
|---|
| 55 | + |
|---|
| 56 | + if ( $origin && ! in_array( $origin, get_allowed_http_origins() ) ) |
|---|
| 57 | + $origin = ''; |
|---|
| 58 | + |
|---|
| 59 | + return apply_filters( 'allowed_http_origin', $origin ); |
|---|
| 60 | +} |
|---|
| 61 | \ No newline at end of file |
|---|