Skip to content

Commit

Permalink
Merge pull request #57 from Automattic/fix/admin-warning-different-ports
Browse files Browse the repository at this point in the history
Fix is_decoupled() warning when frontend is running on different port
  • Loading branch information
alecgeatches authored Aug 4, 2022
2 parents e843be5 + 1125d5b commit 74ad59a
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 247 deletions.
3 changes: 2 additions & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"plugins": [
"."
],
"config": {}
"config": {},
"core": "WordPress/WordPress#6.0.1"
}
9 changes: 7 additions & 2 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
* @return bool
*/
function is_decoupled() {
$frontend = wp_parse_url( home_url(), PHP_URL_HOST );
$backend = wp_parse_url( site_url(), PHP_URL_HOST );
$frontend_url = wp_parse_url( home_url(), PHP_URL_HOST );
$frontend_port = wp_parse_url( home_url(), PHP_URL_PORT );
$frontend = $frontend_url . ( $frontend_port ? ':' . $frontend_port : '' );

$backend_url = wp_parse_url( site_url(), PHP_URL_HOST );
$backend_port = wp_parse_url( site_url(), PHP_URL_PORT );
$backend = $backend_url . ( $backend_port ? ':' . $backend_port : '' );

return $frontend !== $backend;
}
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"phpcompatibility/phpcompatibility-wp": "^2.1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"phpunit/phpunit": "^7",
"yoast/phpunit-polyfills": "^1.0",
"wp-phpunit/wp-phpunit": "^5.9"
"yoast/phpunit-polyfills": "^1.0"
},
"scripts": {
"phpcs": "phpcs",
Expand Down
Loading

0 comments on commit 74ad59a

Please sign in to comment.