Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Warning:</strong> incoming wall of text..</p> <p>@Rob, WP is hell when it comes to working in teams; however, with a little work (and some symlink magic) you can set up your WP projects so that your working files for your themes or plugins can reside separately from the WP core. Some of this uses WP's built in mechanisms, some of it is related to SVN externals (hint). I'll let you google that since it's outside the scope of your question.</p> <h2>A note on WP GUIDs</h2> <p><strong>WARNING:</strong> DO NOT replace guids. WP GUIDs are there for external feed readers. Feed readers use the GUID to determine if the content is recent. Changing it basically tells those readers that every entry in the feed is new (especially for posts.) That introduces a lot of extra overhead for legacy content that you just don't need. GUID are a legacy feature that should have been changed a long time ago to UUIDs. Technically, you can use anything int he guid field, but WP uses the permalink to populate that field -- legacy.</p> <p>The only time it is ever acceptable to change the GUID is for new wp projects where content is brand-spankin' new.</p> <h1>To answer your question:</h1> <p>WP stores explicit references to the current domain in a dozen places in it's DB. These locations are a pain to track down and change, and the last thing you want to do is deal with manual edits to a *.sql dump file that you're going to import into production. It just smacks of bad development practices.</p> <p>There's a couple ways to get around this, but it means a little bit of work if you're already further down your development lifecycle. I'll address the first case.</p> <h2>Case 1: Project Onset</h2> <p>When you're starting the project, you'll likely have a development sandbox and DB ready. You'll likely have WP already installed by now, so it's essentially clean for all intents and purposes. </p> <p>The first thing you're going to want to do is change how your config file works. Most folks keep with the standard <code>wp-config.php</code> file (beyond a team production project, there's not really any reason to edit it.) However, you can set it up with some logic to include developer-specific or environment-specific config files. For example:</p> <p><strong>wp-config.php</strong></p> <pre><code>switch( $current_environment ) { case 'jack.local' : include( 'wp-config-jack.php' ) break; // Jack's sandbox case 'jill.local' : include( 'wp-config-jill.php' ) break; // Jill's sandbox default : ... break; // Staging &amp; Production } </code></pre> <p>The next thing you're going to want to do is include the normal contents of the <code>wp-config.php</code> file in a <code>wp-config-remote.php</code> file for use on staging/production. Next, edit your <code>wp-config-remote.php</code> file so that you can use 1 config file across multiple environments (staging,production). An <code>if(...)</code> or <code>switch(...)</code> block is all you need, e.g.</p> <pre><code>if( (strpos( $_SERVER[ "HTTP_HOST" ], "localhost" ) !== false) || (strpos( $_SERVER[ "HTTP_HOST" ], "local" ) !== false) ) </code></pre> <p>(There are better ways to write that condition... this is just a crude example.)</p> <p>Configure all of your WP settings specific to each of your remote environments. Hopefully you'll be checking this into a source control repository.</p> <p>That basically frees you up to let your team have config settings specific to their environment, while letting you check in settings for each of the remote environments <strong>once</strong>.</p> <p>The second thing you're going to want to do is build a mechanism to intercept and filter domain-specific links. The intent behind this mechanism is to replace any references to the current domain with a token/placeholder. I've outline the technique to do this here: <a href="http://www.farfromfearless.com/2010/09/07/url-token-replacement-techniques-for-wordpress-3-0/" rel="nofollow">http://www.farfromfearless.com/2010/09/07/url-token-replacement-techniques-for-wordpress-3-0/</a></p> <p>It basically amounts to creating a filter that acts on the content before it's submitted to the DB and before the content is rendered to the page. The technique is transparent in that it won't affect normal editing practices. You can still create your content in the editor, reference other pages, posts, images, etc. and they'll show up just fine while editing in different environments.</p> <p>In recent projects, I've wrapped all of this and a few other WP "normalization" features into a single bootstrap plugin that I set &amp; forget.</p> <h2>Case 2: Project Ongoing</h2> <p>Now, in your case, you're further along in your development lifecycle. It's going to take some work to replace those domain references, but if you follow the steps I've outline above you should only ever have to do this once. The link I supplied above gives you the SQL you'll need to do that job. It's important to note that in a multi-site environment, you'll need to do this for every "sub-site" you've created.</p> <p>Once you've updated your DB, I suggest implementing the steps in <strong>CASE 1</strong> so you don't have to repeat the steps again.</p> <h2>Bonus: synchronizing content</h2> <p>Synchronizing content is a pain. What I've done in recent projects is had clients work on the staging server and promote changes upstream to production. So then, that leaves you with synchronizing downstream to your sandbox(es). Write a shell script that dumps a copy of SPECIFIC content tables from your staging DB, and imports them into your sandbox DB (effectively replacing content tables.) You should be able to see the benefit of the domain-token-replacement technique.</p> <p>Images that aren't checked into source control, e.g. client images should be pushed to a common location, e.g. an S3 Bucket. There are WP plugins that can help you with that. That'll save a lot of time having to synchronize assets across environments.</p> <p>I hope this helps you out -- if not, there's always SilverStripe ;)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload