Last active
February 22, 2019 10:25
-
-
Save catzy007/b8ae122f34e96c900404be56892558cc to your computer and use it in GitHub Desktop.
wordpress config
This file contains hidden or 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
| /** Absolute path to the WordPress directory. */ | |
| if ( !defined('ABSPATH') ) | |
| define('ABSPATH', dirname(__FILE__) . '/'); | |
| /** | |
| * get home url from absolute path | |
| * @return string url to main site | |
| * hello@lafif.me | |
| */ | |
| function get_dynamic_home_url(){ | |
| $base_dir = ABSPATH; // Absolute path | |
| $doc_root = preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']); | |
| $base_url = preg_replace("!^${doc_root}!", '', $base_dir); | |
| $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https'; | |
| $port = $_SERVER['SERVER_PORT']; | |
| $disp_port = ($protocol == 'http' && $port == 80 || $protocol == 'https' && $port == 443) ? '' : ":$port"; | |
| $domain = $_SERVER['HTTP_HOST']; | |
| $home_url = "${protocol}://${domain}${disp_port}${base_url}"; | |
| return $home_url; | |
| } | |
| $url = get_dynamic_home_url(); | |
| define('WP_SITEURL', $url); | |
| define('WP_HOME', $url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment