<?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>Troy Chaplin</title> <atom:link href="http://troychaplin.ca/feed/?cat=-3%2C-4" rel="self" type="application/rss+xml" /><link>http://troychaplin.ca</link> <description>Web Design and Development</description> <lastBuildDate>Sun, 29 Aug 2010 19:11:44 +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>Five Canadian Universities Using WordPress to Blog</title><link>http://troychaplin.ca/blog/wordpress-users/five-canadian-universities-using-wordpress-to-blog/</link> <comments>http://troychaplin.ca/blog/wordpress-users/five-canadian-universities-using-wordpress-to-blog/#comments</comments> <pubDate>Sun, 29 Aug 2010 18:01:22 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Users]]></category> <category><![CDATA[Bloggin]]></category> <category><![CDATA[Canadian Universities]]></category> <category><![CDATA[Higher Education]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/?p=135</guid> <description><![CDATA[As WordPress gains more and more attention from outside the blogging community, large companies and organizations are starting to seriously consider WordPress as a low-cost alternative to enterprise level content management systems. However, given WordPress’ track record as a powerful blogging tool, a fair number of companies and organizations have been using it to blog [...]]]></description> <content:encoded><![CDATA[<p>As WordPress gains more and more attention from outside the blogging community, large companies and organizations are starting to seriously consider WordPress as a low-cost alternative to enterprise level content management systems. However, given WordPress’ track record as a powerful blogging tool, a fair number of companies and organizations have been using it to blog for years.</p><p>After working in the education sector in Canada for the last decade, I was interested in finding out which Canadian universities were using WordPress, and how they use it. In future blog posts I hope to focus solely on one institution that uses WordPress to blog, talking about what they&#8217;re doing, how they do it, and any other information I can dig up about the blogs.</p><p>I&#8217;m always looking to discover new areas of higher education that are using WordPress in their web environment, whether it be blogging or as a CMS, so if you know of others that are not mentioned below, please leave me a comment.</p><p>Here’s an overview of five Canadian universities using WordPress to power their blogs.</p><h2>Carleton University</h2><p>The Carleton University Web Services team runs a blog that is focused on providing information, tips and tutorials for the users of their custom content management system. Posts are made weekly and cover such topics as analytics, cms tutorials, search engine optimization, social media and more.</p><p><img class="alignnone size-full wp-image-143" title="Carleton University" src="http://troychaplin.ca/cms/wp-content/files/carleton-university-wpblog.png" alt="" width="590" height="300" /></p><p><a href="http://www2.carleton.ca/ccms/news/" target="_blank">Visit the Carleton University CMS blog »</a></p><h2>Dalhousie University</h2><p>Dalhousie University has a wide variety of blog for departments, faculties and offices across campus. Currently active blogs provide information and news to faculty, staff and students from areas such as career services, community health, computer science, human resources and many more.</p><p><img class="alignnone size-full wp-image-146" title="Dalhousie University" src="http://troychaplin.ca/cms/wp-content/files/dalhousie-university-wpblog.png" alt="" width="590" height="300" /></p><p><a href="https://blogs.dal.ca/" target="_blank">Visit Dalhousie Universities blogs »</a></p><h2>Ivey MBA</h2><p>The Richard Ivey School of Business (a part of the University of Western Ontario) offers an informational blog focused on their MBA program, as well as the Ivey admissions process. The admissions team also use the blog to share experiences and insight during their recruitment travels.</p><p><img class="alignnone size-full wp-image-147" title="Ivey MBA" src="http://troychaplin.ca/cms/wp-content/files/ivey-mba-wpblog.png" alt="" width="590" height="300" /></p><p><a href="http://blogs.ivey.ca/mba/" target="_blank">Visit the Ivey MBA Recruiting and Admissions blog »</a></p><h2>Sheridan College</h2><p>Sheridan College presents Sheridan 3D, a blog focused on providing information on various activities both on-campus and off-campus. In additions to blogging recent news, the site also features videos and photo galleries from a variety of events and activities.</p><p><img class="alignnone size-full wp-image-149" title="Sheridan College" src="http://troychaplin.ca/cms/wp-content/files/sheridan-college-wpblog.png" alt="" width="590" height="300" /></p><p><a href="http://www.sheridan3d.ca/" target="_blank">Visit the Sheridan 3D site »</a></p><h2>University of British Columbia</h2><p>The University of British Columbia offers more than just blogs, they have created a university oriented social network by allowing the community to create their own members profile and participate in groups, forums or blog discussions, whether they be public or private.</p><p><img class="alignnone size-full wp-image-150" title="University of British Columbia" src="http://troychaplin.ca/cms/wp-content/files/ubc-wpblog.png" alt="" width="590" height="300" /></p><p><a href="http://blogs.ubc.ca/" target="_blank">Visit the University of British Columbia blogs »</a></p> ]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-users/five-canadian-universities-using-wordpress-to-blog/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Variable Post Excerpt Lengths Based on Title Character Count</title><link>http://troychaplin.ca/blog/wordpress-hacks/variable-post-excerpt-lengths-based-on-title-character-count/</link> <comments>http://troychaplin.ca/blog/wordpress-hacks/variable-post-excerpt-lengths-based-on-title-character-count/#comments</comments> <pubDate>Sat, 21 Aug 2010 18:06:15 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[Excerpts]]></category> <category><![CDATA[Hacks]]></category> <category><![CDATA[Theming]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=98</guid> <description><![CDATA[If you are looking to create a post landing page layout that flows across multiple columns while maintaining a consistent height to each post coming through from the loop, then the following piece of code will do just that. It will allow you to set the number of characters output on the excerpt based on [...]]]></description> <content:encoded><![CDATA[<p>If you are looking to create a post landing page layout that flows across multiple columns while maintaining a consistent height to each post coming through from the loop, then the following piece of code will do just that. It will allow you to set the number of characters output on the excerpt based on the title character count. My <a href="/blog">blog listings</a> page is a perfect example of this code in action.</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=98&amp;download=variable-excerpt-length-based-title.txt">variable-excerpt-length-based-title.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p982"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p98code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span>get_the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Limit $summary to how many characters?</span>
&nbsp;
<span style="color: #000088;">$title_len</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//get length of title</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title_len</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">270</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//calc space remaining for excerpt</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title_len</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">230</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//calc space remaining for excerpt</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title_len</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">75</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">180</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$summary</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$excerpt</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$excerpt</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'...'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&nbsp;
'</span><span style="color: #339933;">.</span><span style="color: #000088;">$summary</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'
&nbsp;
'</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&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;da-more-link&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Read Full Post: &lt;?php the_title(); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span>Read Full Post <span style="color: #339933;">&amp;</span>raquo<span style="color: #339933;">;&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div><p>The way this works is rather simple. The $title_len represents the length of the post title, while the $limit represents the excerpt length limit. In the first if statement, the title_len is less than 30 characters, then the excerpt will output 270 characters.</p><p>The next series of else if statement function in the same way, reducing the size of the excerpt as the title character counts increases. This example only displays 3 possible sizes, but add more else if&#8217;s if required.</p><p>The second portion of the code will create a summary by stripping the post and apply the conditional statement values, which will then be output onto the page wrapped in p tags. The first line of the summary also end with three periods, this can be changed to whatever you wish to output to end the excerpt text.</p><p>The read more link is the last line of the code, simply change the READ MORE LINK portion of the code to set the text for viewing the full post.</p> ]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-hacks/variable-post-excerpt-lengths-based-on-title-character-count/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Deregistering WordPress Plugin Javascripts and Move Them Into the Footer</title><link>http://troychaplin.ca/blog/wordpress-hacks/deregistering-wordpress-plugin-javascripts-and-move-them-into-the-footer/</link> <comments>http://troychaplin.ca/blog/wordpress-hacks/deregistering-wordpress-plugin-javascripts-and-move-them-into-the-footer/#comments</comments> <pubDate>Sun, 15 Aug 2010 18:06:29 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[Hacks]]></category> <category><![CDATA[Minification]]></category> <category><![CDATA[Plugins]]></category> <category><![CDATA[Theming]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=100</guid> <description><![CDATA[As a javascript is being loaded on a site, it will prevent any other item from downloading. This can be very frustrating for your visitors if the scripts are loading before the images, styles, or other site components. Having your javascript calls placed in your footer will allow other resources on your site to load [...]]]></description> <content:encoded><![CDATA[<p>As a javascript is being loaded on a site, it will prevent any other item from downloading. This can be very frustrating for your visitors if the scripts are loading before the images, styles, or other site components. Having your javascript calls placed in your footer will allow other resources on your site to load first, effectively speeding up the overall load time of your site.</p><p>Often times a WordPress plugin will use a javascript, but the plugins load them into the wp_head tag. Moving a plugin javascript into the footer area requires a simple function, but is dependent on the plugin authors inclusion of the wp_print_scripts action. Search the plugins main php file for the wp_print_scripts item, and it will be closely followed by the script name.</p><p>The following piece of code uses a sample to move the javascript from the WP-Codebox plugin:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=100&amp;download=deregister-plugin-js-move-into-footer.txt">deregister-plugin-js-move-into-footer.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1009"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p100code9"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_enqueue_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_codebox_scripts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_codebox_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-codebox/js/codebox.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</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>
	wp_localize_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'ajax_url'</span> <span style="color: #339933;">=&gt;</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-codebox/wp-codebox.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'text_wait'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Your last request is still being processed. Please wait a while ...'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'codebox'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Before inserting the code into the functions.php file of the WordPress theme, open your theme footer.php and check to see if it contains the following line of code, if not, then add it above the closing body tag. <strong>Note:</strong> both the wp_header and wp_footer are used by a plugin file to insert CSS and javascript code into your theme.</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10010"><td class="code" id="p100code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_footer<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></pre></td></tr></table></div><p>On lines one and two of the full function, the first line will add an action to hook into the wp_enqueue_script, and replace it with an action of your own choosing, in this case wp_codebox_scripts. Then on line two, you specify the name of your newly created action to register it as a function, as seen in the following example:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10011"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p100code11"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_enqueue_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_codebox_scripts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> wp_codebox_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></td></tr></table></div><p>Navigate into the plugin folder and open the main php file and do a search for wp_print_scripts. This function will only be possible if it is available in the plugin structure. In the wp-codebox.php file, the print scripts action can be found on line 61, and a little further down on line 67 we see the line of code that includes the wp_enqueue_script which also contains the script name and the path to the plugin javascript file:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10012"><td class="line_numbers"><pre>67
