<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flav36rs &#187; class</title>
	<atom:link href="http://flav36rs.com/tag/class/feed/" rel="self" type="application/rss+xml" />
	<link>http://flav36rs.com</link>
	<description>Just another technical blog</description>
	<lastBuildDate>Mon, 12 Sep 2011 16:56:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>WordPress append page slug to body class</title>
		<link>http://flav36rs.com/2011/02/19/wordpress-append-page-slug-to-body-class/</link>
		<comments>http://flav36rs.com/2011/02/19/wordpress-append-page-slug-to-body-class/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 13:53:15 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[slug]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=775</guid>
		<description><![CDATA[Styling different pages in WordPress is a relatively easy process if you make use of the default body classes that are made available to you, especially the unique page ID class &#8220;page-id-123&#8220;. The problem with using the ID class to &#8230; <a href="http://flav36rs.com/2011/02/19/wordpress-append-page-slug-to-body-class/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Styling different pages in WordPress is a relatively easy process if you make use of the default <a href="http://codex.wordpress.org/Function_Reference/body_class" target="_blank">body classes</a> that are made available to you, especially the unique page ID class &#8220;<em>page-id-123</em>&#8220;.</p>
<p>The <strong>problem</strong> with using the ID class to identify an individual page is that a page ID can quite easily change when working with a development version or even migrating your blog from one install to another.<span id="more-775"></span></p>
<p>One <strong>solution</strong> to this problem is to append the post type and slug as a class name to the body, e.g. &#8216;<em>page-about</em>&#8216; or &#8216;<em>post-hello-world</em>&#8216;.</p>
<p>Simply add the following to your <a href="http://codex.wordpress.org/Theme_Development#Functions_File" target="_blank">functions.php</a> file to automatically append the classes:</p>
<pre lang="php" escaped="true">function add_body_class( $classes )
{
    global $post;
    if ( isset( $post ) ) {
        $classes[] = $post-&gt;post_type . '-' . $post-&gt;post_name;
    }
    return $classes;
}
add_filter( 'body_class', 'add_body_class' );</pre>
<p><strong>Note: </strong>This method will also apply to individual post pages and custom post types.</p>
]]></content:encoded>
			<wfw:commentRss>http://flav36rs.com/2011/02/19/wordpress-append-page-slug-to-body-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress append image dimensions as class names</title>
		<link>http://flav36rs.com/2010/12/05/wordpress-append-image-dimensions-as-class-names/</link>
		<comments>http://flav36rs.com/2010/12/05/wordpress-append-image-dimensions-as-class-names/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 11:53:20 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[dimensions]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[width]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=747</guid>
		<description><![CDATA[When inserting images into post or page content WordPress automatically adds three class name to the image tag along with the other attributes, these are the alignment (alignnone), size (size-full) and the attachment id (wp-image-123). If you need to add &#8230; <a href="http://flav36rs.com/2010/12/05/wordpress-append-image-dimensions-as-class-names/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When inserting images into post or page content WordPress automatically adds three class name to the image tag along with the other attributes, these are the alignment <em>(alignnone)</em>, size <em>(size-full)</em> and the attachment id <em>(wp-image-123)</em>.</p>
<p>If you need to add additional class names to the defaults without having to manually add them every time you insert a new image, you can make use of either the <strong>get_image_tag_class</strong> or <strong>get_image_tag</strong> filters. <span id="more-747"></span></p>
<p>The first of the two filters is <strong>get_image_tag_class</strong>, which allows you to add a value or change the class attribute completely:</p>
<pre lang="php" escaped="true">function add_image_class($class){
	$class .= ' additional-class';
	return $class;
}
add_filter('get_image_tag_class','add_image_class');</pre>
<p>The second function is a little more flexible and provides the ability to alter the image tag completely, thus providing functionality to add the image dimensions to the class names as shown in this example:</p>
<pre lang="php" escaped="true">function add_image_class_dimensions($html, $id, $alt, $title)
{
	if (preg_match('/width="(d+)" height="(d+)"/', $html, $dimensions)) {
		list(,$width, $height) = $dimensions;
		$html = str_replace(
			'class="',
			'class="wp-image-width-'.$width.' wp-image-height-'.$height.' ',
			$html
		);
	}
	return $html;
}
add_filter('get_image_tag', 'add_image_class_dimensions', 10, 4);</pre>
<p>In brief, this function matches the dimensions found within the image tag <em>(width and height)</em> and appends them to the front of the class attribute.</p>
<p>Applying both of these filters will output something similar the following code in the TinyMCE editor:</p>
<pre lang="xhtml" escaped="true">&lt;img class="wp-image-width-200 wp-image-height-100 alignnone size-full wp-image-123" title="Image Title Here" src="/wp-content/uploads/2010/12/my-image.jpg" alt="" width="200" height="100" /&gt;</pre>
<p>To make use of this functionality you will first need to add the filter and function to your theme&#8217;s function.php file. Once this is done, add a new image to your post or page and you will see the custom class names are appended to the image tag. They <strong>will not</strong> be applied to any existing images within your content, you will have to insert them again from the media library for the changes to be applied.</p>
<p>These are only two examples of what results can be achieved, further adjustments and alterations can be easily added using the two get_image_tag filters.</p>
]]></content:encoded>
			<wfw:commentRss>http://flav36rs.com/2010/12/05/wordpress-append-image-dimensions-as-class-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple PHP Sparklines</title>
		<link>http://flav36rs.com/2008/04/12/simple-php-sparklines/</link>
		<comments>http://flav36rs.com/2008/04/12/simple-php-sparklines/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 22:16:24 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[gdlib]]></category>
		<category><![CDATA[sparkline]]></category>

		<guid isPermaLink="false">http://sha.re.it/?p=15</guid>
		<description><![CDATA[Whilst designing a new layout for one of my current projects, I wanted to be able to provide the end user with the ability to quickly scan over a series of statistics. The main page should act as overview of &#8230; <a href="http://flav36rs.com/2008/04/12/simple-php-sparklines/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Whilst designing a new layout for one of my current projects, I wanted to be able to provide the end user with the ability to quickly scan over a series of statistics.</p>
<p>The main page should act as overview of everything that is going on, therefore I wanted to avoid overcrowding it with lots of large graphs and instead simply show the basic trends.</p>
<p>A few months back I came across an implementation of <a title="Sparkline From Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Sparkline" target="_blank">Sparklines</a> &#8211; data-intense, design-simple, word-sized graphics &#8211; which are often used to demonstrate stock market activity in a simple visual graphic.</p>
<p>I was just going to use a pre-made script from the many already available, but instead decided to knock one up myself and created a small <a title="PHP Class Source Code" href="http://sha.re.it/wp-content/examples/sparkline/sparkline.class.phps" target="_blank">PHP Class</a> to generate and output a sparkline image using the GD Library.</p>
<p>To create a sparkline I can now simply include the class and then initiate it in a variation of the following:</p>
<pre lang="php">$sparkline = new Sparkline();
$sparkline-&gt;data = Array(3,38,2,8, ... ,38,13,4,23);
$sparkline-&gt;output(); // Display image</pre>
<p>This PNG image is generated and output to the browser:</p>
<p style="text-align: center;"><img src="http://sha.re.it/wp-content/examples/sparkline/example1.php" alt="Example Sparkline" width="120" height="40" /></p>
<p style="text-align: left;">A number of other setup options are available to customise the output further:</p>
<pre lang="php">$sparkline-&gt;bg = '#000000'; // Background colour
$sparkline-&gt;width = 150;
$sparkline-&gt;height = 50;
$sparkline-&gt;line = '#336699'; // Line colour
$sparkline-&gt;points = '#333333'; // Start &amp; end points
$sparkline-&gt;thickness = 2; // Line thickness
$sparkline-&gt;scale = 5; // Anti-aliasing scale size
$sparkline-&gt;output('saved/test.png', true); // Save to location and display</pre>
<p style="text-align: center;"><img src="http://sha.re.it/wp-content/examples/sparkline/example2.php" alt="Customised Sparkline" width="180" height="60" /></p>
<p style="text-align: left;">All colours must be provided in hexadecimal format and if you are attempting to save the image the destination location must be writeable by Apache.</p>
<p style="text-align: left;">The <a title="PHP Class Source Code" href="http://sha.re.it/wp-content/examples/sparkline/sparkline.class.phps" target="_blank">Sparkline PHP Class source code</a> is available for anyone to use as they may like, although I must confess it hasn&#8217;t been fully tested as yet!</p>
]]></content:encoded>
			<wfw:commentRss>http://flav36rs.com/2008/04/12/simple-php-sparklines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

