I’m not sure if this was a waste of time, but I’m not in love with the colors I’m using on my site. When I built the theme, I kind of knew I’d get tired of the colors, so I made an index at the top showing what colors were used, it looks like this:
/* Colors Used:==================== dark brown:#85605d; darkest brown:#70564F; slate blue:#acb6bd light blu:#e1f5ff deep grey-blue :#637486 */
This was helpful for using a find/replace method, but if I wanted to add dynamic controls to the theme I’d have to create a new stylesheet to override the original one in case I wanted to go with a different color scheme, which would be kind of time consuming, and not easily sustainable.
So I pulled everything out except the theme info from the style.css and included a php file called style.php, wrapped the stylesheet in a style tag, and added variables that are echoed throughout the file. Like so:
$lightColor1 = '#e1f5ff'; $medColor1 = '#637486'; $blogEntryText = '#333333'; $darkColor1 = '#acb6bd'; $color2 = '#70564F';
This allows me to easily tweak my colors, like an automatic find/replace, but I still am not handling my background images, which are also based around the same color scheme, so I added these lines:
$logoImage = ''. get_bloginfo('template_url') .'/images/logo-geekout.gif';
$banner1FoldLeft = ''. get_bloginfo('template_url') .'/images/bg-fold-blue-left.png';
$banner1FoldRight = ''. get_bloginfo('template_url') .'/images/bg-fold-right.png';
$banner2FoldLeft = ''. get_bloginfo('template_url') .'/images/bg-fold-brown-left.png';
$commentsBanner = ''. get_bloginfo('template_url') .'/images/bg-comments-banner.png';
$commentbgEven = 'url('. get_bloginfo('template_url') .'/images/bg-comments-odd-brown.png)';
$commentbgOdd = 'url('. get_bloginfo('template_url') .'/images/bg-comments-even-blue.png)';
Now I can get at my colors and a lot of my images quickly. This is kind of a precursor to something else I’m working on, but I thought I’d share.
Note: I realize I could use a CSS framework like Compass to create color variables, but that’s a different purpose than what I need. I want something I can get at later…through the WordPress backend.
I posted this video to http://screenr.com today, you can see it at http://screenr.com/J2h. This site is an incredible resource, which I plan on using a few more times in the next week or so. Below is the video.
Watch in full screen to see the code more clearly.
Other Posts in this SeriesFirst Screencas…
If today I could use CSS3 on every site I built, it would be a dream come true, but the fact of the matter is that I can’t. That is to say, that I can’t rely on it. The reason is due to browser support and market share.
On this site, almost everything is CSS and CSS2. I don’t use CSS3 commonl…
Well, I’ve finally updated the WordPress bundle from the previous release. In this bundle I’ve included some fairly neat snippets. Almost all of them are wrapped in the brackets. Below is a screenshot of what snippets the bundle contains.
Why are these snippets helpful?
Textmate sni…
Obviously, if you’re not going to post mp3s to your site very often, the easy solution is to paste the embed code into your individual post or page using HTML mode, but you might have a need to embed an mp3 on a regular basis. This tutorial will show how to use the embeddable player mentioned in my in…
Tim and I finished a plugin today. It is the first plugin that we are officially releasing to the public. The plugin title is “Category Expander”. You can see it in action on the sidebar. Through the settings menu in the WordPress dashboard, you can choose which categories you’d l…
A few weeks ago I wanted to add an mp3 to my daughter’s baby book blog (built on WordPress). At first I thought to install a plugin, but it seemed a bit much for my needs. After trying a few things, I eventually settled on a nice theme-integrated method that uses a google flash-based mp3 player. I…
Did you know you can register multiple Widget locations in WordPress (self hosted blogs of course)? Well, you can. All you have to do is go to your functions.php file (default usage in /wp-content/themes/default/functions.php), where you’ll see something that looks like this:
register_…
Just about every Tuesday, my wife and I take my daughter to Chic-fil-A for dinner. We love our experience there and our daughter does too. The environment is terrific, and after giving it a lot of thought, here’s why.
1. The people who work there at least behave as if they enjoy their job.
In the ci…
{0}