Created
August 11, 2021 05:24
-
-
Save arungpisyadi/40f04c9faff93668e50e6813f040f385 to your computer and use it in GitHub Desktop.
A script to allow dynamic site_url and home_url.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!defined('ABSPATH')){ | |
define('ABSPATH', dirname(__FILE__) . '/'); | |
} | |
$main_domain = get_site_url(); | |
$port = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'; | |
$main_domain = str_replace($port, '', $main_domain); | |
// var_dump($main_domain); | |
$viewed_domain = $_SERVER['HTTP_HOST']; | |
// var_dump($viewed_domain); | |
$currentpath = preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])); | |
$currentpath = preg_replace('/\/wp.+/', '', $currentpath); | |
// var_dump($currentpath); exit; | |
$_url = $port.$viewed_domain.$currentpath; | |
define('WP_HOME', $_url); | |
define('WP_SITEURL', $_url); | |
define('WP_CONTENT_URL', $_url . '/wp-content'); | |
define('WP_PLUGIN_URL', $_url . '/wp-content/plugins'); | |
define('DOMAIN_CURRENT_SITE', $_url); | |
@define('ADMIN_COOKIE_PATH', './'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment