production vs deployment – WP_LOCATION hack – help!
-
Hi, I have searched on this topic but have not found a satisfactory answer. Here’s the deal:
Current process:
- I dev a site and enter content into the local db. I have the siteurl and home set to http://wp.dev
- I then use mysqldump to get an sql file.
- I then search and replace that sql file to change all strings from http://wp.dev to http://myonline.co.za
- I then import that sql file into my online database.
This is okay, but I’d prefer to avoid the search/replace step. I found a hack whereby you add a function WP_LOCATION() to the end of wp_config.php that overrides the siteurl and home fields. It looks like this:
define('WP_CONTENT_URL', $wpLocation."/wp-content function WP_LOCATION () { $script_path = realpath(dirname($_SERVER['SCRIPT_FILENAME'])); $wp_base_path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..'); $web_subfolder = substr( $script_path, strlen($wp_base_path)); $wp_path = $web_subfolder ? substr( dirname($_SERVER['SCRIPT_NAME']), 0, -strlen($web_subfolder) ) : dirname($_SERVER['SCRIPT_NAME']) ; $retval = 'http' . ($_SERVER['HTTPS'] ? 's' : null) . '://' . $_SERVER['HTTP_HOST'] . $wp_path ; return $retval; } $wpLocation = WP_LOCATION(); define('WP_HOME',$wpLocation); define('WP_SITEURL',$wpLocation); define('WP_CONTENT_URL',$wpLocation."/wp-content");(found here: http://codex.ww.wp.xz.cn/Running_a_Development_Copy_of_WordPress)
The problem:
I found that functions likebloginfo('stylesheet_url');and others are still returning the old url (wp.dev, not myonline.co.za) and so the style.css and various images are not being loaded from the right server.How can I be sure that all references to the dev hostname are going to use the live hostname without having to resort to editing the sql file every time?
\d
The topic ‘production vs deployment – WP_LOCATION hack – help!’ is closed to new replies.