[wp-hackers] WP Development & Production Sites
Jeremy Clarke
jer at simianuprising.com
Mon Nov 22 17:39:21 UTC 2010
The admin hacks you guys are talking about make my head spin.
I can't help thinking the problem is how you're approaching your needs. I
don't think that synching your dev environment back to live on the database
level is the right way to keep them in sync. The content lives in the
database and you should never mess with the live content. If you change
content on your dev setup you should manually re-do that work on the live
site. This is not that hard and has the positive side effect of avoiding
your development cruft form living on the live site (e.g. crap added by
plugins you tried but didn't keep).
What you really want to sync back to the live site are two things: 1)
plugin/theme files and 2) Plugin/theme configuration options.
In my experience both of these can be solved with files rather than the
database, and if you can keep everything in files then SVN can do all the
dirty work for you. You commit the changes on dev and just update live.
The tricky part is getting configuration into files rather than the
database. My approach to this is a system where I have an array in
functions.php containing all the get_option() values that I want/expect the
site to have, and an 'init' callback that checks the values for those
options and runs update_option() to change them if they are wrong. This way
when I make a change on the dev site I just need to add an element to my
array to reference the specific option I changed, commit that change to SVN,
then SVN-update on the live site and it immediately changes the value. This
way you don't have to worry, you know what the value will be on any site
with an up-to-date version of the functions.php or plugin file. In my case
this also has a positive side-effect of making it impossible to change the
setting in the admin, it gets reverted immediately when the page reloads
(and shows an error message so the user isn't confused).
Another less-invasive method is to have 'versions' of your
plugin/functions.php and to make incremental changes to settings. So to
update the live site you add a new version to your plugin/theme and have an
upgrade method that changes the settings the way you think will be necessary
for that particular transition. This system lets users change things after
if you want that but IMHO it is more complicated then what I described above
because in any given scenario you aren't completely sure what the resulting
settings will be.
--
Jeremy Clarke | http://jeremyclarke.org
Code and Design | http://globalvoicesonline.org
More information about the wp-hackers
mailing list