New WordPress Customizer Import/Export Plugin Migrates Theme and Plugin Settings

customizer-import-export

The WordPress project is charging full steam ahead with improvements to the customizer. The most recent release featured the addition of dynamic and contextual controls, sections, and panels. As WordPress 4.2 is kicking off development, core contributors are looking to add menus to the customizer for easy management from the frontend.

More WordPress theme developers are adopting the native customizer to add options to themes, as it provides a standard interface with which users are familiar. One feature that is missing is the ability export and import customizer settings, an option that many pre-customizer theme panels have readily available.

customizer-export-import-settingsCustomizer Export/Import is a plugin that addresses this need by adding the ability for users to export/import settings from any theme or plugin that makes use of the customizer. You’ll need to have the same theme (or plugin) installed on both sites where you are performing the export/import. The export file is named after your theme and you can use it to import the settings for the same theme (or child theme) on another site.

The plugin was created by Justin Busa, a web developer and co-founder at FastLine Media. After spending quite a bit of time with the customizer while migrating a theme options page over to it, Busa was inspired to solve the problem of import/export.

“One of the pieces that had to be migrated was the ability for users to export or import their theme settings,” he said. “That’s a pretty common feature of themes that have a custom options page, but not one that can be standardized since each theme typically has its own way of handling options.”

As he began building export/import functionality for his own theme, he found that it could benefit more developers as a general tool. “I quickly realized that was something that could actually work with any theme. I did some research to see if something like this already existed and it turns out that it didn’t.”

Reusable Configurations for Themes and Plugins

Busa believes that developers who build WordPress sites are most likely to be the ideal users of this plugin as a tool to streamline the process. “This plugin will allow people building many WordPress sites to save different configurations for their favorite themes and reuse them again and again,” he said. “It could also be as simple as exporting the settings you used on a previous site to start a new similar site.”

export-import-messageTheme authors can also add support for the plugin in order to avoid having to spin up their own export/import functionality, as Busa is doing with his current theme. The Export/Import panel in the customizer will prompt the user to install the plugin if he hasn’t already. “Additionally, theme authors could potentially offer any number of presets for their themes that users could import by leveraging this plugin,” Busa said.

Customizer Export/Import is designed to work with any theme or plugin that makes use of the customizer. Busa notes that it does not, however, export settings that aren’t stored in the database as theme mods, which means that it doesn’t currently export widgets, menus or settings such as the built-in “Site Title & Tagline”. The export file output by the plugin contains a serialized dump of mods retrieved using the get_theme_mods function.

“We’ve tested it with many popular themes that use the customizer, including Genesis, Make, and Twenty Fifteen, and it works great,” he said. Busa is not sure if adding the ability to import widgets and menus from other sites makes sense.

“For example, the pages in a menu might not be on the destination site or the widgets in a sidebar might not be installed,” he said. “My initial thinking is that if you need that level of export/import functionality, you’re probably better off with a heavier solution like WP Migrate DB Pro. I’ll be keeping an eye on feedback before making a decision there.”

The Customizer Export/Import plugin is available on WordPress.org. If you are a theme developer or user who finds the plugin to be valuable, make sure to send Busa feedback via the project page on GitHub.

7 Comments


  1. I’m just a little curious, what plugin settings does this version of customizer import/export plugin migrate?

    Report


  2. Hey Sebastien. Thanks for asking! Right now, the only settings it will export are those stored in the database as theme mods. For a plugin’s settings to be exported it would need to be creating customizer controls and settings that aren’t defined as options. I’m not opposed to looking at other ways it can export settings that aren’t stored as theme mods, so if you any suggestions, I’d love to hear them!

    Report


  3. Transferring plugin/themes settings in WordPress is a hard problem to solve as there is no widely used standard. We were actually thinking of developing a two hook API for getting and setting the settings, but that would still need to have adoption with developers. Good effort Justin.

    Report


    1. Thanks, Vladimir! That’s why theme mods really spurred my interest. They are one of the few things in that arena that are standardized. I like your idea for hooks and was actually thinking of working something like that into the plugin, but as you mentioned that would still need to be adopted by developers to make a difference. At the very least, I’m hoping this plugin can spark some awareness/conversation about moving in that direction.

      Report


  4. I love the idea of the plugin but dislike the name. It is a bit misleading. This will not work with all themes that use the customizer. It will probably only work with a handful of plugins because most plugins wouldn’t save their options as theme mods. It would’ve been more accurately named Theme Mods Import/Export.

    See, the Customizer is not an API for storing/retrieving options, so there’s really nothing to import or export. It’s an API for displaying a settings screen. Plugins and themes can store settings in 1 of 4 ways: theme mods, single options, array of options, or something custom. A theme can even use a combination of those methods, depending on the circumstances. The only method that is standardized for figuring out settings is theme mods. With that method, you can grab the correct option from the database.

    Report


    1. Thanks for the input, Justin! You make a good point about the name, although it is an export/import experience that lives in the Customizer, so I think the name still works. One idea that I’ve had to make it more than just a theme mod export/import is to add hooks that developers could tap into for any settings that are stored in a different way. If that were to catch on then I think the current name would be more appropriate.

      Report


  5. It would be nice if there was a php function that we could drop into the functions.php file of a child theme so that it would use the theme mods of the parent theme, and be overwritten by changes in the child theme customizer.

    Kind of the way you enqueue a parent stylesheet then a child stylesheet.

    So use theme mods from parent theme, then theme mods from child theme.

    Report

Comments are closed.