</pre></td><td class="code" id="p100code12"><pre class="php" style="font-family:monospace;">wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> get_bloginfo <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wpurl'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-content/plugins/wp-codebox/js/codebox.js'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'0.1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>Make note of the script name and path to the javascript file and insert it into line 3 of the full function code (<strong>note:</strong> because the function uses a plugin_url reference, you should not add the wp-content and plugins slugs as part of the path to the javascript file):</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code13'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10013"><td class="line_numbers"><pre>3
</pre></td><td class="code" id="p100code13"><pre class="php" style="font-family:monospace;">wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-codebox/js/codebox.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.50'</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></pre></td></tr></table></div><p>On line 4 there is two areas that you would need to insert the script name, as seen in the following example. Line five also requires you to insert the plugin directory, as well as the main php file name:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10014"><td class="line_numbers"><pre>4
5
</pre></td><td class="code" id="p100code14"><pre class="php" style="font-family:monospace;">wp_localize_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'codebox'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'ajax_url'</span> <span style="color: #339933;">=&gt;</span> plugins_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-codebox/wp-codebox.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></pre></td></tr></table></div><p>Once you&#8217;ve added the proper script names and paths in the final function, refresh your site and take a look at the source code. You should see that the call to the plugin javascript is located in the footer, as opposed to the header.</p> ]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-hacks/deregistering-wordpress-plugin-javascripts-and-move-them-into-the-footer/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Deregistering Default Plugin CSS Files in WordPress</title><link>http://troychaplin.ca/blog/wordpress-hacks/deregistering-default-plugin-css-files-in-wordpress/</link> <comments>http://troychaplin.ca/blog/wordpress-hacks/deregistering-default-plugin-css-files-in-wordpress/#comments</comments> <pubDate>Sun, 08 Aug 2010 18:11:03 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[Functions]]></category> <category><![CDATA[Hacks]]></category> <category><![CDATA[Minification]]></category> <category><![CDATA[Theming]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=102</guid> <description><![CDATA[With every file loaded into a site an HTTP request is made to the server, and the higher the number of requests made will decrease the overall load time of your site pages and posts. A simple way to cut down on those requests is by combining your CSS and Javascript files into as few [...]]]></description> <content:encoded><![CDATA[<p>With every file loaded into a site an HTTP request is made to the server, and the higher the number of requests made will decrease the overall load time of your site pages and posts. A simple way to cut down on those requests is by combining your CSS and Javascript files into as few as possible.</p><p>Disabling the plugin CSS allows you to copy it directly into the main theme style sheet, effectively removing one or more HTTP requests on your site. Although a handful of recent WordPress plugins have begun to offer the option to disable its CSS through its configuration, most plugins still place a call to its CSS file inside the wp_header tag. Disabling the default CSS file requires a simple function, but is dependent on the plugin authors inclusion of the wp_print_styles action.</p><p>Search the plugins main php file in the plugin folder for the wp_print_styles item, and it will be closely followed by the script name. The following piece of code uses a sample to disable the default CSS file for the wp-pagenavi plugin:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=102&amp;download=deregister-plugin-css-code.txt">deregister-plugin-css-code.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10220"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p102code20"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_print_styles'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_deregister_styles'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_deregister_styles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp-pagenavi'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><h2>Setting Up the Function</h2><p>Before inserting the code into the functions.php file of the WordPress theme, open your theme header.php and check to see if it contains the following line of code, if not, then add it in the header tag. <strong>Note:</strong> the wp_header tag is used by plugins to load resources and is required for them to function.</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p102code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10221"><td class="code" id="p102code21"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_header<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></pre></td></tr></table></div><p>Navigate into the plugin folder and open the main php file and do a search for wp_enqueue_style. This function will only be possible if it is available in the plugin structure. In the wp-pagenavi.php file, the print scripts action and style name can be found on line 204:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p102code22'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10222"><td class="code" id="p102code22"><pre class="php" style="font-family:monospace;">wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-pagenavi'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$css_file</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2.70'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>In the first argument in the enqueue for the plugin, the name of the style is wp-pagenavi. Copy this name and paste it into the wp_deregister_style line of the full function, as shown in the following example:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p102code23'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10223"><td class="code" id="p102code23"><pre class="php" style="font-family:monospace;">wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp-pagenavi'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><h2>Deregistering Multiple Plugin CSS Files</h2><p>If you have multiple plugins that use the wp_enqueue_style action, you can add multiple instances of the wp_deregister_style in one single function with the following sample:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=102&amp;download=deregister-multiple-plugin-css-code.txt">deregister-multiple-plugin-css-code.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10224"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p102code24"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_print_styles'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_deregister_styles'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_deregister_styles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp-pagenavi'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'NextGEN'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_deregister_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'codebox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-hacks/deregistering-default-plugin-css-files-in-wordpress/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>WordPress Breadcrumb Function to Replace Plugins</title><link>http://troychaplin.ca/blog/wordpress-functions/wordpress-breadcrumb-function-to-replace-plugins/</link> <comments>http://troychaplin.ca/blog/wordpress-functions/wordpress-breadcrumb-function-to-replace-plugins/#comments</comments> <pubDate>Sun, 01 Aug 2010 18:11:44 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Functions]]></category> <category><![CDATA[Functions]]></category> <category><![CDATA[Plugins]]></category> <category><![CDATA[Theming]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=104</guid> <description><![CDATA[In the past I&#8217;ve relied on a plugin to handle the breadcrumbs throughout the sites I&#8217;ve built. In a effort to reduce the amount of plugins I use regular and replace them with functions I came across a simple to implement, easy to update function that does exactly what I need. First, paste the following [...]]]></description> <content:encoded><![CDATA[<p>In the past I&#8217;ve relied on a plugin to handle the breadcrumbs throughout the sites I&#8217;ve built. In a effort to reduce the amount of plugins I use regular and replace them with functions I came across a simple to implement, easy to update function that does exactly what I need. First, paste the following code into your template file(s) in the area you want your breadcrumbs to appear:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=104&amp;download=breadcrumb-template-tag.txt">breadcrumb-template-tag.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10427"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p104code27"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dimox_breadcrumbs'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> dimox_breadcrumbs<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></pre></td></tr></table></div><p>Next, we take the following code and paste it into your functions.php file. The areas you would want to consider changing to customize the output on the front end of your site have been commented throughout.</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=104&amp;download=breadcrumb-function.txt">breadcrumb-function.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10428"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
</pre></td><td class="code" id="p104code28"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> dimox_breadcrumbs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000088;">$delimiter</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&amp;raquo;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change the dividers</span>
  <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Home'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change the 'Home' link</span>
  <span style="color: #000088;">$currentBefore</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;span class=&quot;current&quot;&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$currentAfter</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>is_front_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_paged<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;div id=&quot;crumbs&quot;&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$home</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: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$home</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt; '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$delimiter</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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;">$wp_query</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$cat_obj</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_queried_object</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$thisCat</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cat_obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$thisCat</span> <span style="color: #339933;">=</span> get_category<span style="color: #009900;">&#40;</span><span style="color: #000088;">$thisCat</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$parentCat</span> <span style="color: #339933;">=</span> get_category<span style="color: #009900;">&#40;</span><span style="color: #000088;">$thisCat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent</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;">$thisCat</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span>get_category_parents<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parentCat</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$delimiter</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentBefore</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'Archive by category &amp;#39;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change the archives prefix</span>
      single_cat_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&amp;#39;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_day<span style="color: #009900;">&#40;</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;a href=&quot;'</span> <span style="color: #339933;">.</span> get_year_link<span style="color: #009900;">&#40;</span>get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt; '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$delimiter</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> get_month_link<span style="color: #009900;">&#40;</span>get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'F'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt; '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$delimiter</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentBefore</span> <span style="color: #339933;">.</span> get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_month<span style="color: #009900;">&#40;</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;a href=&quot;'</span> <span style="color: #339933;">.</span> get_year_link<span style="color: #009900;">&#40;</span>get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt; '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$delimiter</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentBefore</span> <span style="color: #339933;">.</span> get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'F'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_year<span style="color: #009900;">&#40;</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: #000088;">$currentBefore</span> <span style="color: #339933;">.</span> get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$cat</span> <span style="color: #339933;">=</span> get_the_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cat</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cat</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> get_category_parents<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cat</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$delimiter</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentBefore</span><span style="color: #339933;">;</span>
      the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentBefore</span><span style="color: #339933;">;</span>
      the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$parent_id</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$breadcrumbs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> get_page<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$breadcrumbs</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</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: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</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: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$parent_id</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000088;">$breadcrumbs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_reverse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$breadcrumbs</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$breadcrumbs</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$crumb</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$crumb</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$delimiter</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentBefore</span><span style="color: #339933;">;</span>
      the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_search<span style="color: #009900;">&#40;</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: #000088;">$currentBefore</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'Search results for &amp;#39;'</span> <span style="color: #339933;">.</span> get_search_query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;#39;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change the search results prefix &amp; suffix</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_tag<span style="color: #009900;">&#40;</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: #000088;">$currentBefore</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'Posts tagged &amp;#39;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change the post tag prefix &amp; suffix</span>
      single_tag_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&amp;#39;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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;">$author</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$userdata</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentBefore</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'Articles posted by '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$userdata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_name</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_404<span style="color: #009900;">&#40;</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: #000088;">$currentBefore</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'Error 404'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$currentAfter</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change the 404 text</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_day<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_month<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_year<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_tag<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' ('</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Page'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_day<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_month<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_year<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_tag<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">')'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/div&gt;
