New WordPress Plugin: Color Scheme every Theme

February 25, 2013 The code provided in this article, is available on github.

Download on wordpress.org: Color Scheme every Theme

WordPress 3.4 gave us a tool for theme customization, and I really like the idea. Changing the background color or adding a header image makes even the most downloaded theme on the internet unique. So I had this idea of not only changing the background color, but changing the whole color scheme of a theme and thus building for example a green, red and blue variant of a theme or a dark and a light version. That would both be great for users, to adjust their downloaded themes, and for theme developers, to provide their themes with multiple color schemes.

Three simple steps to make your own color scheme

  1. Generating the css – The first step, after installing and activating the plugin, is scanning your current theme after color-relevant css. Go to the plugins settings page under Settings -> Color scheme every theme and click the generate button. This will scan all the css files in your current theme after colors, generate code to overwrite the default colors and provide you with a color scheme template to add to your functions.php. After clicking the generate button you will see two textfields. The first with the color scheme template …
    if ( function_exists( 'cset_add_color_scheme' ) ) {
    	cset_add_color_scheme( 'scheme-name', array(
    		'$color-1' => '#111111',
    		'$color-2' => '#111111',
    		'$color-3' => '#111111',
    		'$color-4' => '#111111',
    		'$color-5' => '#111111',
    		'$color-6' => '#111111',
    	) );
    }
    

    … and the second with the default colors, found in you theme.

    /**
     * Default colors
     *
     * $color-1: #efefef;
     * $color-2: rgba(0,0,0,0.5);
     * $color-3: rgba(0,0,0,0);
     * $color-4: #fff;
     * $color-5: #000;
     * $color-6: #222;
     */
    
  2. Adding a scheme to the functions.php - Now you only have to add one or more color schemes to your themes functions.php. Just copy and paste the first code-snippet and change the colors as you like. Allowed are all valid css color definitions, inclusive rgb/rgba and hsl/hsla.
  3. Choosing a scheme – It’s almost done, the last step is going to the customize section of your theme an choosing the color scheme. Click in the admin menu on Appearance -> Themes and then on the Customize link of the current theme.screenshot-1

    Now you should see the schemes you created in the Color Schemes section, choose one and see a live preview to the right and save if you want to publish the new scheme.

Next development steps

This plugin is really not much more than a working prototype. I have some ideas, to make it really great.

  • Making the generator work for other themes than the currently activated (even parent/child themes).
  • Saving color schemes in the options, so there are no changes to the functions.php needed.
  • Generating random color schemes or automatically making the default scheme ‘warmer’ or ‘colder’.
  • Testing, bugfixing and discussing

Troubleshooting

If there is something not working, you are welcome to contact me via the comment section of this article or twitter. But check some things first, to make it easier for me to locate the problem:

  1. Check if your WordPress version is 3.4 or higher and if your PHP version is 4.3.0 or higher.
  2. To overwrite the color scheme of your theme, the plugin does save a file in the wp-content/uploads/ directory. So this directory must have write permissions set.
  3. Set the WP_DEBUG constant in your wp-config.php file to true and see if there are any errors shown when you use the plugin.
  4. Try to deactivate all other plugins. If the problem disappears I have to know which plugins you use, to help.
  5. Give me as much information about your system as possible, when you contact me.

What do you think?

Of course I want to hear what your thoughts and experiences are. Is this plugin usable for you, would you like too see some features it doesn’t have at the moment or do you have some color schemes, you want to share? Please comment or contact me on twitter and let me know what you think!

Back Code on github Tweet me Plus me

15 comments on “New WordPress Plugin: Color Scheme every Theme

  1. Stiaan says:

    Hi,

    Love the concept, but when I try to generate a color scheme my content area just go blank (can still see the admin menu on the left). When I go to Customize the bar is there but nothing inside. I’ve tried this on different wordpress installs and with the plugin downloaded from wordpress.org as well as the one on githib.
    Any ideas what might be the problem?
    Thx!

    1. daniel says:

      Hi, mailed you some question and added a troubleshooting section above. I’m sure we can solve this.

      1. Ulrich says:

        I have the same problem as Stiaan. there is a color-scheme-Responsive.tss in the upload folder and I have disabled all plugins. I am running wp3.5.1 and the theme is Responsive. There are no errors from WP_DEBUG that I can see. Server with php version 5.3

      2. daniel says:

        I am still trying to reproduce the bug. Send you some questions via mail. Thanks for reporting.

      3. daniel says:

        Finally solved the white-screen bug. Version 1.1 is available in the plugin directory.

  2. WPExplorer says:

    This plugin looks great can’t wait to test it out.

    Hopefully we can put an end to all these themes with the gazillion of theme options built-in.

    1. daniel says:

      Thanks. I agree, there are way too many themes overplaying the theme options thing.

  3. I activated this plugin and I am having trouble using it! Can you please tell me your email so that I can send you further details of my problems with this plugin.
    alteriaonline@gmail.com

    1. daniel says:

      I’ve send you a mail.

  4. George says:

    Hi There.

    Ive tried generating a colour scheme but i get;
    There was an error while generating the color scheme.

    Check if you have an active and working theme and if there is any css-file in your active theme!

    The site is on a sub domain due to being in development so I’m not sure if that would be the reason. Please email me and I can give you th eurl if need be.

    Thanks

  5. Sanja says:

    I got this error with Twenty Twelve theme installed:

    There is no color scheme generatad for your current theme.

    There was an error while generating the color scheme.
    Check if you have an active and working theme and if there is any css-file in your active theme!

    It is on a multisite installed site. Does this not work with default theme?

    1. daniel says:

      Hi,

      I just tested the plugin with the Twenty-Twelve-theme in a multisite environment and it worked fine. Have you gone through the troubleshooting list?

      Kind regards
      Daniel

  6. [...] 2.0 of my color scheme plugin (read about v1.o here) makes it even more easy to create color schemes for WordPress [...]

  7. Bangzorp says:

    Trying to generate and get this error:

    Warning: Invalid argument supplied for foreach() in /nfs/c07/h01/mnt/99388/domains/blog.mexxywood.tv/html/wp-content/plugins/color-scheme-every-theme/classes/ColorExtractor.class.php on line 9

    Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /nfs/c07/h01/mnt/99388/domains/blog.mexxywood.tv/html/wp-content/plugins/color-scheme-every-theme/classes/ColorExtractor.class.php on line 9

    Warning: Invalid argument supplied for foreach() in /nfs/c07/h01/mnt/99388/domains/blog.mexxywood.tv/html/wp-content/plugins/color-scheme-every-theme/classes/ColorExtractor.class.php on line 45

    Warning: Cannot modify header information – headers already sent by (output started at /nfs/c07/h01/mnt/99388/domains/blog.mexxywood.tv/html/wp-content/plugins/color-scheme-every-theme/classes/ColorExtractor.class.php:9) in /nfs/c07/h01/mnt/99388/domains/blog.mexxywood.tv/html/wp-includes/pluggable.php on line 876

    1. daniel says:

      Hi,

      seems to be the ‘glob’ function, which is making trouble. I’ve sent you a mail with some further questions.

      Thank you so much
      Daniel

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>