CINXE.COM

bavotasan.com

<?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>bavotasan.com</title> <atom:link href="http://bavotasan.com/feed/" rel="self" type="application/rss+xml" /> <link>http://bavotasan.com</link> <description>by c.bavota</description> <lastBuildDate>Fri, 20 Aug 2010 19:01:51 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item> <title>Create bit.ly Short URLs for your Posts in WordPress</title> <link>http://bavotasan.com/tutorials/create-bit-ly-short-urls-for-your-posts-in-wordpress/</link> <comments>http://bavotasan.com/tutorials/create-bit-ly-short-urls-for-your-posts-in-wordpress/#comments</comments> <pubDate>Fri, 20 Aug 2010 18:48:00 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[bit.ly]]></category> <category><![CDATA[functions.php]]></category> <category><![CDATA[hacks]]></category> <category><![CDATA[mods]]></category> <category><![CDATA[short urls]]></category> <category><![CDATA[shortlinks]]></category> <category><![CDATA[tweets]]></category> <category><![CDATA[Twitter]]></category> <category><![CDATA[WordPress]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2668</guid> <description><![CDATA[I have been working with the http://bit.ly API and decided to change the short URLs on my site to include the short URLs provided by http://bit.ly. The API is pretty straightforward and I created a few WordPress functions to to get it all working. Before we even start, you would need to registered with http://bit.ly [...]]]></description> <content:encoded><![CDATA[<p>I have been working with the <a href="http://bit.ly/">http://bit.ly</a> API and decided to change the short URLs on my site to include the short URLs provided by <a href="http://bit.ly/">http://bit.ly</a>. The API is pretty straightforward and I created a few WordPress functions to to get it all working.</p> <p>Before we even start, you would need to registered with <a href="http://bit.ly/">http://bit.ly</a> and then check out this page <a href="http://bit.ly/a/your_api_key">http://bit.ly/a/your_api_key</a> to get your API key and your login.</p> <p>Now, let&#8217;s add a function to automatically create a <a href="http://bit.ly/">http://bit.ly</a> short URL when you publish a post. We will hook into the <code>publish_post</code> action and then use the <a href="http://bit.ly/">http://bit.ly</a> API to fetch a shortened URL. Place the following into your theme&#8217;s <code>function.php</code> file.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'publish_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'create_bitly'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">function</span> create_bitly<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span> <span style="color: #000088;">$login</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'YOUR LOGIN'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change this to your login</span> <span style="color: #000088;">$apikey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'YOUR API KEY'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change this to your API key</span> &nbsp; <span style="color: #000088;">$longURL</span> <span style="color: #339933;">=</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// here we get the permalink to your post</span> &nbsp; <span style="color: #666666; font-style: italic;">// This is the API call to fetch the shortened URL</span> <span style="color: #000088;">$apiurl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://api.bit.ly/v3/shorten?longUrl='</span><span style="color: #339933;">.</span><span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$longURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;login='</span><span style="color: #339933;">.</span><span style="color: #000088;">$login</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;apiKey='</span><span style="color: #339933;">.</span><span style="color: #000088;">$apikey</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// We are using cURL</span> <span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$apiurl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$shortURL</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$results</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// the short URL</span> &nbsp; update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bitlyURL'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$shortURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// adding the short URL to a custom field called bitlyURL</span> <span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div> <p>You can read more about the <a href="http://bit.ly/">http://bit.ly</a> API here: <a href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation">http://code.google.com/p/bitly-api/wiki/ApiDocumentation</a></p> <p>In order to add your new short URL to your header, you first need to remove the default shortlink tag and then create a function that will place the proper code between your <code>&lt;head&gt;</code> tags.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">remove_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_shortlink_wp_head'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// removing the default shortlink</span> add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bilty_shortlink_head'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// adding the new bit.ly shortlink</span> &nbsp; <span style="color: #000000; font-weight: bold;">function</span> bilty_shortlink_head<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span> <span style="color: #000088;">$shortURL</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bitlyURL'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$shortURL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;link rel=&quot;shortlink&quot; href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$shortURL</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;link rel=&quot;shortlink&quot; href=&quot;'</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?p='</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div> <p>If you want to display your new short URLs, you can do so by using the `wp_get_shortlink()` function. But first you need to make sure that WordPress knows to replace the default short URL with the new <a href="http://bit.ly/">http://bit.ly</a> short URL.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_shortlink'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'get_bitly_shortlink'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// filtering the WP function</span> &nbsp; <span style="color: #000000; font-weight: bold;">function</span> get_bitly_shortlink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span> <span style="color: #000088;">$shortURL</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bitlyURL'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$shortURL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$shortURL</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?p='</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div> <p>You can place the following code anywhere within the loop of your <code>single.php</code> theme file to display your short URL.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">Short URL: &lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> wp_get_shortlink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> wp_get_shortlink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;</pre></div></td></tr></table></div> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/tutorials/create-bit-ly-short-urls-for-your-posts-in-wordpress/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item> <title>Optimizing your MySQL Database</title> <link>http://bavotasan.com/tutorials/optimizing-your-mysql-database/</link> <comments>http://bavotasan.com/tutorials/optimizing-your-mysql-database/#comments</comments> <pubDate>Tue, 17 Aug 2010 15:20:12 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[database]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[mysqlcheck]]></category> <category><![CDATA[mysqltuner]]></category> <category><![CDATA[optimize mysql]]></category> <category><![CDATA[root]]></category> <category><![CDATA[shell]]></category> <category><![CDATA[ssh]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2658</guid> <description><![CDATA[I run my Web sites on a dedicated virtual server and every once in a while, I need to go in and optimize things to make sure everything runs smoothly. I am not an expert when it comes to shell commands, but do I know a few that really help keep things working the way [...]]]></description> <content:encoded><![CDATA[<p>I run my Web sites on a dedicated virtual server and every once in a while, I need to go in and optimize things to make sure everything runs smoothly. I am not an expert when it comes to shell commands, but do I know a few that really help keep things working the way they should. </p> <p>One of the most important things I have come to realize is that you must keep an eye on your MySQL tables, because a problematic database can slow down your server dramatically. Databases that see a lot of queries often become fragmented and these are the databases that can start to cause you some problems. Luckily, there is a shell command that can go in and do all your de-fragmenting and optimizing for you.</p> <p>I always make sure to back things up before I run this, just in case.</p> <p>This command must be run from the shell and you need to be logged in as a root user:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="sql" style="font-family:monospace;">mysqlcheck <span style="color: #66cc66;">-</span>u root <span style="color: #66cc66;">-</span>p <span style="color: #808080; font-style: italic;">--auto-repair --check --optimize --all-databases</span></pre></div></td></tr></table></div> <p>Once the command has been entered, you will need to input your password. Then you will see it list through your database tables one by one as it works it magic.</p> <p>You can read up on the <a href="http://dev.mysql.com/doc/refman/5.0/en/mysqlcheck.html">mysqlcheck</a> command to understand exactly what it does.</p> <p>Another worthwhile tool is <a href="http://blog.mysqltuner.com/">MySQLTuner</a>. It can help you with recommendations on how to configure your MySQL to increase performance and stability. I use it every month too see if anything has been acting up and that is a good routine to get into to keep your sites running their best.</p> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/tutorials/optimizing-your-mysql-database/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item> <title>How to Draw a Smiley Face with CSS3</title> <link>http://bavotasan.com/tutorials/draw-smiley-face-css3/</link> <comments>http://bavotasan.com/tutorials/draw-smiley-face-css3/#comments</comments> <pubDate>Tue, 10 Aug 2010 22:52:43 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[behold]]></category> <category><![CDATA[Chrome]]></category> <category><![CDATA[Circles]]></category> <category><![CDATA[course]]></category> <category><![CDATA[css3]]></category> <category><![CDATA[deg]]></category> <category><![CDATA[div]]></category> <category><![CDATA[failed attempts]]></category> <category><![CDATA[ffe]]></category> <category><![CDATA[gradients]]></category> <category><![CDATA[height]]></category> <category><![CDATA[html]]></category> <category><![CDATA[inset]]></category> <category><![CDATA[inspiration]]></category> <category><![CDATA[lefteye]]></category> <category><![CDATA[linear gradient]]></category> <category><![CDATA[ovals]]></category> <category><![CDATA[position]]></category> <category><![CDATA[power]]></category> <category><![CDATA[radius]]></category> <category><![CDATA[random shapes]]></category> <category><![CDATA[rgba]]></category> <category><![CDATA[safari]]></category> <category><![CDATA[smile]]></category> <category><![CDATA[smiley face]]></category> <category><![CDATA[smileyface]]></category> <category><![CDATA[something]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2643</guid> <description><![CDATA[I was messing around with CSS3 gradients, rounded corners and shadows, and I thought to myself, &#8220;I wonder if I can draw something that actually looks like something?&#8221; Lo and behold, I could. I decided to go with a smiley face, since it would need circles, ovals and some random shapes. It would also require [...]]]></description> <content:encoded><![CDATA[<p>I was messing around with CSS3 gradients, rounded corners and shadows, and I thought to myself, &#8220;I wonder if I can draw something that actually looks like something?&#8221; Lo and behold, I could. I decided to go with a smiley face, since it would need circles, ovals and some random shapes. It would also require gradients and shadows. After a few failed attempts, I somehow managed to figure it out and the outcome is pretty cool.</p> <div class="smileyface"> <p class="eyes lefteye"> <p class="eyes righteye"> <div class="smile"> <div class="corner"></div> <div class="corner right"></div> </p></div> </div> <p>It really amazes me that CSS3 has the power to create something like this. I tested it out in Firefox, Safari and Chrome. They all look good. Of course, in IE it looks like this&#8230;</p> <p><a href="http://bavotasan.com/wp-content/uploads/2010/08/smileyie.jpg"><img src="http://bavotasan.com/wp-content/uploads/2010/08/smileyie.jpg" alt="" title="smileyie" width="300" height="300" class="nobox aligncenter size-full wp-image-2654" /></a></p> <p>It&#8217;s like IE is living in 1986.</p> <p>Here is the HTML:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;smileyface&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>p <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;eyes lefteye&quot;</span><span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>p <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;eyes righteye&quot;</span><span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;smile&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;corner&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;corner right&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div> <p>Here is the CSS:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.smileyface</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ffe632</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#fffe8d</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#f6d23e</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#fffe8d</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#f6d23e</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">inset</span> <span style="color: #933;">0px</span> <span style="color: #933;">-14px</span> <span style="color: #933;">14px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> .3<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">2px</span> <span style="color: #933;">20px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> .6<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">inset</span> <span style="color: #933;">0px</span> <span style="color: #933;">-14px</span> <span style="color: #933;">14px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> .3<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">2px</span> <span style="color: #933;">20px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> .6<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">inset</span> <span style="color: #933;">0px</span> <span style="color: #933;">-14px</span> <span style="color: #933;">14px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> .3<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">2px</span> <span style="color: #933;">20px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> .6<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> &nbsp; p<span style="color: #6666ff;">.eyes</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#222</span><span style="color: #00AA00;">;</span> border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span>/<span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span>/<span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span> box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> &nbsp; p<span style="color: #6666ff;">.eyes</span><span style="color: #6666ff;">.lefteye</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">75px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> &nbsp; p<span style="color: #6666ff;">.eyes</span><span style="color: #6666ff;">.righteye</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">75px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> &nbsp; div<span style="color: #6666ff;">.smile</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">70px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#222</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">120px</span> <span style="color: #933;">120px</span> / <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">90px</span> <span style="color: #933;">90px</span><span style="color: #00AA00;">;</span> -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">120px</span> <span style="color: #933;">120px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">90px</span> <span style="color: #933;">90px</span><span style="color: #00AA00;">;</span> border-radius<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">120px</span> <span style="color: #933;">120px</span> / <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">90px</span> <span style="color: #933;">90px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">38px</span><span style="color: #00AA00;">;</span> box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> &nbsp; div<span style="color: #6666ff;">.corner</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">30px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#222</span><span style="color: #00AA00;">;</span> border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span>/<span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span>/<span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-12px</span><span style="color: #00AA00;">;</span> -webkit-transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>65deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -moz-transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>65deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-12px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> &nbsp; div<span style="color: #6666ff;">.corner</span><span style="color: #6666ff;">.right</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">202px</span><span style="color: #00AA00;">;</span> -webkit-transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>-65deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> -moz-transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>-65deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div> <p>Inspiration:</p> <ul> <li><a href="http://desandro.com/articles/opera-logo-css/">http://desandro.com/articles/opera-logo-css/</a></li> <li><a href="http://cordobo.com/wp-content/uploads/ie-pure-css-logo/">http://cordobo.com/wp-content/uploads/ie-pure-css-logo/</a></li> </ul> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/tutorials/draw-smiley-face-css3/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item> <title>Use jQuery to Replace a Word with a Link</title> <link>http://bavotasan.com/tutorials/jquery-replace-word-with-link/</link> <comments>http://bavotasan.com/tutorials/jquery-replace-word-with-link/#comments</comments> <pubDate>Mon, 09 Aug 2010 20:54:46 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[body]]></category> <category><![CDATA[core function]]></category> <category><![CDATA[footer]]></category> <category><![CDATA[Function]]></category> <category><![CDATA[google]]></category> <category><![CDATA[head]]></category> <category><![CDATA[ig]]></category> <category><![CDATA[instance]]></category> <category><![CDATA[javascript replace function]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[Lt]]></category> <category><![CDATA[multiple times]]></category> <category><![CDATA[page]]></category> <category><![CDATA[piece]]></category> <category><![CDATA[posttop]]></category> <category><![CDATA[search]]></category> <category><![CDATA[site]]></category> <category><![CDATA[slash]]></category> <category><![CDATA[text]]></category> <category><![CDATA[thePage]]></category> <category><![CDATA[var]]></category> <category><![CDATA[way]]></category> <category><![CDATA[Word]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2615</guid> <description><![CDATA[If you use a word multiple times on your site and you don&#8217;t feel like going through all your posts to replace every instance of it, you can use jQuery to search your page and do the replacing for you. I wanted to replace a word throughout an entire site with a link and all [...]]]></description> <content:encoded><![CDATA[<p>If you use a word multiple times on your site and you don&#8217;t feel like going through all your posts to replace every instance of it, you can use jQuery to search your page and do the replacing for you. I wanted to replace a word throughout an entire site with a link and all it took was a small piece of code. </p> <p>If you don&#8217;t already have jQuery loaded into your page, include this before your closing <code>&lt;head&gt;</code>.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">'text/javascript'</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div> <p>That will load up jQuery from Google.</p> <p>Now you just need to include this in your site&#8217;s footer, before the closing <code>&lt;body&gt;</code>. (Why in the footer? Because including your JavaScript after all of your code is the efficient way to do it.)</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> thePage <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> thePage.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>thePage.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/jQuery/ig</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&lt;a href=&quot;http://jquery.com&quot;&gt;jQuery&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div> <p>Since jQuery doesn&#8217;t have a core function for replacing text, we will use the JavaScript <code><a href="http://www.w3schools.com/jsref/jsref_replace.asp">replace()</a></code> function. The <code>i</code> after the slash makes the search and replace case-insensitive, and the <code>g</code> makes it global. </p> <p>I have the script working on this page to replace every instance of the word jQuery with a link to the jQuery Web site.</p> <p><script type="text/javascript"> (function($) { $(".posttop p").each(function() { $(this).html($(this).html().replace(/jQuery/ig, '<a href="http://jquery.com">jQuery</a>')); }); })(jQuery) </script></p> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/tutorials/jquery-replace-word-with-link/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item> <title>A Simple CSS Trick to Vertically Align Text</title> <link>http://bavotasan.com/tutorials/a-simple-css-trick-to-vertically-align-text/</link> <comments>http://bavotasan.com/tutorials/a-simple-css-trick-to-vertically-align-text/#comments</comments> <pubDate>Thu, 05 Aug 2010 17:33:08 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[absolute positioning]]></category> <category><![CDATA[Align]]></category> <category><![CDATA[Center]]></category> <category><![CDATA[Containers]]></category> <category><![CDATA[css]]></category> <category><![CDATA[css trick]]></category> <category><![CDATA[DIGGING]]></category> <category><![CDATA[div]]></category> <category><![CDATA[fff]]></category> <category><![CDATA[Hmm]]></category> <category><![CDATA[line]]></category> <category><![CDATA[magic]]></category> <category><![CDATA[overkill]]></category> <category><![CDATA[positioning]]></category> <category><![CDATA[solution]]></category> <category><![CDATA[technique]]></category> <category><![CDATA[text]]></category> <category><![CDATA[trick]]></category> <category><![CDATA[way]]></category> <category><![CDATA[Width]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2604</guid> <description><![CDATA[I was trying to vertically align text within a div container and it just wasn&#8217;t working for me. You would think that using vertical-align in your CSS would accomplish just that, but you would be wrong. I found a way to do it using three div containers and absolute positioning but I felt that was [...]]]></description> <content:encoded><![CDATA[<p>I was trying to vertically align text within a div container and it just wasn&#8217;t working for me. You would think that using <code>vertical-align</code> in your CSS would accomplish just that, but you would be wrong. I found a way to do it using three div containers and absolute positioning but I felt that was a little overkill for my purposes. </p> <p>This was the box I was designing:</p> <div style="width: 100px; height: 100px; background: #666; color: #fff; text-align: center; text-shadow: none;">Some Text</div> <p>After doing a lot of digging around, I discovered that you could set the line-height of your text to be the same as the height of your div container and this is what you would get:</p> <div style="width: 100px; height: 100px; background: #666; color: #fff; text-align: center; text-shadow: none; line-height: 100px;">Some Text</div> <p>That did it. </p> <p>Here is the CSS I used:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* where the magic happens */</span> <span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div> <p>The only way this technique wouldn&#8217;t work for you was if you had text on two lines, then the second line would be 100 pixels below the first. Hmm&#8230; maybe I could figure out a solution to that one as well.</p> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/tutorials/a-simple-css-trick-to-vertically-align-text/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item> <title>Moderno v1.0 Premium WordPress Theme</title> <link>http://bavotasan.com/articles/moderno-v1-0-premium-wordpress-theme/</link> <comments>http://bavotasan.com/articles/moderno-v1-0-premium-wordpress-theme/#comments</comments> <pubDate>Mon, 02 Aug 2010 20:00:57 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[Column Layout]]></category> <category><![CDATA[com]]></category> <category><![CDATA[crowd]]></category> <category><![CDATA[exquisite design]]></category> <category><![CDATA[face kits]]></category> <category><![CDATA[font]]></category> <category><![CDATA[infinite]]></category> <category><![CDATA[infinite number]]></category> <category><![CDATA[info]]></category> <category><![CDATA[look]]></category> <category><![CDATA[Moderno]]></category> <category><![CDATA[number]]></category> <category><![CDATA[original look]]></category> <category><![CDATA[Placing]]></category> <category><![CDATA[possibilities]]></category> <category><![CDATA[premium]]></category> <category><![CDATA[Select]]></category> <category><![CDATA[site]]></category> <category><![CDATA[subtle nuances]]></category> <category><![CDATA[theme]]></category> <category><![CDATA[Themes]]></category> <category><![CDATA[web]]></category> <category><![CDATA[web font]]></category> <category><![CDATA[Widgets]]></category> <category><![CDATA[WordPress]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=1807</guid> <description><![CDATA[Just updated for WordPress 3.0. Moderno has a beautifully simple, yet exquisite design with many subtle nuances that make it stand out from the crowd. An optional two or three column layout with an infinite number of color and font possibilities make it easy to create a truly original look for your Web site. Go [...]]]></description> <content:encoded><![CDATA[<p><strong>Just updated for WordPress 3.0.</strong></p> <p><a href="http://themes.bavotasan.com/our-themes/premium-themes/moderno">Moderno</a> has a beautifully simple, yet exquisite design with many subtle nuances that make it stand out from the crowd. An optional two or three column layout with an infinite number of color and font possibilities make it easy to create a truly original look for your Web site. Go crazy placing your favorite widgets in up to three widgetized locations. Select a standardized Web font or get a little more creative with one of ten pre-installed @font-face kits.<br /> <span id="more-1807"></span><br /> <a class="highslide" href="http://bavotasan.com/wp-content/uploads/2010/03/moderno_final.jpg"><img src="http://bavotasan.com/wp-content/uploads/2010/03/moderno_final-373x600.jpg" alt="" title="moderno_final" width="373" height="600" class="aligncenter size-medium wp-image-1808" /></a></p> <p>Go to <a href="http://themes.bavotasan.com/our-themes/premium-themes/moderno">Themes by bavotasan.com</a> for more info.</p> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/articles/moderno-v1-0-premium-wordpress-theme/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item> <title>Using Ajax with WordPress</title> <link>http://bavotasan.com/tutorials/using-ajax-with-wordpress/</link> <comments>http://bavotasan.com/tutorials/using-ajax-with-wordpress/#comments</comments> <pubDate>Mon, 02 Aug 2010 18:53:53 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[admin]]></category> <category><![CDATA[ajax]]></category> <category><![CDATA[approval]]></category> <category><![CDATA[custom scripts]]></category> <category><![CDATA[Email]]></category> <category><![CDATA[feedback]]></category> <category><![CDATA[file]]></category> <category><![CDATA[form]]></category> <category><![CDATA[Function]]></category> <category><![CDATA[List]]></category> <category><![CDATA[look]]></category> <category><![CDATA[magazine]]></category> <category><![CDATA[mailing]]></category> <category><![CDATA[person]]></category> <category><![CDATA[way]]></category> <category><![CDATA[WordPress]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2586</guid> <description><![CDATA[A little while back, I updated Magazine Basic and added the Ajax save function. When I uploaded it to WordPress to await approval, I received some feedback on how I could incorporate Ajax using the admin-ajax.php file instead of the sloppy way I had it coded. All of the core Ajax functions in WordPress rely [...]]]></description> <content:encoded><![CDATA[<p>A little while back, I updated Magazine Basic and added the Ajax save function. When I uploaded it to WordPress to await approval, I received some feedback on how I could incorporate Ajax using the <code>admin-ajax.php</code> file instead of the sloppy way I had it coded. All of the core Ajax functions in WordPress rely on <code>admin-ajax.php</code> and using it for custom scripts is extremely easy to implement. </p> <p>Let&#8217;s take a look at all the pieces you need to get it working. In this example I will build a small mailing list function that will send out an email to the admin when a person clicks submit.</p> <p>Here&#8217;s our form:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">&lt;form method=&quot;post&quot; id=&quot;mailinglist&quot; action=&quot;&quot;&gt; &lt;div id=&quot;message&quot;&gt;&lt;/div&gt; &lt;input type=&quot;text&quot; name=&quot;mailinglistemail&quot; id=&quot;mailinglistemail&quot; /&gt; &lt;input type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;mailinglistsubmit&quot; value=&quot;Join&quot; /&gt;&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> admin_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/wp-admin/images/wpspin_light.gif&quot; alt=&quot;&quot; class=&quot;ajaxsave&quot; style=&quot;display: none;&quot; /&gt; &lt;/form&gt;</pre></div></td></tr></table></div> <p>Here&#8217;s the jQuery:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistemail&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please enter your email address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> email <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mailinglistemail'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>email.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;@&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">||</span> email.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please enter a valid email address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> action<span style="color: #339933;">:</span> <span style="color: #3366CC;">'join_mailinglist'</span><span style="color: #339933;">,</span> email<span style="color: #339933;">:</span> email <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistsubmit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ajaxsave&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> jQuery.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;?php echo admin_url('admin-ajax.php'); ?&gt;&quot;</span><span style="color: #339933;">,</span> data<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ajaxsave&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistsubmit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div> <p>Let me explain each part. </p> <p>When a user clicks submit, we need to check that the email field is not empty. If it is empty, we let the user know by sending the &#8220;Please enter your email address.&#8221; message and we stop the form from being submitted by including the <code>return false;</code> line.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistemail&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please enter your email address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div> <p>Next, we&#8217;ll do a simple validation to make sure the email address actually contains the @ symbol and a period. If not, send an error message and return false.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> email <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mailinglistemail'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>email.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;@&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">||</span> email.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please enter a valid email address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div> <p>Once all that is done and everything is good, we can submit our form. This is where <code>admin-ajax.php</code> comes into play. When using <code>admin-ajax.php</code>, you need to include an action callback to make it work. Our callback is <code>join_mailinglist</code>. This is going to interact with our PHP to make everything work on the backend. Let&#8217;s create a data variable to store our action and our email value.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> action<span style="color: #339933;">:</span> <span style="color: #3366CC;">'join_mailinglist'</span><span style="color: #339933;">,</span> email<span style="color: #339933;">:</span> email <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div> <p>Now we will hide our submit button and have a loader graphic appear to let people know something is going on. Then will will use the jQuery <a href="http://api.jquery.com/jQuery.post/">.post</a> function to send everything out to the <code>admin-ajax.php</code> file. Once the function is complete and a response is given, the loader will disappear, the submit button will return and a success message, or error message will indicate what happened.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistsubmit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ajaxsave&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> jQuery.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;?php echo admin_url('admin-ajax.php'); ?&gt;&quot;</span><span style="color: #339933;">,</span> data<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ajaxsave&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglistsubmit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mailinglist #message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div> <p>With the form and the jQuery in place, all we need now is some PHP. </p> <p>The <code>admin-ajax.php</code> file requires two action filters.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_my_action'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_action_callback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_nopriv_my_action'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_action_callback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div> <p>The first action will only work if users are logged in. The second is if users don&#8217;t have to be logged in. For our requirements, it should look like this:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_join_mailinglist'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'join_mailinglist_callback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_ajax_nopriv_join_mailinglist'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'join_mailinglist_callback'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div> <p>Here is our join_mailinglist_callback function, which needs to be added to <code>functions.php</code>:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> join_mailinglist_callback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$yourEmail</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'c@bavotasan.com'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Add me to your mailing list'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$success</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourEmail</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$success</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Your email is subscribed to our mailing list.'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'There was a problem. Please try again.'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div> <p>With everything in place, you will get a form that works like the one below.</p> <form method="post" id="mailinglist" action=""> <div id="message"></div> <input type="text" name="mailinglistemail" id="mailinglistemail" /> <input type="submit" name="submit" id="mailinglistsubmit" value="Join" /><img src="http://bavotasan.com/wp-admin/images/wpspin_light.gif" alt="" class="ajaxsave" style="display: none;" /><br /> </form> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/tutorials/using-ajax-with-wordpress/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item> <title>Great Font Resources for Web Development</title> <link>http://bavotasan.com/articles/great-font-resources/</link> <comments>http://bavotasan.com/articles/great-font-resources/#comments</comments> <pubDate>Tue, 27 Jul 2010 14:20:25 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[api]]></category> <category><![CDATA[APIs]]></category> <category><![CDATA[custom fonts]]></category> <category><![CDATA[david chester]]></category> <category><![CDATA[Desktop]]></category> <category><![CDATA[desktop publishing]]></category> <category><![CDATA[development]]></category> <category><![CDATA[download]]></category> <category><![CDATA[equivalents]]></category> <category><![CDATA[face kits]]></category> <category><![CDATA[flash]]></category> <category><![CDATA[font resources]]></category> <category><![CDATA[Fonts]]></category> <category><![CDATA[google]]></category> <category><![CDATA[Loader]]></category> <category><![CDATA[new fonts]]></category> <category><![CDATA[others resources]]></category> <category><![CDATA[range]]></category> <category><![CDATA[Replacement]]></category> <category><![CDATA[Squirrel]]></category> <category><![CDATA[subscription costs]]></category> <category><![CDATA[text elements]]></category> <category><![CDATA[Tool]]></category> <category><![CDATA[type]]></category> <category><![CDATA[type foundries]]></category> <category><![CDATA[typeface]]></category> <category><![CDATA[TypeKit]]></category> <category><![CDATA[using flash]]></category> <category><![CDATA[way]]></category> <category><![CDATA[WebFont]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2517</guid> <description><![CDATA[Ever since I wrote Embedding Fonts in your Web Site with CSS and @font-face many people have been emailing me with questions about adding new fonts to their sites. One of the easiest ways is with The New Google Font API but there are also a few others resources available. Here is a list of [...]]]></description> <content:encoded><![CDATA[<p>Ever since I wrote <a href="http://bavotasan.com/tutorials/embedding-fonts-web-site-css-font-face/">Embedding Fonts in your Web Site with CSS and @font-face</a> many people have been emailing me with questions about adding new fonts to their sites. One of the easiest ways is with <a href="http://bavotasan.com/articles/google-font-api/">The New Google Font API</a> but there are also a few others resources available. Here is a list of places to find fonts and tools you can use to include them in your Web site.</p> <h3>Font Squirrel</h3> <p><img src="http://bavotasan.com/wp-content/uploads/2010/07/fontsquirrel.jpg" alt="Font Squirrel" title="fontsquirrel" width="550" height="160" class="alignleft size-full wp-image-2572" /><br /> Font Squirrel has an amazing library of free commercial-use fonts. All of the @font-face kits that are available in my <a href="http://themes.bavotasan.com/category/premium-themes/">Premium themes</a> come from Font Squirrel. You can download fonts to use in desktop publishing or you can grab some @font-face kits to use on your Web site. There is even a handy, simple to use tool for converting standard fonts into @font-face kits for embedding on your Web site.<br /> <a href="http://www.fontsquirrel.com/">http://www.fontsquirrel.com/</a></p> <h3>Google Font API</h3> <p><img src="http://bavotasan.com/wp-content/uploads/2010/07/googlefont.jpg" alt="Google Font API" title="googlefont" width="550" height="160" class="alignleft size-full wp-image-2564" /><br /> I wrote about this one already so just check out <a href="http://bavotasan.com/articles/google-font-api/">that article</a>.</p> <h3>TypeKit</h3> <p><img src="http://bavotasan.com/wp-content/uploads/2010/07/typekit.jpg" alt="TypeKit" title="typekit" width="550" height="160" class="alignleft size-full wp-image-2567" /><br /> TypeKit is a subscription-based service that allows you to link to fonts from many different type foundries. Subscription costs range from free to $99.99 per year. A free account allows for 25,000 pageviews a month and a limit of 2 fonts throughout you site. It is a great way to test out the service to see if it is right for you.<br /> <a href="https://typekit.com/">https://typekit.com/</a></p> <h3>WebFont Loader</h3> <p><img src="http://bavotasan.com/wp-content/uploads/2010/07/webfont.jpg" alt="WebFont Loader" title="webfont" width="550" height="160" class="alignleft size-full wp-image-2565" /><br /> This one is very similar to the Google Font API but it offers a wider range of resources of available fonts. You can use Google Fonts, TypeKit, Ascender or custom fonts.<br /> <a href="http://code.google.com/apis/webfonts/docs/webfont_loader.html">http://code.google.com/apis/webfonts/docs/webfont_loader.html</a></p> <h3>sIFR</h3> <p><img src="http://bavotasan.com/wp-content/uploads/2010/07/sifr.jpg" alt="sIFR" title="sifr" width="550" height="160" class="alignleft size-full wp-image-2575" /><br /> sIFR (Scalable Inman Flash Replacement) is an open source piece of JavaScript that allows you to replace text elements on your Web site with Flash embedded equivalents. It is a bit more complicated to implement but there are many sites that use it and the results are quite nice.<br /> <a href="http://wiki.novemberborn.net/sifr3/">http://wiki.novemberborn.net/sifr3/</a></p> <h3>typeface.js</h3> <p><img src="http://bavotasan.com/wp-content/uploads/2010/07/typeface.jpg" alt="typeface.js" title="typeface" width="550" height="160" class="alignleft size-full wp-image-2576" /><br /> typeface.js was developed by David Chester as an alternative to using Flash to embed fonts on your site. Using typeface.js is pretty straightforward, since all it takes is the core JavaScript file and then a font. You can even convert your own fonts.<br /> <a href="http://typeface.neocracy.org/">http://typeface.neocracy.org/</a></p> <h3>FLIR</h3> <p><img src="http://bavotasan.com/wp-content/uploads/2010/07/flir.jpg" alt="FLIR" title="flir" width="550" height="160" class="alignleft size-full wp-image-2577" /><br /> FLIR (FaceLift Image Replacement) is another alternative to sIFR. It was created by Cory Mawhorter and uses JavaScript and PHP to dynamically create images of the text elements that you wish to use specific fonts on. Implementing it requires only a few lines of code and you are up and running.<br /> <a href="http://facelift.mawhorter.net/">http://facelift.mawhorter.net/</a></p> <h3>Cuf贸n</h3> <p><img src="http://bavotasan.com/wp-content/uploads/2010/07/cufon.jpg" alt="Cuf贸n" title="cufon" width="550" height="160" class="alignleft size-full wp-image-2578" /><br /> Cuf贸n works with a rendering engine built in JavaScript and a font generator that uses <a href="http://fontforge.sourceforge.net/">FontForge</a> to convert fonts to a proprietary format.<br /> <a href="http://wiki.github.com/sorccu/cufon/">http://wiki.github.com/sorccu/cufon/</a></p> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/articles/great-font-resources/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item> <title>Blind Toggle for jQuery</title> <link>http://bavotasan.com/tutorials/blindtoggle-for-jquery/</link> <comments>http://bavotasan.com/tutorials/blindtoggle-for-jquery/#comments</comments> <pubDate>Thu, 22 Jul 2010 03:17:06 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[bottom check]]></category> <category><![CDATA[core code]]></category> <category><![CDATA[Drop Down Menu]]></category> <category><![CDATA[element]]></category> <category><![CDATA[fn]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[slide effect]]></category> <category><![CDATA[Slides]]></category> <category><![CDATA[toggle]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2551</guid> <description><![CDATA[jQuery has a great slide effect which comes built in to the core code. The only problem is that when an element slides down, it starts from the top and slides down to the bottom. Check out the drop down menu on Moderno to see what I mean. I wanted to create an element that [...]]]></description> <content:encoded><![CDATA[<p><a href="http://jquery.com">jQuery</a> has a great slide effect which comes built in to the core code. The only problem is that when an element slides down, it starts from the top and slides down to the bottom. Check out the drop down menu on <a href="http://demos.bavotasan.com/?wptheme=Moderno">Moderno</a> to see what I mean. </p> <p>I wanted to create an element that slides out from the bottom up and came across this piece of <a href="http://jquery.com">jQuery</a> code which creates a &#8220;blind&#8221; toggle.</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">blindToggle</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>speed<span style="color: #339933;">,</span> easing<span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> h <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> parseInt<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'paddingTop'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> parseInt<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'paddingBottom'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>marginTop<span style="color: #339933;">:</span> parseInt<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'marginTop'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span><span style="color: #CC0000;">0</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">:</span> <span style="color: #339933;">-</span>h<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> speed<span style="color: #339933;">,</span> easing<span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div> <p>I have included it in my upcoming Premium theme Elemental Portfolio and I wanted to give props to Karl Swedberg on <a href="http://www.learningjquery.com/2008/02/simple-effects-plugins">Learning jQuery</a> for pointing me in the right direction.</p> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/tutorials/blindtoggle-for-jquery/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item> <title>Shorten Your Post Titles in WordPress</title> <link>http://bavotasan.com/tutorials/shorten-your-post-titles-in-wordpress/</link> <comments>http://bavotasan.com/tutorials/shorten-your-post-titles-in-wordpress/#comments</comments> <pubDate>Fri, 16 Jul 2010 15:24:22 +0000</pubDate> <dc:creator>c.bavota</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Array]]></category> <category><![CDATA[boxes]]></category> <category><![CDATA[count]]></category> <category><![CDATA[file]]></category> <category><![CDATA[Function]]></category> <category><![CDATA[idea]]></category> <category><![CDATA[length]]></category> <category><![CDATA[line]]></category> <category><![CDATA[loop]]></category> <category><![CDATA[magazine]]></category> <category><![CDATA[Php]]></category> <category><![CDATA[php tags]]></category> <category><![CDATA[pop]]></category> <category><![CDATA[post]]></category> <category><![CDATA[reason]]></category> <category><![CDATA[Slideshow]]></category> <category><![CDATA[strlen]]></category> <category><![CDATA[title]]></category> <category><![CDATA[WordPress]]></category> <guid isPermaLink="false">http://bavotasan.com/?p=2542</guid> <description><![CDATA[This is not a function that you would need to use often, but I came across a reason to use it recently and I thought it might be a good idea to share it. All it does is limit the number of words in your title, just in case you don&#8217;t want it to wrap [...]]]></description> <content:encoded><![CDATA[<p>This is not a function that you would need to use often, but I came across a reason to use it recently and I thought it might be a good idea to share it. All it does is limit the number of words in your title, just in case you don&#8217;t want it to wrap onto a second line. I used it in the featured slideshow on <a href="http://themes.bavotasan.com/our-themes/premium-themes/magazine-premium/">Magazine Premium</a> since the size of the boxes is fixed.</p> <p>Include this in your <code>functions.php</code> file between the PHP tags:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> short_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$after</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;=</span><span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$after</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$mytitle</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div> <p>Then you can use it within the WordPress loop like this:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> short_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'...'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div> <p>If you would rather count by characters instead of just words, you can add this function to your <code>functions.php</code> file instead of the one above:</p> <div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> short_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$after</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$size</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span><span style="color: #339933;">&gt;</span><span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mytitle</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$mytitle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$mytitle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$after</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$mytitle</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div> ]]></content:encoded> <wfw:commentRss>http://bavotasan.com/tutorials/shorten-your-post-titles-in-wordpress/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>

Pages: 1 2 3 4 5 6 7 8 9 10