&nbsp;
'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-functions/wordpress-breadcrumb-function-to-replace-plugins/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Adding Custom Modules on the WordPress Dashboard</title><link>http://troychaplin.ca/blog/wordpress-functions/adding-custom-modules-on-the-wordpress-dashboard/</link> <comments>http://troychaplin.ca/blog/wordpress-functions/adding-custom-modules-on-the-wordpress-dashboard/#comments</comments> <pubDate>Sun, 25 Jul 2010 18:12:35 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Functions]]></category> <category><![CDATA[Dashboard]]></category> <category><![CDATA[Functions]]></category> <category><![CDATA[Hacks]]></category> <category><![CDATA[Theming]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=106</guid> <description><![CDATA[Wouldn&#8217;t it be nice to have the ability to add new custom module on the dashboard in your WordPress builds? The following code will do just that, simply add it to your functions.php file and add whatever you want within the echo and voila! ?Download add-custom-dashboard-module.txt1 2 3 4 5 6 7 8 9 10 [...]]]></description> <content:encoded><![CDATA[<p>Wouldn&#8217;t it be nice to have the ability to add new custom module on the dashboard in your WordPress builds? The following code will do just that, simply add it to your functions.php file and add whatever you want within the echo and voila!</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=106&amp;download=add-custom-dashboard-module.txt">add-custom-dashboard-module.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10631"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p106code31"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Create the function to output the contents of our Dashboard Widget</span>
<span style="color: #000000; font-weight: bold;">function</span> example_dashboard_widget_function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Display whatever it is you want to show</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' INSERT SOMETHING HERE '</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Create the function use in the action hook</span>
<span style="color: #000000; font-weight: bold;">function</span> example_add_dashboard_widgets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_add_dashboard_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'example_dashboard_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Site Documentation'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'example_dashboard_widget_function'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Hoook into the 'wp_dashboard_setup' action to register our other functions</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_dashboard_setup'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'example_add_dashboard_widgets'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>In the following example I have created a 2 column table with inline styles that features an unordered list that I normally use to create a tutorials and documentation module for each of my clients.</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=106&amp;download=custom-module-table-sample.txt">custom-module-table-sample.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10632"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code" id="p106code32"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Create the function to output the contents of our Dashboard Widget</span>
<span style="color: #000000; font-weight: bold;">function</span> example_dashboard_widget_function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Display whatever it is you want to show</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;div id=&quot;docs-left&quot; style=&quot;float:left;width:48%;&quot;&gt;
&lt;p style=&quot;font-size:12px;font-weight:bold;margin-top:0;color:#333333&quot;&gt;Basic Tutorials
&lt;ul style=&quot;padding: 0 0 0 18px&quot;&gt;
&lt;li style=&quot;list-style-type:disc&quot;&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Basic Tutorial 1&lt;/a&gt;
&lt;li&gt;
&lt;li style=&quot;list-style-type:disc&quot;&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Basic Tutorial 2&lt;/a&gt;
&lt;li&gt;
&lt;li style=&quot;list-style-type:disc&quot;&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Basic Tutorial 3&lt;/a&gt;
&lt;li&gt;
&lt;li style=&quot;list-style-type:disc&quot;&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Basic Tutorial 4&lt;/a&gt;
&lt;li&gt;
		&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&quot;docs-right&quot; style=&quot;float:right;width:48%;&quot;&gt;
&lt;p style=&quot;font-size:12px;font-weight:bold;margin-top:0;color:#333333&quot;&gt;Advanced Tutorials
&lt;ul style=&quot;padding: 0 0 0 18px&quot;&gt;
&lt;li style=&quot;list-style-type:disc&quot;&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Advanced Tutorial 1&lt;/a&gt;
&lt;li&gt;
&lt;li style=&quot;list-style-type:disc&quot;&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Advanced Tutorial 2&lt;/a&gt;
&lt;li&gt;
&lt;li style=&quot;list-style-type:disc&quot;&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Advanced Tutorial 3&lt;/a&gt;
&lt;li&gt;
&lt;li style=&quot;list-style-type:disc&quot;&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Advanced Tutorial 4&lt;/a&gt;
&lt;li&gt;
		&lt;/ul&gt;
&lt;/div&gt;
&lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;
&nbsp;
	'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Create the function use in the action hook</span>
<span style="color: #000000; font-weight: bold;">function</span> example_add_dashboard_widgets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_add_dashboard_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'example_dashboard_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Site Documentation'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'example_dashboard_widget_function'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Hoook into the 'wp_dashboard_setup' action to register our other functions</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_dashboard_setup'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'example_add_dashboard_widgets'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-functions/adding-custom-modules-on-the-wordpress-dashboard/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Hiding Dashboard Navigation Items in WordPress</title><link>http://troychaplin.ca/blog/wordpress-hacks/hiding-dashboard-navigation-items-in-wordpress/</link> <comments>http://troychaplin.ca/blog/wordpress-hacks/hiding-dashboard-navigation-items-in-wordpress/#comments</comments> <pubDate>Sun, 18 Jul 2010 18:13:11 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[Dashboard]]></category> <category><![CDATA[Functions]]></category> <category><![CDATA[Hacks]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=108</guid> <description><![CDATA[When setting up custom WordPress builds for clients there are sometimes areas within the administration area that will never be used, and other areas that you simply do not want those clients to have access to, such as Appearance, Plugins, Settings and maybe more. Preventing clients from accessing several of these areas will save you [...]]]></description> <content:encoded><![CDATA[<p>When setting up custom WordPress builds for clients there are sometimes areas within the administration area that will never be used, and other areas that you simply do not want those clients to have access to, such as Appearance, Plugins, Settings and maybe more. Preventing clients from accessing several of these areas will save you frustration when a client accidentally deactivates a plugin or changing a critical setting.</p><p>Removing items from the main administration navigation is as simple as pasting the following code into your theme&#8217;s functions.php file. The opening if statement is used to hide items for admins only, while the restrictions set in the else statement would hide items for all user roles below the admin level.</p><p><strong>Note:</strong> in both statements all of the items are set to be hidden from the navigation. To customize what users can see, simply remove the navigation items that you want to remain visible.</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=108&amp;download=hide-dashboard-nav-items.txt">hide-dashboard-nav-items.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10834"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p108code34"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> remove_menus <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;">$menu</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// check if admin and hide these for admins</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'install_themes'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$restricted</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Dashboard'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Posts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Media'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Links'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Pages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Appearance'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tools'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Settings'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Plugins'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// hide these for other roles</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$restricted</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Dashboard'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Posts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Media'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Links'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Pages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Appearance'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tools'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Settings'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Plugins'</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: #990000;">end</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$menu</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">prev</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$menu</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$value</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;">$menu</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$menu</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</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;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">NULL</span>?<span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$restricted</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$menu</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$menu</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'remove_menus'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-hacks/hiding-dashboard-navigation-items-in-wordpress/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Hiding the Default WordPress Dashboard Panels</title><link>http://troychaplin.ca/blog/wordpress-hacks/hiding-the-default-wordpress-dashboard-panels/</link> <comments>http://troychaplin.ca/blog/wordpress-hacks/hiding-the-default-wordpress-dashboard-panels/#comments</comments> <pubDate>Sun, 11 Jul 2010 18:13:42 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[Dashboard]]></category> <category><![CDATA[Functions]]></category> <category><![CDATA[Hacks]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=110</guid> <description><![CDATA[When you first install an instance of WordPress there are a set of default modules that are displayed on the dashboard within the administration area. Often times client, or even developers themselves, have no use for some of them. Instead of changing the settings for each individual user, why not use the following in your [...]]]></description> <content:encoded><![CDATA[<p>When you first install an instance of WordPress there are a set of default modules that are displayed on the dashboard within the administration area. Often times client, or even developers themselves, have no use for some of them. Instead of changing the settings for each individual user, why not use the following in your theme&#8217;s functions.php file, this will remove all specified modules from every user that is currently in the system, as well as any new users that will be created over time.</p><p><strong>Note:</strong> all available dashboard modules have been added to the following example, to customize it to suit your needs simply remove the items to wish to remain visible.</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=110&amp;download=remove-dashboard-modules.txt">remove-dashboard-modules.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11036"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code" id="p110code36"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Create the function to use in the action hook</span>
<span style="color: #000000; font-weight: bold;">function</span> example_remove_dashboard_widgets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Globalize the metaboxes array, this holds all the widgets for wp-admin</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_meta_boxes</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Main Modules</span>
	<span style="color: #666666; font-style: italic;">// Remove the right now widget</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_meta_boxes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard_right_now'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Remove the recent comments widget</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_meta_boxes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard_recent_comments'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Remove the incoming links widget</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_meta_boxes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard_incoming_links'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Remove the plugins widget</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_meta_boxes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard_plugins'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Secondary Modules</span>
	<span style="color: #666666; font-style: italic;">// Remove the quickpress widget</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_meta_boxes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'side'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard_quick_press'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Remove the recent drafts widget</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_meta_boxes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'side'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard_recent_drafts'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Remove the primary feed widget</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_meta_boxes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'side'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard_primary'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Remove the secondary feed widget</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_meta_boxes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'side'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dashboard_secondary'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Hoook into the 'wp_dashboard_setup' action to register our function</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_dashboard_setup'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'example_remove_dashboard_widgets'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-hacks/hiding-the-default-wordpress-dashboard-panels/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Flowing WordPress Category and Blog Roll Lists Across Two Columns</title><link>http://troychaplin.ca/blog/wordpress-hacks/flowing-wordpress-category-and-blog-roll-lists-across-two-columns/</link> <comments>http://troychaplin.ca/blog/wordpress-hacks/flowing-wordpress-category-and-blog-roll-lists-across-two-columns/#comments</comments> <pubDate>Sun, 04 Jul 2010 18:15:20 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Hacks]]></category> <category><![CDATA[Hacks]]></category> <category><![CDATA[Layout]]></category> <category><![CDATA[Styling]]></category> <category><![CDATA[Theming]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=115</guid> <description><![CDATA[If your design calls for flowing a WordPress categories or blog roll list over two columns then the following functions will allow you to do just that, and style them along the way by using the ul left and right classes. Categories Paste the following into your functions.php file to flow the categories over two [...]]]></description> <content:encoded><![CDATA[<p>If your design calls for flowing a WordPress categories or blog roll list over two columns then the following functions will allow you to do just that, and style them along the way by using the ul left and right classes.</p><h2>Categories</h2><p>Paste the following into your functions.php file to flow the categories over two columns:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=115&amp;download=categories-2column-code.txt">categories-2column-code.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11539"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code" id="p115code39"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000088;">$cats</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span>wp_list_categories<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title_li=&amp;echo=0&amp;depth=1&amp;style=none'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$cat_n</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cats</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$cat_n</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</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;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$cat_n</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$cat_left</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cat_left</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'
