To move content between our content staging site and the live site, we’re using a premium plugin called RAMP, from Crowd Favorite. RAMP allows content owners to select content items on an item-by-item basis and push them over to the live site. It has a nice GUI in the WordPress admin and in theory end users can use it to manage content deployments.
Now that we have lots of real content in the staging site and we’ve got our custom theme going, along with a CPT and associated custom taxonomies, a big menu and everything, we can finally really put RAMP through its paces.
What we discovered is that the combination of RAMP and CMB2 requires customization to really work well.
GUID & copying the database
GUID is how RAMP knows that a post is the same post on two different sites. The post ID’s will be different, but the GUIDs should always be the same.
I didn’t know what a GUID was supposed to be and I feel stupid now. You probably already know this. Don’t go ’round changing your GUID’s because they don’t match up with the site URL. Ask me how I know! :)
To get around problems caused by my earnest attempt at cleanup, I used our database copy script to get the live site back into some kind of usable state – I brought over all the content, etc from the staging site. The only special tweak after the DB copy was that I had to reconfigure RAMP because it needs different settings in stage and in live.
RAMP and CMB2 Repeating Fields
The Crowd Favorite folks provide an add-on to RAMP that will allow you to configure RAMP to transform Post IDs in fields created by custom metabox libraries such as CMB2 (which we happen to be using). Unfortunately this add-on only helps with fields that are not repeating. Repeating fields – which are immensely useful, we use them all over the place – bury any Post IDs in a serialized post meta field along with a lot of other data.
For RAMP to be able to transform those Post IDs contained in that serialized data, you have to write a custom add-on to the add-on. I’ve put a somewhat sanitized version of ours up as a gist.
URL translation in CMB2 Repeating Fields
Crowd Favorite provides a plugin that will translate the URLs of intra-site links that appear in the main post content. By default these links are absolute URLs that point at your content staging server, and without this add-on will not be converted.
With CMB2 it’s easy to add TinyMCE editors in custom fields, and in those editors it’s easy to create links that also need to be translated. The plugin that CF provides won’t handle these custom fields, so I modified it to handle them.
I’ve put the bits I customized up as a gist.
RAMP-ing over custom meta with a menu
We use a mega-menu plugin that gives us a lot of customization options. All of this stuff gets shoved into a couple of custom postmeta fields that are added to every menu item post.
This one made my brain hurt, because menus are handled completely differently in RAMP from posts. Here is a big hint in the code about this:
// nuke existing menu items, trust me, its easier this way
In the end the code to accomplish it was really small and simple if rather hard-won.
I also worked and worked at finding a way to translate the post ID’s of image attachments embedded in that serialized postmeta. Because menus never go through the post preparation process in RAMP, getting this to work seems very tricky. Trying to wrap my head around just what RAMP was doing during its process was exhausting – it’s complex. I resorted to annotated sticky notes to try and make sense of it because I couldn’t hold it all in my head from day to day (or even moment to moment).
I finally gave up, moved what I had to production and used it to RAMP over our mega-menu. Guess what? The images appeared perfectly on the live site. I have no idea why. I don’t like that I have no idea why but it works, for now, so I’ll take it.
Anyway, I’ve put my little menu custom meta plugin up as a gist.
Note about licensing
While RAMP itself is under GPL, the add-on code provided to us by Crowd Favorite is not released under any license, so I cannot fork and GPL it myself. Hence the gists, and incomplete bits of code, rather than complete plugins under GPL.