This WordPress plugin creates a new control type for the WordPress Theme Customizer. This new control will allow you to pick a theme made up of various options with one click.
An example would be a theme with two different color palettes: a blue theme and a red theme. A user that clicks on the blue theme would then automatically set all other controls to the right settings to make the theme blue.
-
Include & activate the plugin
-
Open your functions.php file
-
Save your themes in an array like so:
$customThemes; // make sure the classes exist before calling them if (class_exists('Theme_Picker_Theme_Collection') && class_exists('Theme_Picker_Theme')) { // assemble data for themes $themes[] = array( "title" => "Theme Number One", "settings" => array( "background_color_control" => "#efefef", "content_background_color_control" => "#ffffff", "text_color_control" => "#4d4d4d", "active_text_color_control" => "#ff3333", "font_family_control" => "Arial" ), "backgroundImage" => "http://example.com/foo.png", "titleColor" => "#ffffff", ); // create new theme collection $customThemes = new Theme_Picker_Theme_Collection($themes); }
- title - the title of the theme
- settings - the settings that this theme controls. The settings field contains an array with
keys
that are the control ids andvalues
that that the value for that property. Note If you're digging through the source code, the control id looks like this<li id="customize-control-FOO">
. WordPress automatically adds thecustomize-control-
to the ID you specify in your functions file. - backgroundImage - the background image that gives users an idea of what the theme looks like before selecting it. I make my images
259px
wide by36px
tall but you can play with the CSS to make them anysize. - titleColor - the color of the title text on top of the background image.
Here is what the theme picker looks like with 6 different themes.
- Can only have one instance of a theme picker
- Requires JavaScript & jQuery
- Settings should use
postMessage
fortransport
or there may be issues with AJAX (untested)
- adding theme background images
- adding title color
- spicing up the theme picker itself
- support for select boxes & input fields
- Initial upload