&lt;li&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$cats</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/li&gt;
&nbsp;
'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&gt;=</span><span style="color: #000088;">$cat_n</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$cat_right</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cat_right</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'
&lt;li&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$cats</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/li&gt;
&nbsp;
'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">endfor</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>ul style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;float:left&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$cat_left</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>ul style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;float:right&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;right&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$cat_right</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;clear:both&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div><h2>Blog Roll</h2><p>Paste the following into your functions.php file to flow the blog roll over two columns:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=115&amp;download=blogroll-2column-code.txt">blogroll-2column-code.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11540"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p115code40"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000088;">$links</span> <span style="color: #339933;">=</span> wp_list_bookmarks<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title_li=&amp;categorize=0&amp;sort_column=menu_order&amp;echo=0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$bookmarks</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/li&gt;
&nbsp;
'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$links</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$links</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$bookmarks</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$link_n</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$link_n</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</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;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$link_n</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$left</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$left</span><span style="color: #339933;">.</span><span style="color: #0000ff;">''</span><span style="color: #339933;">.</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&gt;=</span><span style="color: #000088;">$link_n</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$right</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$right</span><span style="color: #339933;">.</span><span style="color: #0000ff;">''</span><span style="color: #339933;">.</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">endfor</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>ul style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;float:left&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$left</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>ul style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;float:right&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;right&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$right</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;clear:both&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-hacks/flowing-wordpress-category-and-blog-roll-lists-across-two-columns/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Removing Automatically Generated Inline Style on Images with Captions in WordPress</title><link>http://troychaplin.ca/blog/wordpress-functions/removing-automatically-generated-inline-style-on-images-with-captions-in-wordpress/</link> <comments>http://troychaplin.ca/blog/wordpress-functions/removing-automatically-generated-inline-style-on-images-with-captions-in-wordpress/#comments</comments> <pubDate>Sun, 27 Jun 2010 18:15:58 +0000</pubDate> <dc:creator>Troy</dc:creator> <category><![CDATA[WordPress Functions]]></category> <category><![CDATA[Functions]]></category> <category><![CDATA[Images]]></category> <category><![CDATA[Styling]]></category> <category><![CDATA[Theming]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://troychaplin.ca/cms/?p=117</guid> <description><![CDATA[For some strange reason images inserted in posts or pages in WordPress will automatically have an inline style applied to them, which could cause formatting headaches for the site visitor. The following is a simple piece of code that you can add to your theme&#8217;s functions.php file to fix this problem: ?Download remove-image-inline-style.txt1 2 3 [...]]]></description> <content:encoded><![CDATA[<p>For some strange reason images inserted in posts or pages in WordPress will automatically have an inline style applied to them, which could cause formatting headaches for the site visitor. The following is a simple piece of code that you can add to your theme&#8217;s functions.php file to fix this problem:</p><div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://troychaplin.ca/cms/wp-content/plugins/wp-codebox/wp-codebox.php?p=117&amp;download=remove-image-inline-style.txt">remove-image-inline-style.txt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11742"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p117code42"><pre class="php" style="font-family:monospace;">add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_caption'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fixed_img_caption_shortcode'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'caption'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fixed_img_caption_shortcode'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> fixed_img_caption_shortcode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$attr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Allow plugins/themes to override the default caption template.</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'img_caption_shortcode'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</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;">$output</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'id'</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'align'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'alignnone'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'width'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'caption'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attr</span><span style="color: #009900;">&#41;</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: #cc66cc;">1</span> <span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">||</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$caption</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$id</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'id=&quot;'</span> <span style="color: #339933;">.</span> esc_attr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;div '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'class=&quot;wp-caption '</span> <span style="color: #339933;">.</span> esc_attr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$align</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; style=&quot;width: '</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$width</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'px&quot;&gt;'</span>
	<span style="color: #339933;">.</span> do_shortcode<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$content</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;p class=&quot;wp-caption-text&quot;&gt;'</span>
	<span style="color: #339933;">.</span> <span style="color: #000088;">$caption</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/p&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>]]></content:encoded> <wfw:commentRss>http://troychaplin.ca/blog/wordpress-functions/removing-automatically-generated-inline-style-on-images-with-captions-in-wordpress/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (request URI contains query)

Served from: troychaplin.ca @ 2010-09-08 06:35:22 -->