<?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>Martin Gardner.co.uk &#187; wordpress</title>
	<atom:link href="http://www.martin-gardner.co.uk/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.martin-gardner.co.uk</link>
	<description>Technology - Gadgets - Programing - Gaming - Reviews - Tutorials</description>
	<lastBuildDate>Fri, 11 Nov 2011 10:07:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to Show Your Google Analytics Count in WordPress</title>
		<link>http://www.martin-gardner.co.uk/how-to-show-your-google-analytics-count-in-wordpress/</link>
		<comments>http://www.martin-gardner.co.uk/how-to-show-your-google-analytics-count-in-wordpress/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 13:16:20 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1754</guid>
		<description><![CDATA[Using a little php function inside your wordpress theme's functions file, we can call up the total amount of visitors from a given month (ie: last 30 days)]]></description>
			<content:encoded><![CDATA[<p>Using a little php function inside your wordpress theme&#8217;s functions file, we can call up the total amount of visitors from a given month (ie: last 30 days).</p>
<p><span id="more-1754"></span></p>
<p style="text-align:center;"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/08/analytics-google.gif" alt="" title="google analytics" width="391" height="365" class="alignnone size-full wp-image-1790" /></p>
<p>Do you need a way to show your site users the amount of visitors you receive each month, which can utilise your Google Analytics account?</p>
<p>Then using this little PHP function below, we can easily print this information to the screen for anyone to read, Or if your feeling a little more savvy then&#8230; you can show this to registered or logged in users only or even just admin users&#8230;</p>
<h2 style="-moz-border-radius:8px 8px 8px 8px; background:#F1F8DF;font-size:20px;font-weight:normal;line-height:30px;padding:2px 10px 2px 30px;text-shadow:1px 1px 1px #BBBBBB;"><span style="-moz-border-radius:8px 0 0 8px;<br />
background:#A1CF26;font-size:24px;margin-left:-5px;padding:3px 5px;">1 &ndash;</span> The Setup</h2>
<blockquote style="margin-top:10px;"><p>
In Order for this function to work, you will require a current copy of the Google Analytics API Class file which you can download <a href="http://code.google.com/p/gapi-google-analytics-php-interface/" title="Click here to Download the Google Analytics API Library" target="_blank">here</a></p>
<p>Upload the analytics folder to your current themes root directory,<br />
ie: wp-content/themes/your_theme_folder/analytics/
</p></blockquote>
<h2 style="-moz-border-radius:8px 8px 8px 8px; background:#F1F8DF;font-size:20px;font-weight:normal;line-height:30px;padding:2px 10px 2px 30px;text-shadow:1px 1px 1px #BBBBBB;"><span style="-moz-border-radius:8px 0 0 8px;<br />
background:#A1CF26;font-size:24px;margin-left:-5px;padding:3px 5px;">2 &ndash;</span>  The Function</h2>
<blockquote style="margin-top:10px;"><p>
Copy the function below into your themes &#8216;<strong>function.php</strong>&#8216; file&#8230; if you dont have one, create one!
</p></blockquote>
<pre class="brush: php; title: ; notranslate">
// Google Analytic Account Number, Analytics Username &amp; Password
function grab_analytic_count($account='ga:000000', $username='', $password='')
{
          session_start();
          $today = date('Y-m-d');
          $thirty_days_ago = date('Y-m-d', strtotime('-30 days'));
          require 'analytics/googleanalytics.class.php';
          try {
              $oAnalytics = new analytics($username,$password);
              $oAnalytics-&gt;useCache();
              $oAnalytics-&gt;setProfileById($account);
              $oAnalytics-&gt;setDateRange($thirty_days_ago, $today);
              $visitors = $oAnalytics-&gt;getVisitors();
              $total_visitors = array_sum($visitors);
              print number_format($total_visitors);
          } catch (Exception $e) {
              print 'Caught Exception: ' . $e-&gt;getMessage();
          }
}
</pre>
<h2 style="-moz-border-radius:8px 8px 8px 8px; background:#F1F8DF;font-size:20px;font-weight:normal;line-height:30px;padding:2px 10px 2px 30px;text-shadow:1px 1px 1px #BBBBBB;"><span style="-moz-border-radius:8px 0 0 8px;<br />
background:#A1CF26;font-size:24px;margin-left:-5px;padding:3px 5px;">3 &ndash;</span>  The PHP</h2>
<blockquote style="margin-top:10px;"><p>
Using this snippet of PHP you can place the call to the function anywhere you want within your template, simply enter your google analytics &#8216;ga:&#8217; account number along with your username and password for your account. </p>
<p>the &#8216;ga:&#8217; account should be at least 6 numbers in length, you can get this normaly in your Analytics code which you normaly paste into the footer of your website.. ie: &#8216;<strong>ga:123456</strong>&#8216;.
</p></blockquote>
<pre class="brush: php; title: ; notranslate">
&lt;?php
if (function_exists('grab_analytic_count'))
echo grab_analytic_count('ga:123456','YOUR_GA_USERNAME','YOUR_GA_PASSWORD');
?&gt;
</pre>
<h2 style="-moz-border-radius:8px 8px 8px 8px; background:#F1F8DF;font-size:20px;font-weight:normal;line-height:30px;padding:2px 10px 2px 30px;text-shadow:1px 1px 1px #BBBBBB;"><span style="-moz-border-radius:8px 0 0 8px;<br />
background:#A1CF26;font-size:24px;margin-left:-5px;padding:3px 5px;">4 &ndash;</span>  The Results</h2>
<blockquote style="margin-top:10px;"><p>
the output from the function will generate a Number based on your analytic results&#8230;<br />
ie: <strong>4,640</strong>
</p></blockquote>
<h2 style="-moz-border-radius:8px 8px 8px 8px; background:#F1F8DF;font-size:20px;font-weight:normal;line-height:30px;padding:2px 10px 2px 30px;text-shadow:1px 1px 1px #BBBBBB;"><span style="-moz-border-radius:8px 0 0 8px;<br />
background:#A1CF26;font-size:24px;margin-left:-5px;padding:3px 5px;">5 &ndash;</span>  What Next</h2>
<blockquote style="margin-top:10px;"><p>
This code can be used in your sidebar, or how about creating a widget just for displaying your count or adding extra code around the function call to check for various user levels and displaying it only to them.
</p></blockquote>
<h2 style="-moz-border-radius:8px 8px 8px 8px; background:#F1F8DF;font-size:20px;font-weight:normal;line-height:30px;padding:2px 10px 2px 30px;text-shadow:1px 1px 1px #BBBBBB;"><span style="-moz-border-radius:8px 0 0 8px;<br />
background:#A1CF26;font-size:24px;margin-left:-5px;padding:3px 5px;">6 &ndash;</span>  Create a Widget</h2>
<blockquote style="margin-top:10px;"><p>
To create a Widget within wordpress isnt as hard as you may think, first we add a little code to our functions.php file once again, this code will check to make sure wordpress can support widgets and that they are enabled, then we will register our own widget area with our unique name: Analytics or something along those lines&#8230;
</p></blockquote>
<pre class="brush: php; title: ; notranslate">
if ( function_exists('register_sidebar') ) {
	register_sidebar(array(
		'name'=&gt;'Analytics',
		'before_widget' =&gt; '&lt;div&gt;',
		'after_widget' =&gt; '&lt;/div&gt;',
		'before_title' =&gt; '&lt;h3&gt;',
		'after_title' =&gt; '&lt;/h3&gt;',
	));
}
</pre>
<blockquote style="margin-top:10px;"><p>
With our Widget ready to go, we need to add code to our template were we want our widget to appear, this can be anywhere you want, in the footer, sidebar or header, in this case ill open up sidebar.php and paste in the following code.
</p></blockquote>
<pre class="brush: php; title: ; notranslate">
&lt;?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('analytics') ) : ?&gt;
This is our Analytics Counter area, your widget is ready to use.
&lt;?php endif; ?&gt;
</pre>
<blockquote style="margin-top:10px;"><p>
The code above will do this for us, keep in mind if you dont use your widget or it breaks for some reason its useful to have some holding text within the php code just for visual representation of where it will be placed..
</p></blockquote>
<h2 style="-moz-border-radius:8px 8px 8px 8px; background:#F1F8DF;font-size:20px;font-weight:normal;line-height:30px;padding:2px 10px 2px 30px;text-shadow:1px 1px 1px #BBBBBB;"><span style="-moz-border-radius:8px 0 0 8px;<br />
background:#A1CF26;font-size:24px;margin-left:-5px;padding:3px 5px;">7 &ndash;</span>  Create Widget Code</h2>
<pre class="brush: php; title: ; notranslate">
function wp_analytic_widget( $args = array() )
{
	// extract any paramerters we could make this our username, password &amp; GA:Code
	extract($args);
	echo $before_widget;
	echo $before_title .' Analytics Counter '. $after_title;
        echo 'Total Monthly Visitors: ';
        echo grab_analytic_count('ga:123456','YOUR_USERNAME','YOUR_PASSWORD');
	echo $after_widget;
}
wp_register_sidebar_widget('Analytic Counter', 'wp_analytic_widget');
</pre>
<blockquote style="margin-top:10px;"><p>
With all that code in place and uploaded, when you login to your admin area, under the appearance tab click on widgets you should be presented with something like this,</p>
<blockquote style="margin-top:10px;"><p>
<img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/08/analytics_widget.jpg" alt="Analytics Widget" title="Analytics Widget" width="291" height="128" />
</p></blockquote>
<p>Now all you need to do, is drag that widget module over to your newley created widget area called &#8216;<strong>Analytics</strong>&#8216;
</p></blockquote>
<blockquote style="margin-top:10px;"><p>
When you visit your site you should be presented with your new widget area displaying your Google Count all wrapped in a div which you can style with CSS, by adding either an ID or class tag to the surounding div&#8230;
</p></blockquote>
<pre class="brush: php; title: ; notranslate">
'before_widget' =&gt; '&lt;div id=&quot;my_id_tag&quot;&gt;',
'after_widget' =&gt; '&lt;/div&gt;',
</pre>
<blockquote style="margin-top:10px;"><p>
like i said above there is so much more opportunity to open this up to a lot more functionality, by wrapping the code in a if statement to check if the user is logged in? or shown only to admin users&#8230; or creating an entire plugin with lots of other features..
</p></blockquote>
<pre class="brush: php; title: ; notranslate">
&lt;?php
if( is_user_logged_in() ) { echo code; }
?&gt;
&lt;?php
if( is_admin() ) { echo code; }
?&gt;
</pre>
<blockquote style="margin-top:10px;"><p>
What do you think? as always comments and suggestions are welcome&#8230;
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/how-to-show-your-google-analytics-count-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hobo WP GoogleBot Tracker Plugin for WordPress</title>
		<link>http://www.martin-gardner.co.uk/hobo-wp-googlebot-tracker-plugin-for-wordpress/</link>
		<comments>http://www.martin-gardner.co.uk/hobo-wp-googlebot-tracker-plugin-for-wordpress/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 21:30:13 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[hobo-web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1962</guid>
		<description><![CDATA[If you want to find out which pages the googlebot is crawling on your wordpress blog then this FREE plugin should do the job nicely. I was tasked by Shaun Anderson from Hobo-web with making a simple, but very effective tracking plugin for wordpress which could track which pages google was crawling and when, this [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to find out which pages the googlebot is crawling on your wordpress blog then this FREE plugin should do the job nicely.<br />
<span id="more-1962"></span><br />
<img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/googlebot.jpg" alt="" title="googlebot" width="260" height="172" class="alignright size-full wp-image-1984" /></p>
<p>I was tasked by <a href="http://www.hobo-web.co.uk/seo-blog/shaun-anderson/" target="_blank">Shaun Anderson</a> from <a href="http://www.hobo-web.co.uk/" target="_blank">Hobo-web</a> with making a simple, but very effective tracking plugin for wordpress which could track which pages google was crawling and when, this plugin will track the date, time &amp; page, upon each googlebot crawl. It can show you which pages its crawled and show you how many times its hit that page!</p>
<p>If you want to get emailed each time the googlebot is on your page then theres an options page to configure it to your needs&#8230;</p>
<h2>WordPress Plugin Admin Options Page</h2>
<p><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/options_page.jpg"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/options_page-285x300.jpg" alt="Wordpress Plugin Options Page" title="options_page" width="285" height="300" class="aligncenter size-medium wp-image-1966" /></a></p>
<blockquote><p>The simple admin administration area will allow you to customise the options to suit your blog, you can enable a dashboard widget for instant viewing each time you login.</p></blockquote>
<h2>Dashboard Widget</h2>
<p><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/dashboard_no_graph.jpg"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/dashboard_no_graph-300x275.jpg" alt="Dashboard widget without the Graph" title="dashboard_no_graph" width="300" height="275" class="aligncenter size-medium wp-image-1963" /></a></p>
<blockquote><p>If you want to show a neat little graph within the widget area, it can do this too..</p></blockquote>
<h2>Dashboard Widget Including Graph</h2>
<p><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/dashboard_inc_graph.jpg"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/dashboard_inc_graph-275x300.jpg" alt="Dashboard widget including Graph" title="dashboard_inc_graph" width="275" height="300" class="aligncenter size-medium wp-image-1964" /></a></p>
<h2>Admin Results &#8211; Top 20 Pages</h2>
<p><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/results_top20.jpg"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/results_top20-300x115.jpg" alt="Admin Results Page" title="results_top20" width="300" height="115" class="aligncenter size-medium wp-image-1976" /></a><br />
The Plugin options page, shows you the most tracked pages on your blog, the higher the number the more times google has crawaled that particular page.</p>
<h2>Admin Results &#8211; All Pages</h2>
<p><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/results_allpages.jpg"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/results_allpages-300x144.jpg" alt="Admin Results - All Pages" title="results_allpages" width="300" height="144" class="aligncenter size-medium wp-image-1977" /></a><br />
You can instantly ses how many pages have been crawled, when they were crawled for some poeple this information could be very handy.</p>
<h2>Admin Results &#8211; Filtered</h2>
<p><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/results_allpages_filtered.jpg"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/results_allpages_filtered-300x147.jpg" alt="" title="results_allpages_filtered" width="300" height="147" class="aligncenter size-medium wp-image-1978" /></a><br />
You can filter through the results by Month &amp; Day giving you a day by day account on which pages have been crawled, if you want to assess which pages are being crawled the most.</p>
<p>This plugin is currently Beta, so expect a few hic&#8217;ups, as always feel free to leave your thoughts or gripes below, </p>
<div class="code_block">
<h3>Download it</h3>
<p>If you want to download the plugin head over to the <a href="http://www.hobo-web.co.uk/seo-blog/index.php/googlebot-tracker/" target="_blank">Hobo</a> blog, Subscribe to the feed and you&#8217;ll get free access to not only the FREE plugin, but you&#8217;ll also get a copy of there <strong>FREE</strong> Ebook &#8220;<em>Beginners Guide to SEO</em>&#8220;.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/hobo-wp-googlebot-tracker-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How To Secure Your WordPress Blog</title>
		<link>http://www.martin-gardner.co.uk/how-to-secure-your-wordpress-blog/</link>
		<comments>http://www.martin-gardner.co.uk/how-to-secure-your-wordpress-blog/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 11:00:25 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1913</guid>
		<description><![CDATA[Here are some of my favourite top tips for keeping your WordPress website or blog more secure and less susceptible to malicious attacks. Attacks to your website/blog can come in different variations, some are made to take advantage of wrongly set file permission settings on the server, while others are more targeted at database attacks, [...]]]></description>
			<content:encoded><![CDATA[<p>Here are some of my favourite top tips for keeping your WordPress website or blog more secure and less susceptible to malicious attacks.<br />
<span id="more-1913"></span></p>
<p><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/wordpress_security.png" alt="" title="wordpress_security" width="560" height="145" /></p>
<p>Attacks to your website/blog can come in different variations, some are made to take advantage of wrongly set file permission settings on the server, while others are more targeted at database attacks, using this small but helpfull list below it should keep the door closed to most of these attacks&#8230;</p>
<blockquote>
<h1>1: File Permissions</h1>
</blockquote>
<p>Setting up your wordpress website/blog with wrongly set file permissions could lead attackers on a wrecking spree across your entire blog, The <a href="http://codex.wordpress.org/Hardening_WordPress#File_permissions" target="_blank">WordPress Codex</a> has an outline of what permissions are acceptable. </p>
<p>File and directory permissions can be changed either via an FTP client or within the administrative page from your web host. <a href="http://codex.wordpress.org/Changing_File_Permissions" target="_blank">This page</a> details more about how file permissions work and how to change them using a number of different systems.</p>
<p style="text-align:center;"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/flashfxp_permissions.jpg" alt="" title="flashfxp_permissions" width="362" height="306" /></p>
<blockquote>
<h1>2: Using Secret Keys in WP-Config.php File</h1>
</blockquote>
<p>The wp-config.php file is the heart of your wordpress site that stores all the database connection information that WordPress needs inorder to connect to the database. This file contains the name, address and password of the MySQL database that stores all of your user info, blog posts and other important content.<br />
Using a secret key, you can make it even more difficult for someone to gain access to your account.</p>
<p>Go to <a href="https://api.wordpress.org/secret-key/1.1/" target="_blank">https://api.wordpress.org/secret-key/1.1/</a> and copy the results into this section of your wp-config.php file if you havenâ€™t already set up a secret key.</p>
<p><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/wp-keys.jpg" alt="" title="wp-keys" width="577" height="318" /></p>
<blockquote>
<h1>3: Strong WordPress Passwords</h1>
</blockquote>
<p>In addition to adding a secret key to your wp-config.php file, also consider changing your user password to something that is strong and unique. WordPress will tell you the strength of your password, but a good tip is to avoid common phrases, use upper and lowercase letters, and include numbers. Itâ€™s also a good idea to change your password regularly â€” say once every six months.</p>
<p style="text-align:center;"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/strong-password.jpg" alt="" title="strong-password" width="366" height="142" class="alignnone size-full wp-image-1936" /></p>
<blockquote>
<h1>4: Stay Up To Date</h1>
</blockquote>
<p>keeping your WordPress site up-to-date is one of the easiest things you can do. For the last few versions, WordPress has included the ability to install automatic updates. Not only that, but sites are notified every time a new upgrade becomes available.</p>
<p>If you arenâ€™t running the latest version of WordPress, upgrade now. Leaving your site on an old version is like keeping your door unlocked when you leave for vacation.</p>
<p style="text-align:center;"><img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/wp-upgrade-msg.jpg" alt="" title="wp-upgrade-msg" width="587" height="89" class="alignnone size-full wp-image-1938" /></p>
<blockquote>
<h1>5: HTAccess Tips</h1>
</blockquote>
<p>Using a .htaccess file, you can set access limits to certain directories. You can tie those limits to a specific IP address, which means that only people from that location can access your information. below is my top tips for keeping your site secure using the htaccess file.</p>
<h3><strong>Disable Hotlinking</strong></h3>
<p>Sometimes another site may directly link images from your site. It saves hard disk space by not having to store the images. But your site ends up serving the requests for them, thus using up your precious bandwidth. This is known as â€˜hotlinkingâ€™. To disable this you can add these lines to the .htaccess</p>
<div class="code_block">#disable hotlinking of images with forbidden or custom image option<br />
RewriteEngine on<br />
RewriteCond %{HTTP_REFERER} !^$<br />
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]<br />
#RewriteRule \.(gif|jpg)$ â€“ [F]<br />
RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/stealingisbad.gif [R,L]</div>
<h3><strong>Stop Spammers</strong></h3>
<p>Like hotlinking, spammers are notorious to use up your siteâ€™s resources. There are a number of ways to identify a potential spammer. One of them is to detect requests with â€˜no referrerâ€™. Spammers use bots to post comments on blogs and they come from â€˜nowhereâ€™. Add these lines to stop the spammers</p>
<div class="code_block">RewriteEngine On<br />
RewriteCond %{REQUEST_METHOD} POST<br />
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*<br />
RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]</p>
<p>RewriteCond %{HTTP_USER_AGENT} ^$<br />
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]</div>
<h3><strong>Protect WP-Config</strong></h3>
<p>The wp-config.php file in your WordPress installation contains some real important secrets, like database name, database username and password etc. You have no choice but to keep it secure.</p>
<div class="code_block"># protect wpconfig.php<br />
&lt;Files wp-config.php&gt;<br />
order allow,deny<br />
deny from all<br />
&lt;/Files&gt;</div>
<h3><strong>Disable Directory Browsing</strong></h3>
<p>Someone who knows the directory structure of a WordPress installation, may use his knowledge to do some damage. Besides you should not let them know what plug-ins are you using.</p>
<div class="code_block"># disable directory browsing<br />
Options All -Indexes</div>
<h3><strong>Protect .htaccess itself!</strong></h3>
<p>Last thing you want after spending so much time protecting your site with .htaccess, is to leave the file itself open to attack. The following hack prevents external access to any file starttng with .hta</p>
<div class="code_block">&lt;Files ~ â€œ^.*\.([Hh][Tt][Aa])â€&gt;<br />
order allow,deny<br />
deny from all<br />
satisfy all<br />
&lt;/Files&gt;</div>
<p>Better still, you can rename the .htaccess to any other name you like</p>
<div class="code_block"># rename htaccess files<br />
AccessFileName ht.access</div>
<blockquote>
<h1>6: Plugins That Help</h1>
</blockquote>
<p>The wordpress plugin community has loads of helpful &#038; some not so helpful plugins that can help lock down your site to anyone wishing to cause it harm :| heres a few that i can recommend to anyone wishing to give them a try&#8230;</p>
<h3><strong>WP-Security-Scan</strong></h3>
<p>Scans your WordPress installation for security vulnerabilities and suggests corrective actions.<br />
Download it <a href="http://wordpress.org/extend/plugins/wp-security-scan/" target="_blank">here</a></p>
<h3><strong>TTC WordPress Security Tool</strong></h3>
<p>This plugin blocks scrapers, cross-site scripting attempts, and other ill behaved bots. This is the second of three security plugins.<br />
Download it <a href="http://wordpress.org/extend/plugins/ttc-wordpress-security-plugin/" target="_blank">here</a></p>
<div class="code_block">
<hr />
</div>
<blockquote>
<h1>Final Thoughts</h1>
</blockquote>
<p>Even though every step has been taken to secure your blog/website, there are still people out there that will still find a way in even with all the security messures in place.. hopefully this list of tips will at least make there hacking attempts a long and pain ful experience, Have any other helpful tips for securing your blog/website? let us know in the comments below&#8230;!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/how-to-secure-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How To Add Recent Comments To Your WordPress Theme The Easy Way</title>
		<link>http://www.martin-gardner.co.uk/how-to-add-recent-comments-to-your-wordpress-theme-the-easy-way/</link>
		<comments>http://www.martin-gardner.co.uk/how-to-add-recent-comments-to-your-wordpress-theme-the-easy-way/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 12:54:44 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[get_comments()]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1869</guid>
		<description><![CDATA[When working with wordpress themes sometimes its handy to have little code snippets for dropping into your theme, this highly customisable snippet will grab your most recent comments and loop through them as many times as needed, Features: Comment Count Comment Status Comment Type Comment Gravatar Comment Link Post Title with Permalink Check out the [...]]]></description>
			<content:encoded><![CDATA[<p>When working with wordpress themes sometimes its handy to have little code snippets for dropping into your theme, this highly customisable snippet will grab your most recent comments and loop through them as many times as needed,<br />
<span id="more-1869"></span><br />
<img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/wp-logo.png" alt="" title="wp-logo" width="500" height="310" class="aligncenter size-full wp-image-1883" /></p>
<p><strong>Features:</strong></p>
<blockquote><p>
Comment Count<br />
Comment Status<br />
Comment Type<br />
Comment Gravatar<br />
Comment Link<br />
Post Title with Permalink
</p></blockquote>
<p>Check out the source below&#8230;</p>
<h2>Source Code</h2>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$recent_comments = get_comments( array(
  'number'    =&gt; 5,
  'status'    =&gt; 'approve',
  'type'	=&gt; 'comment'
) );

foreach ($recent_comments as $comment)
{
?&gt;
&lt;li&gt;
&lt;a href=&quot;&lt;?php echo get_permalink($comment-&gt;comment_post_ID);?&gt;&quot; title=&quot;&lt;?php echo $comment-&gt;comment_author;?&gt; on &lt;?php echo get_the_title($comment-&gt;comment_post_ID); ?&gt;&quot;&gt;
&lt;?php echo get_avatar( $comment-&gt;comment_author_email, '55' ); ?&gt;
&lt;/a&gt;
&lt;h3&gt;
&lt;a href=&quot;&lt;?php echo get_permalink($comment-&gt;comment_post_ID);?&gt;#comment-&lt;?php echo $comment-&gt;comment_ID;?&gt;&quot; title=&quot;&lt;?php echo $comment-&gt;comment_author;?&gt; on &lt;?php echo get_the_title($comment-&gt;comment_post_ID); ?&gt;&quot;&gt;
&lt;?php echo get_the_title($comment-&gt;comment_post_ID); ?&gt;
&lt;/a&gt;
&lt;/h3&gt;
By: &lt;?php echo $comment-&gt;comment_author;?&gt;
&lt;/li&gt;
&lt;?php
}
?&gt;
</pre>
<p>OK so lets walk through the code..</p>
<h2>get_comments()</h2>
<blockquote style="margin-top: 10px;"><p>Using the WordPress function <em>get_comments()</em> we can use an array of arguments to pass into this function to retrieve what we need, the <a href="http://codex.wordpress.org/Function_Reference/get_comments">wordpress codex</a> page gives a small but tidy explanation of this function.</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
&lt;?php $defaults = array(
    'author_email' =&gt; '' ,
    'ID' =&gt; '',
    'karma' =&gt; '',
    'number' =&gt; '',
    'offset' =&gt; '',
    'orderby' =&gt; '',
    'order' =&gt; 'DESC',
    'parent' =&gt; '',
    'post_id' =&gt; '',
    'status' =&gt; '',
    'type' =&gt; '',
    'user_id' =&gt; '' ); ?&gt;
</pre>
<p>Passing in our arguments of <em>number=5, status=approved &#038; type=comment</em> (this should be self explaining) we want to show only 5 comments in our list, they must be approved, and have the type comment, </p>
<blockquote><p>
<strong>TIP</strong><br />
If we didnt use the type=> &#8216;comment&#8217; argument then the results, would include any &#8216;<em>pingbacks</em>&#8216; which is not what we want to show, only comments&#8230;
</p></blockquote>
<p>Next we use the PHP foreach loop so we iterate through each result, and display our content anyway we want..<br />
if you were to use the PHP print_r() function before the foreach loop, the output will show you all values in that array, </p>
<p><strong>Example</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
echo &quot;&lt;pre&gt;&quot;;
print_r($recent_comments);
echo &quot;&lt;/pre&gt;&quot;;
?&gt;
</pre>
<p>the print_r() function above will print out something similar to this</p>
<pre class="brush: php; title: ; notranslate">
[0] =&gt; stdClass Object
        (
            [comment_ID] =&gt; 23387
            [comment_post_ID] =&gt; 32
            [comment_author] =&gt; Marty
            [comment_author_email] =&gt; myemail@myemail.com
            [comment_author_url] =&gt; http://www.martin-gardner.co.uk
            [comment_author_IP] =&gt; 11.111.11.111
            [comment_date] =&gt; 2010-09-22 08:09:24
            [comment_date_gmt] =&gt; 2010-09-22 07:09:24
            [comment_content] =&gt; the content of the comment
            [comment_karma] =&gt; 0
            [comment_approved] =&gt; 1
            [comment_agent] =&gt; Mozilla
            [comment_type] =&gt;
            [comment_parent] =&gt; 0
            [user_id] =&gt; 2
            [comment_subscribe] =&gt; N
        )
</pre>
<p>This is just one result from my array, </p>
<h2>Generate a Gravatar</h2>
<p>Using a call to the comment_author_email value we can do a check to see if that user has a gravatar icon assosiated with there account&#8230; if they have then we can print it to the screen, if not then we can just show our own default gravatar picture&#8230;</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php echo get_avatar( $comment-&gt;comment_author_email, '55' ); ?&gt;
</pre>
<h2>Generate The Permalink</h2>
<p>Using the wordpress function get_permalink() we can in our value for the post ID which will produce the permalink needed for the post</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php echo get_permalink($comment-&gt;comment_post_ID);?&gt;
</pre>
<h2>End Results</h2>
<p>After you have all your code in the right places you should end up with something like this<br />
<img src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/09/recent_comments.jpg" alt="" title="recent_comments" width="205" height="430" class="aligncenter size-full wp-image-1882" /></p>
<h2>Final Thoughts</h2>
<p>Using the get_comments() function we can cut down on the ammount code we have to write, I know theres lots of other variations out there that will do nearly everything you need, but this dosnt need any messy select statements or crazy database joins to get the job done.. </p>
<p>What do you rekon? have a better, simple way? of getting the job done, feel free to share it..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/how-to-add-recent-comments-to-your-wordpress-theme-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Get Your WordPress Plugin To DROP TABLE From The Database</title>
		<link>http://www.martin-gardner.co.uk/how-to-get-your-wordpress-plugin-to-drop-table-from-the-database/</link>
		<comments>http://www.martin-gardner.co.uk/how-to-get-your-wordpress-plugin-to-drop-table-from-the-database/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 00:10:52 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1438</guid>
		<description><![CDATA[I&#8217;m going to show you an easy way, how to get rid of your database tables &#38; options when the plugin is deactivated, that&#8217;s if you want them deleted? If you&#8217;ve ever made a plugin or thought about making a plugin for wordpress which includes its own set of database tables, then the chances are [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to show you an easy way, how to get rid of your database tables &amp; options when the plugin is deactivated, that&#8217;s if you want them deleted?<br />
<span id="more-1438"></span></p>
<blockquote style="line-height: 18px;"><p><a href="http://www.martin-gardner.co.uk/contact/"><img class="alignnone size-full wp-image-1440" style="margin: 0px 0px 10px 10px;" title="Wordpress - Do you need Help?" src="http://www.martin-gardner.co.uk/wp-content/uploads/2010/01/wordpress.jpg" alt="Wordpress - Do you need Help?" width="287" height="182" align="right" /></a></p>
<p>If you&#8217;ve ever <a href="http://www.martin-gardner.co.uk/wordpress/">made a plugin</a> or thought about <a href="http://www.martin-gardner.co.uk/how-to-add-a-wordpress-theme-admin-page/">making a plugin for wordpress</a> which includes its own set of database tables, then the chances are (like most plug-ins) they wont remove the data when the plug-ins been de-activated.</p>
<p>In most cases this is to preserve the data in those tables, Just in case the user wants to reactivate the plugin with all the options still saved, or in other case&#8217;s, it&#8217;s just plain lazy?</p></blockquote>
<h2 style="color: #dc1000;">The Function</h2>
<pre class="brush: php; title: ; notranslate">
&lt;?php
function pluginUninstall() {
  global $wpdb;
  $thetable = $wpdb-&gt;prefix.&quot;your_table_name&quot;;
  //Delete any options that's stored also?
  //delete_option('wp_yourplugin_version');
  $wpdb-&gt;query(&quot;DROP TABLE IF EXISTS $thetable&quot;);
}
?&gt;
</pre>
<p>What you have to do is hook this Function into wordpress.<br />
So when the plugin is de-activated you want this code to run&#8230;</p>
<h2 style="color: #dc1000;">The Hook</h2>
<blockquote><p>To do this, we call&#8230;</p>
<p><strong>register_deactivation_hook($file, $function)</strong></p>
<p>This wordpress function takes 2 parameters in order for it to work&#8230;</p>
<ol>
<li>The File to be called</li>
<li>The Function to run</li>
</ol>
</blockquote>
<h2 style="color: #dc1000;">Example:</h2>
<p>If your plugin is located in either of following locations<br />
http://www.yourblog.com/wp-content/plugins/yourplugin.php or</p>
<p>http://www.yourblog.com/wp-content/plugins/yourplugin/plugin-name.php</p>
<p>then you can use this..</p>
<blockquote><p><strong>register_deactivation_hook( __FILE__, &#8216;pluginUninstall&#8217; );</strong></p></blockquote>
<p>The <strong><em>__FILE__</em></strong> will point to were your function is located, (The Current File your working in) and the 2nd part after the comma is the name of the function which is being passed, in this case were calling our <strong><em>pluginUninstall</em></strong> function, this will then remove all the options and tables that&#8217;s been added in the function.</p>
<h2 style="color: #dc1000;">Preserve Your Data</h2>
<p>If your plugin needs to/or you want it to, keep some form of data behind after its de-activated, then you can simply write another function to handle that request, maybe you have an admin options page for your plugin? on there you can add a small section with a form, this can just have a button, which when pressed it can run the function and remove whatever data you would like&#8230;</p>
<blockquote><p>You know of any other way? feel free to share!</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/how-to-get-your-wordpress-plugin-to-drop-table-from-the-database/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Beautiful Custom Design WordPress Book</title>
		<link>http://www.martin-gardner.co.uk/a-beautiful-custom-design-wordpress-book/</link>
		<comments>http://www.martin-gardner.co.uk/a-beautiful-custom-design-wordpress-book/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 14:33:50 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1364</guid>
		<description><![CDATA[The Guys over at http://digwp.com have released there Beautiful Custom Design Book for wordpress&#8230; click on through for a full run down&#8230; or click here to go direct to the shop 400 Pages of Practical Information There is much to learn about the Worldâ€™s most popular publishing platform. From your first steps of learning about [...]]]></description>
			<content:encoded><![CDATA[<p>The Guys over at <a href="http://digwp.com/" target="_blank">http://digwp.com</a> have released there <em>Beautiful Custom Design Book</em> for wordpress&#8230; click on through for a full run down&#8230; or click <a href="https://www.e-junkie.com/ecom/gb.php?cl=88539&amp;c=ib&amp;aff=100026" target="_blank">here</a> to go direct to the shop</p>
<p><span id="more-1364"></span><br />
<a href="https://www.e-junkie.com/ecom/gb.php?cl=88539&amp;c=ib&amp;aff=100026" target="_blank"><img src="http://digwp.com/images/digwp-728x90.jpg" width="600" height="70" border="0" /></a></p>
<p><a href="https://www.e-junkie.com/ecom/gb.php?cl=88539&amp;c=ib&amp;aff=100026" target="_blank"><img class="alignnone" style="padding: 10px 0 10px 10px;" title="Digging into WordPress - The Book" src="http://digwp.com/images/digwpebook.gif" border="0" alt="" align="right" /></a></p>
<h3 style="color:#026EB6;">400 Pages of Practical Information</h3>
<p>There is much to learn about the Worldâ€™s most popular publishing platform. From your first steps of learning about WordPress all the way through maintaining a site throughout the years, this book is packed with truly practical information.</p>
<h3 style="color:#026EB6;">Beautiful Custom Design</h3>
<p>Design-wise, Digging into WordPress is a beautiful book: every page of the book is printed with stunning digital-color precision on gloss-finish paper, with each of its eight chapters color-coded to provide quick and easy navigation. With its large, clear typography, each page is easy on the eyes and easy to read.</p>
<h3 style="color:#026EB6;">PDF Version</h3>
<p>All printed copies of the book include a PDF version that you can read on your computer (or you can buy the PDF version alone). We know itâ€™s nice to have a real book to hold in your hands, but the PDF is also great for three big reasons:</p>
<ol>
<li><strong>Hyperlinked.</strong> All the many URLâ€™s in the book you can just click to go to the web page referenced. There is also internal linking â€“ you can click links in the table of contents to jump to those sections.</li>
<li><strong>Copy &amp; Paste code.</strong> Much easier to grab code via copy &amp; paste than retyping from scratch. Of course the page numbers in the book and PDF match, so if you are reading the book you can jump over to the PDF and go to that page to copy and paste. Youâ€™ll always know <em>exactly</em> where that code is.</li>
<li><strong>Search.</strong> The book has an appendix, but thatâ€™s never quite as good as just using your PDF readers search feature to find what you are looking for.</li>
</ol>
<p><a href="https://www.e-junkie.com/ecom/gb.php?cl=88539&amp;c=ib&amp;aff=100026" target="_blank"><img class="alignnone" style="padding: 10px 0 10px 10px;" title="Digging into WordPress - The Book" src="http://digwp.com/images/250x250-Campaign.png" border="0" alt="" align="right" /></a></p>
<p><em><a title="Download Free Demo PDF" href="http://digwp.com/book-demo/Digging-Into-WP-DEMO.pdf" target="_blank">Download a free PDF sample of the book..</a></em><br />
<small>Features entire Table of Contents &amp; part of Chapter 3</small></p>
<h3 style="color:#026EB6;">A Lifetime Subscription</h3>
<p>When you buy this book, you will instantly get the most current version. But also, you are getting a lifetime subscription to all updated (PDF) copies of the book. Updates will automatically be emailed to you as they are released.</p>
<h3 style="color:#026EB6;">Spiral Bound!</h3>
<p>How many tech books do you wish would JUST FLIPPING ?!@!*! STAY FLAT while you are trying to reference them while at the computer.</p>
<h3 style="color:#026EB6;">Lots of Code Samples</h3>
<p>We go into depth about the anatomy of a WordPress theme. How they work, and how to write the code you need to do the things you want. This means real code that you can sink your teeth into, as well as copy and paste. Beyond theme building, we introduce many tricks your functions.php file can pull off and show you ways to increase performance and security through HTAccess.</p>
<p><em><a title="Learn more!" href="http://digwp.com/book/learn-more/" target="_blank">Learn more about Digging into WordPress..</a></em></p>
<h3 style="color:#026EB6;">Authors</h3>
<p>Written by Chris Coyier and Jeff Starr, who eat their own dog food when it comes to talking WordPress. Between them, nearly 100 WordPress sites manufactured.</p>
<p><em><a title="About the Authors" href="http://digwp.com/about/" target="_blank">Learn more about the authors..</a></em></p>
<h1 style="color:#026EB6;">Get the Book!</h1>
<p><a href="https://www.e-junkie.com/ecom/gb.php?cl=88539&amp;c=ib&amp;aff=100026" target="_blank"><img class="alignnone" title="Digging into WordPress - The Book" src="http://digwp.com/images/realbook.png" border="0" alt="" /></a></p>
<p><a href="https://www.e-junkie.com/ecom/gb.php?cl=88539&amp;c=ib&amp;aff=100026" target="ejejcsingle" target="_blank">Click here to visit Sales @ Digging Into WordPress.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/a-beautiful-custom-design-wordpress-book/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To List WordPress Child Pages Only On That Parent Page</title>
		<link>http://www.martin-gardner.co.uk/how-to-list-wordpress-child-pages-only-on-that-parent-page/</link>
		<comments>http://www.martin-gardner.co.uk/how-to-list-wordpress-child-pages-only-on-that-parent-page/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 13:56:42 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[parent page]]></category>
		<category><![CDATA[post->post_parent]]></category>
		<category><![CDATA[sub page]]></category>
		<category><![CDATA[wp_list_pages()]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1220</guid>
		<description><![CDATA[How to create a dynamic list of page title links when you are on a page that has sub pages, ie: If using a gallery for a page, were each sub-page is a gallery of images When you have multiple pages in your wordpress website, either using it as a blog or as a complete [...]]]></description>
			<content:encoded><![CDATA[<p>How to create a dynamic list of page title links when you are on a page that has sub pages, ie: If using a gallery for a page, were each sub-page is a gallery of images<br />
<span id="more-1220"></span><br />
When you have multiple pages in your wordpress website, either using it as a blog or as a complete CMS, this quick tip will help show you how to:</p>
<blockquote>
<p style="text-align: center; color:#DC1000;"><strong>Only show those child pages of the parent page,<br />
Only when you are on that Parent page!</strong></p>
</blockquote>
<p>Below is the HTML framework for our sidebar navigation&#8230;</p>
<ul>
<li>Gallery
<ul>
<li>page 1</li>
<li>page 2</li>
<li>page 3</li>
<li>page 4</li>
<li>page 5</li>
</ul>
</li>
</ul>
<pre class="brush: php; title: ; notranslate">
&lt;ul&gt;
   &lt;li&gt;Gallery
     &lt;ul&gt;
        &lt;li&gt;page 1&lt;/li&gt;
        &lt;li&gt;page 2&lt;/li&gt;
        &lt;li&gt;page 3&lt;/li&gt;
        &lt;li&gt;page 4&lt;/li&gt;
        &lt;li&gt;page 5&lt;/li&gt;
     &lt;/ul&gt;
   &lt;/li&gt;
&lt;/ul&gt;
</pre>
<blockquote><p>When on the &#8220;<strong>PARENT</strong>&#8221; page,</p>
<p>The code in the sidebar, navigation menu or page,<br />
will be populated with a list of Child Sub pages for THAT current PARENT page only&#8230;</p></blockquote>
<p>Copy the code below into your sidebar, and try it&#8230;</p>
<pre class="brush: php; title: ; notranslate">
  &lt;?php if ( is_page() ) {
      if($post-&gt;post_parent)
      $children = wp_list_pages('sort_column=menu_order&amp;title_li=&amp;child_of='.$post-&gt;post_parent.'&amp;echo=0');
else
      $children = wp_list_pages('sort_column=menu_order&amp;title_li=&amp;child_of='.$post-&gt;ID.'&amp;echo=0');
      if ($children) {
   ?&gt;
      &lt;div class=&quot;sidebar&quot;&gt;
&lt;h2&gt;Sub-pages of Current Page&lt;/h2&gt;
&lt;ul&gt;
      	&lt;?php echo $children; ?&gt;
      	&lt;/ul&gt;
      &lt;/div&gt;
   &lt;?php
} // End If Post
       } // End if is page
   ?&gt;
</pre>
<p>As long as your Page has at least one associated child page, the list will be shown, if there are no child pages then the menu will not be shown.. this is handy if you&#8217;re sidebar is quite packed with elements/ads, this will be generated only on that parent page&#8230;</p>
<p>you can check out the example on the <a href="http://www.shugtech.co.uk/gallery">Shugtech Gallery</a> website.<br />
Each Gallery Album is a child of Gallery, so each image gallery is a separate wp page were the list of other Albums available is on the right hand sidebar&#8230;</p>
<p>As always feedback is welcome..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/how-to-list-wordpress-child-pages-only-on-that-parent-page/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>How To Add A WordPress Theme Options Page</title>
		<link>http://www.martin-gardner.co.uk/how-to-add-a-wordpress-theme-admin-page/</link>
		<comments>http://www.martin-gardner.co.uk/how-to-add-a-wordpress-theme-admin-page/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 18:00:27 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1111</guid>
		<description><![CDATA[In this post you&#8217;ll find out how to add and create a custom wordpress theme options page inside the administration area which will let you Add/Edit your own Youtube video, for use in your sidebar. What will be created Download the Source Code Getting Started In order for you to add your theme settings page [...]]]></description>
			<content:encoded><![CDATA[<p>In this post you&#8217;ll find out how to add and create a custom wordpress theme options page inside the administration area which will let you Add/Edit your own <a title="Check out my Youtube Channel" href="http://www.youtube.com/user/MartyFaeScotland" target="_blank">Youtube </a>video, for use in your sidebar.</p>
<p><span id="more-1111"></span></p>
<h3>What will be created</h3>
<blockquote>
<p style="text-align: center;" align="center"><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/wp-admin-theme-settings.jpg"><img class="aligncenter size-medium wp-image-1149" title="wp-admin-theme-settings" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/wp-admin-theme-settings.jpg" alt="wp-admin-theme-settings" width="515" height="161" /></a></p>
</blockquote>
<blockquote>
<h2>Download the Source Code</h2>
<p align="center"><a href="http://www.martin-gardner.co.uk/wp/how-to-create-a-wordpress-theme-admin-options-page.rar"><img class="aligncenter size-full wp-image-473" title="Download Now" src="http://www.martin-gardner.co.uk/wp-content/uploads/2008/11/download_now.gif" alt="Download Now" width="226" height="44" align="center" /></a></p>
</blockquote>
<h3>Getting Started</h3>
<p>In order for you to add your theme settings page you will have to modify a few files located inside you wordpress theme directory this is normally located in:</p>
<blockquote><p>/wp-content/themes/YourThemeName/</p></blockquote>
<p>As long as you have proper write permissions on your theme folder You can use the built in <a title="edit your wordpress themes using the inbuilt editor" href="http://www.martin-gardner.co.uk/how-to-create-a-wordpress-copyright-footer-message/" target="_self">wordpress theme editor</a> to edit all the theme files for creating your theme options page, If not i would recommend using the FREE <a title="FireFTP is a free, secure, cross-platform FTP client for Mozilla Firefox" href="http://fireftp.mozdev.org/" target="_blank">fireftp</a> plugin for <a title="The Best browser out there." href="http://www.mozilla.com/en-US/firefox/upgrade.html" target="_blank">firefox</a>, to download/edit the files locally.</p>
<p>The first file we need to edit will be the functions.php file, this file loads first before the theme is processed, which acts in the same manner as a plugin: read more on the <a href="http://codex.wordpress.org/Theme_Development" target="_blank">functions.php</a> file.</p>
<h2><span style="text-decoration: underline;">Functions.php</span></h2>
<p>you can just paste the code from our options page straight into the functions.php file, but I like to keep it clean so we can reference our options page inside the functions.php file first.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php include(&quot;options.php&quot;);?&gt;
</pre>
<p>We can then create a new page inside your themes root directory(if you can), called &#8220;<em>options.php</em>&#8221; Where first part of the code can be pasted in.</p>
<h2><span style="text-decoration: underline;">Options.php</span></h2>
<pre class="brush: php; title: ; notranslate">
$settings = array(
 'youtube' =&gt; 'kGl-2Lst1Kk' //Greenock Donnies Quad Biking Video
);
$themename = &quot;Your Theme Name&quot;;
$shortname = &quot;yourthemename&quot;;
$options = array (
              array(Ã‚Â  &quot;name&quot; =&gt; &quot;Main Options&quot;,
                      &quot;type&quot; =&gt; &quot;header&quot;
              ),
              array(Ã‚Â  &quot;name&quot; =&gt; &quot;Youtube Video ID&quot;,
                      &quot;id&quot; =&gt; $shortname.&quot;_youtube&quot;,
                      &quot;std&quot; =&gt; $settings['youtube'],
                      &quot;type&quot; =&gt; &quot;text&quot;,
                      &quot;note&quot; =&gt; &quot;&lt;strong&gt;Example: &lt;/strong&gt; http://www.youtube.com/watch?v=&lt;strong style='color: #ff0000;'&gt;kGl-2Lst1Kk&lt;/strong&gt;&quot;
              )
 );
?&gt;
</pre>
<p>The above starts to build a few array&#8217;s to hold our settings in place were we can reference them using very simple calls,</p>
<h3><span style="text-decoration: underline;">Settings</span></h3>
<p>The main settings holds one  default variable called &#8220;<em>$settings</em>&#8221; this will Initialize our <a href="http://uk2.php.net/manual/en/language.types.array.php" target="_blank">Associative Array</a> this holds 2 values, the main option called <em>&#8220;<strong>Name</strong></em><em>&#8220;</em> with a value of &#8220;<strong><em>youtube</em></strong>&#8220;, and the <em>&#8220;<strong>type</strong>&#8220;</em> with a value of &#8220;<strong><em>header</em></strong>&#8221;</p>
<p>We don&#8217;t want the script to load and break the front end of the website, when there&#8217;s no default data to pull the video from youtube(Ok so it might not break it, but will, at least generate a few javascript errors, so we put in place a default value.)</p>
<h3><span style="text-decoration: underline;">Options</span></h3>
<p>The options array builds out our mini plugin which we can manipulate using the associative arrays, setting the theme name along with short names allows us to access a variable to call when needed.</p>
<pre class="brush: php; title: ; notranslate">
function mytheme_add_admin() {
         global $themename, $shortname, $options;
             if ( $_GET['page'] == basename(__FILE__) )
             {
                  if ( 'save' == $_REQUEST['action'] )
                  {
                      foreach ($options as $value)
                      {
                             if ($value['type']!='header')
                         {
                             update_option( $value['id'], $_REQUEST[ $value['id'] ] );
                         }
                      }
                      foreach ($options as $value)
                      {
                             if( isset( $_REQUEST[ $value['id'] ] ) )
                             {
                                 update_option( $value['id'], $_REQUEST[ $value['id'] ]Ã‚Â  );
                             } else {
                                 delete_option( $value['id'] );
                             }
                      }
                      header(&quot;Location: themes.php?page=settings.php&amp;saved=true&quot;);
                      die;
                  } else if( 'reset' == $_REQUEST['action'] )
                      {
                          foreach ($options as $value)
                      {
                          delete_option( $value['id'] );
                      }
                          header(&quot;Location: themes.php?page=settings.php&amp;reset=true&quot;);
                          die;
                      }
                   }
add_theme_page($themename.&quot; Options&quot;, &quot;Theme Options&quot;, 'edit_themes', basename(__FILE__), 'mytheme_admin');
}// end function

function mytheme_admin() {
         global $themename, $shortname, $options;

         if ( $_REQUEST['saved'] ) echo '&lt;div id=&quot;message&quot;&gt;&lt;p&gt;&lt;strong&gt;'.$themename.' settings saved.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;';
         if ( $_REQUEST['reset'] ) echo '&lt;div id=&quot;message&quot;&gt;&lt;p&gt;&lt;strong&gt;'.$themename.' settings reset.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;';

// leave the function &quot;&lt;em&gt;mytheme_admin()&lt;/em&gt;&quot; Open until for part 2 of the code.
?&gt;
</pre>
<p>The main function at the top &#8220;<strong><em>mytheme_add_admin()</em></strong>&#8221; will check the $_GET;Ã‚Â  then do a series of checks to identify any requests that may be passed, either through the $_GET or $_POST method which will be referenced through the $_REQUEST variable which contains the content of both $_GET, $_COOKIE, and $_POST.</p>
<blockquote><p><strong>The First check</strong>: will see if our form was posted, which includes our &#8220;<strong>action</strong>&#8221; with a value &#8220;<strong>save</strong>&#8220;, then loop through our options and using the wordpress hook &#8220;<em><strong>update_option()</strong></em>&#8221; which will update our options in the database, thenÃ‚Â  finally redirecting the user back to the themes page, with a nice fade-in message.</p></blockquote>
<blockquote><p><strong>The Second check:</strong> Still checks to see if the form was posted, but this time, checks to see if &#8220;<em><strong>action</strong></em>&#8221; has a value of &#8220;<em><strong>reset</strong></em>&#8220;, if this is present then the user must have clicked the reset button, this will use the wordpress hook &#8220;<em><strong>delete_option()</strong></em>&#8221; and remove the options set in the database for our video id.</p></blockquote>
<blockquote><p><strong>The End:</strong> of the Function also uses a wordpress hook &#8220;<em><strong>add_theme_page()</strong></em>&#8220;,</p>
<p>This builds out our Options page in the administration area, the first parameter of the function takes our &#8220;<em><strong>$themename</strong></em>&#8221; variable and appends &#8220;<em><strong>settings</strong></em>&#8221; to the end of it to produce: &#8220;<em><strong>Your theme name Options</strong></em>&#8221; which will be the title header used on the options page,</p>
<p>The next parameter is the &#8220;<em><strong>Name</strong>&#8220;</em>, which is used inside the navigation sidebar, the &#8220;<em><strong>edit_themes</strong></em>&#8221; parameter tells wordpress to insert the &#8220;<em><strong>Theme Options</strong></em>&#8221; text inside the Appearance navigation block on the sidebar, So when you click expand on the Appearance tab it will show.</p>
<p align="center">
<div id="attachment_1126" class="wp-caption aligncenter" style="width: 510px"><img class="size-full wp-image-1126" title="wp-theme-options" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/theme-options.jpg" alt="wp-theme-options" width="500" height="270" /><p class="wp-caption-text">Theme Options Visible in Under the Appearence tab.</p></div></blockquote>
<h3><span style="text-decoration: underline;">Admin Page</span></h3>
<p>In order for us to have our admin options page, we will need to build our options page, this will load after clicking the Theme options link, the first thing were going to do introduce some CSS styles to the page,</p>
<pre class="brush: php; title: ; notranslate">
&lt;style type=&quot;text/css&quot;&gt;
th { text-align: left; }
td { padding: 5px 10px !important; }
tr.header {background-color: #99CC66 !important;color: #ffffff;}
.header td {padding: 2px 10px !important;font-size: 14px !important;font-weight: bold !important; }
&lt;/style&gt;
</pre>
<h3><span style="text-decoration: underline;">The Wrap</span></h3>
<blockquote><p>The Wrap is what we are given to use as a container to bring the wordpress theme options inline with the current default admin css within the admin area, The class which when used, can encompass a lot of various already defined wordpress styles.</p>
<p align="center">
<div id="attachment_1142" class="wp-caption aligncenter" style="width: 551px"><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/wp-admin-wrap-area.jpg"><img class="size-medium wp-image-1142" title="wp-admin-wrap-area" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/wp-admin-wrap-area.jpg" alt="The Area in which you can modify" width="541" height="468" /></a><p class="wp-caption-text">The Area in which you can modify</p></div></blockquote>
<pre class="brush: php; title: ; notranslate">
&lt;div class=&quot;wrap&quot;&gt;
 &lt;h2&gt;&lt;?php echo $themename; ?&gt; Settings&lt;/h2&gt;
  &lt;form method=&quot;post&quot;&gt;
    &lt;table class=&quot;form-table&quot;&gt;
&lt;?php foreach ($options as $value) { if ($value['type'] == &quot;text&quot;) { ?&gt;
&lt;tr&gt;
    	   &lt;th scope=&quot;row&quot; style=&quot;width: 25%&quot;&gt;
&lt;?php echo $value['name']; ?&gt;:
&lt;/th&gt;
       	   &lt;td&gt;
        	&lt;input onfocus=&quot;this.select();&quot; name=&quot;&lt;?php echo $value['id']; ?&gt;&quot; id=&quot;&lt;?php echo $value['id']; ?&gt;&quot; type=&quot;&lt;?php echo $value['type']; ?&gt;&quot; value=&quot;&lt;?php if ( get_settings( $value['id'] ) != &quot;&quot;) { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?&gt;&quot; /&gt;
&amp;nbsp; &amp;nbsp; &lt;?php echo $value['note']; ?&gt;
    	   &lt;/td&gt;
&lt;/tr&gt;
&lt;?php } elseif ($value['type'] == &quot;select&quot;) { ?&gt;
    	&lt;tr&gt;
        &lt;th scope=&quot;row&quot;&gt;
              &lt;?php echo $value['name']; ?&gt;:
        &lt;/th&gt;
          &lt;td&gt;
            &lt;select name=&quot;&lt;?php echo $value['id']; ?&gt;&quot; id=&quot;&lt;?php echo $value['id']; ?&gt;&quot;&gt;
                &lt;?php foreach ($value['options'] as $option) { ?&gt;
                &lt;option value=&quot;&lt;?php echo $option; ?&gt;&quot; &lt;?php if ( get_settings( $value['id'] ) == $option) { echo ' selected=&quot;selected&quot;'; } elseif ($option == $value['std']) { echo ' selected=&quot;selected&quot;'; } ?&gt;&gt;
                   &lt;?php echo $option; ?&gt;
                &lt;/option&gt;
                &lt;?php } ?&gt;
            &lt;/select&gt;
&amp;nbsp; &amp;nbsp; &lt;?php echo $value['note']; ?&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;?php } elseif ($value['type'] == &quot;header&quot;) {?&gt;
&lt;tr class=&quot;header&quot;&gt;
          &lt;td colspan=&quot;2&quot;&gt;
             &lt;?php  echo $value['name'] ?&gt; &amp;nbsp; &amp;nbsp;
                &lt;span style=&quot;font-size: 11px; font-weight: normal;&quot;&gt;
                  &lt;?php echo $value['note']; ?&gt;
                &lt;/span&gt;
           &lt;/td&gt;
         &lt;/tr&gt;
&lt;?php  }  } ?&gt;
     &lt;/table&gt;
     &lt;p class=&quot;submit&quot;&gt;
     &lt;input name=&quot;save&quot; type=&quot;submit&quot; value=&quot;Save changes&quot; /&gt;
     &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;save&quot; /&gt;
    &lt;/p&gt;
  &lt;/form&gt;

  &lt;form method=&quot;post&quot;&gt;
   &lt;p class=&quot;submit&quot; style=&quot;border: 0;&quot;&gt;
    &lt;input name=&quot;reset&quot; type=&quot;submit&quot; value=&quot;Reset&quot; /&gt;
    &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;reset&quot; /&gt;
   &lt;/p&gt;
  &lt;/form&gt;
&lt;/div&gt;
&lt;?php }//end function `mytheme_admin()` ?&gt;
&lt;?php
function mytheme_settings($key) {
global $settings;
return $settings[$key];
}?&gt;
</pre>
<h3><span style="text-decoration: underline;">The Wrap Exposed</span></h3>
<blockquote><p>This is what will be created once the codes been uploaded.</p>
<p align="center"><a href="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/wp-admin-theme-settings.jpg"><img class="aligncenter size-medium wp-image-1149" title="wp-admin-theme-settings" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/wp-admin-theme-settings-300x94.jpg" alt="wp-admin-theme-settings" width="300" height="94" /></a></p>
</blockquote>
<h3><span style="text-decoration: underline;">CSS Admin Styles</span></h3>
<blockquote><p>Included within the class wrap is a variety of various other classes that you can use inside your Theme Options page, these are outlined below, these give various design astetics to either the theme options page or if your creating a wordpress  plugin these will give it a more wordpress look and feel without the hassle of creating your own styles.</p>
<p align="center">
<div id="attachment_1138" class="wp-caption aligncenter" style="width: 531px"><img class="size-full wp-image-1138" title="wp-admin-headstyle" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/wp-admin-headstyle.jpg" alt="The Various CSS styles which can be applied" width="521" height="359" /><p class="wp-caption-text">The Various CSS styles which can be applied</p></div></blockquote>
<h3><span style="text-decoration: underline;">CSS Admin Styles</span></h3>
<p>The last thing that to be added to the &#8220;settings.php&#8221; page will be our wordpress hook to add the &#8220;mytheme_add_admin&#8221; to our admin menu, with a small for loop to grab and loop through our options for the theme settings.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php add_action('admin_menu', 'mytheme_add_admin'); ?&gt;
&lt;?php
   foreach ($options as $value) {
       if (get_settings( $value['id'] ) === FALSE)
       {
           $$value['id'] = $value['std'];
       } else {
           $$value['id'] = get_settings( $value['id'] );
       }
   }

   foreach ($settings as $k=&gt;$v) {
      $var = $shortname.'_'.$k;
      if (!empty($$var)) $settings[$k] = $$var;
   }
?&gt;
</pre>
<h3><span style="text-decoration: underline;">Settings page in Full</span></h3>
<p>below is the full source of the settings.php page, save this and upload into your theme directory</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$settings = array(
    'youtube' =&gt; 'H5h95s0OuEg'
);

# Settings
$themename = &quot;The Web News&quot;;
$shortname = &quot;thewebnews&quot;;
$options = array (
           array(  &quot;name&quot; =&gt; &quot;Main Settings&quot;,
                    &quot;type&quot; =&gt; &quot;header&quot;
           ),
           array( &quot;name&quot; =&gt; &quot;Youtube Video ID&quot;,
                  &quot;id&quot; =&gt; $shortname.&quot;_youtube&quot;,
                  &quot;std&quot; =&gt; $settings['youtube'],
                  &quot;type&quot; =&gt; &quot;text&quot;,
                  &quot;note&quot; =&gt; &quot;&lt;strong&gt;Example: &lt;/strong&gt; http://www.youtube.com/watch?v=&lt;strong style='color: #ff0000;'&gt;H5h95s0OuEg&lt;/strong&gt;&quot;
          )
);

function mytheme_add_admin() {
    global $themename, $shortname, $options;
    if ( $_GET['page'] == basename(__FILE__) ) {
        if ( 'save' == $_REQUEST['action'] ) {
                foreach ($options as $value) {
                    if ($value['type']!='header') {
                        update_option( $value['id'], $_REQUEST[ $value['id'] ] );
                    }
                }
                foreach ($options as $value) {
                    if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }

                header(&quot;Location: themes.php?page=settings.php&amp;saved=true&quot;);
                die;

        } else if( 'reset' == $_REQUEST['action'] ) {

            foreach ($options as $value) {
                delete_option( $value['id'] );
           }
            header(&quot;Location: themes.php?page=settings.php&amp;reset=true&quot;);
            die;
        }
    }
    add_theme_page($themename.&quot; Settings&quot;, &quot;Theme Settings&quot;, 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
function mytheme_admin() {
    global $themename, $shortname, $options;
    if ( $_REQUEST['saved'] ) echo '&lt;div id=&quot;message&quot; class=&quot;updated fade&quot;&gt;&lt;p&gt;&lt;strong&gt;'.$themename.' settings saved.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;';
    if ( $_REQUEST['reset'] ) echo '&lt;div id=&quot;message&quot; class=&quot;updated fade&quot;&gt;&lt;p&gt;&lt;strong&gt;'.$themename.' settings reset.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;';
?&gt;

&lt;style type=&quot;text/css&quot;&gt;
th { text-align: left; }
td { padding: 5px 10px !important; }
tr.header {background-color: #99CC66 !important;color: #ffffff;}
.header td {padding: 2px 10px !important;font-size: 14px !important;font-weight: bold !important; }
&lt;/style&gt;

&lt;div class=&quot;wrap&quot;&gt;
 &lt;h2&gt;&lt;?php echo $themename; ?&gt; Settings&lt;/h2&gt;
  &lt;form method=&quot;post&quot;&gt;
    &lt;table class=&quot;form-table&quot;&gt;
      &lt;?php foreach ($options as $value) { if ($value['type'] == &quot;text&quot;) { ?&gt;
        &lt;tr&gt;
    	   &lt;th scope=&quot;row&quot; style=&quot;width: 25%&quot;&gt;
               &lt;?php echo $value['name']; ?&gt;:
           &lt;/th&gt;
       	   &lt;td&gt;
           &lt;input onfocus=&quot;this.select();&quot; name=&quot;&lt;?php echo $value['id']; ?&gt;&quot; id=&quot;&lt;?php echo $value['id']; ?&gt;&quot; type=&quot;&lt;?php echo $value['type']; ?&gt;&quot; value=&quot;&lt;?php if ( get_settings( $value['id'] ) != &quot;&quot;) { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?&gt;&quot; /&gt;
&amp;nbsp; &amp;nbsp; &lt;?php echo $value['note']; ?&gt;
     &lt;/td&gt;
   &lt;/tr&gt;
  &lt;?php } elseif ($value['type'] == &quot;select&quot;) { ?&gt;
    &lt;tr&gt;
       &lt;th scope=&quot;row&quot;&gt;&lt;?php echo $value['name']; ?&gt;:&lt;/th&gt;
        &lt;td&gt;
            &lt;select name=&quot;&lt;?php echo $value['id']; ?&gt;&quot; id=&quot;&lt;?php echo $value['id']; ?&gt;&quot;&gt;
                &lt;?php foreach ($value['options'] as $option) { ?&gt;
                &lt;option value=&quot;&lt;?php echo $option; ?&gt;&quot; &lt;?php if ( get_settings( $value['id'] ) == $option) { echo ' selected=&quot;selected&quot;'; } elseif ($option == $value['std']) { echo ' selected=&quot;selected&quot;'; } ?&gt;&gt;&lt;?php echo $option; ?&gt;&lt;/option&gt;
                &lt;?php } ?&gt;
            &lt;/select&gt;
&amp;nbsp; &amp;nbsp; &lt;?php echo $value['note']; ?&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;?php
} elseif ($value['type'] == &quot;header&quot;) {?&gt;
     &lt;tr class=&quot;header&quot;&gt;
       &lt;td colspan=&quot;2&quot;&gt;
         &lt;?php  echo $value['name'] ?&gt; &amp;nbsp; &amp;nbsp;
         &lt;span style=&quot;font-size: 11px; font-weight: normal;&quot;&gt;
            &lt;?php echo $value['note']; ?&gt;
         &lt;/span&gt;
       &lt;/td&gt;
     &lt;/tr&gt;
&lt;?php } } ?&gt;
&lt;/table&gt;
&lt;p class=&quot;submit&quot;&gt;
    &lt;input name=&quot;save&quot; type=&quot;submit&quot; value=&quot;Save changes&quot; /&gt;
    &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;save&quot; /&gt;
&lt;/p&gt;
&lt;/form&gt;

&lt;form method=&quot;post&quot;&gt;
    &lt;p class=&quot;submit&quot; style=&quot;border: 0;&quot;&gt;
       &lt;input name=&quot;reset&quot; type=&quot;submit&quot; value=&quot;Reset&quot; /&gt;
       &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;reset&quot; /&gt;
    &lt;/p&gt;
&lt;/form&gt;
&lt;/div&gt;

&lt;?php }//end function `mytheme_admin()` ?&gt;

&lt;?php add_action('admin_menu', 'mytheme_add_admin'); ?&gt;

&lt;?php
foreach ($options as $value) {
      if (get_settings( $value['id'] ) === FALSE)
      {
         $$value['id'] = $value['std'];
      } else {
         $$value['id'] = get_settings( $value['id'] );
      }
}

foreach ($settings as $k=&gt;$v) {
   $var = $shortname.'_'.$k;
   if (!empty($$var)) $settings[$k] = $$var;
}
?&gt;
</pre>
<h3><span style="text-decoration: underline;">The Javascript</span></h3>
<p>the final addition to the script is using javascript to pull our youtube ID and print the youtube script to the page.<br />
We do this by creating a new javascript file, called &#8220;scripts.js&#8221; inside this file we save our code below.</p>
<pre class="brush: php; title: ; notranslate">
function showVideo(id) {
     document.write(&quot;&lt;object width=\&quot;269\&quot; height=\&quot;225\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/&quot;+id+&quot;&gt;&amp;amp;hl=en&amp;amp;fs=1\&quot;&gt;&lt;/param&gt;&lt;/param&gt;&lt;param name=\&quot;allowFullScreen\&quot; value=\&quot;true\&quot;&gt;&lt;/param&gt;&lt;param name=\&quot;allowscriptaccess\&quot; value=\&quot;always\&quot;&gt;&lt;/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/&quot;+id+&quot;&amp;amp;hl=en&amp;amp;fs=1\&quot; type=\&quot;application/x-shockwave-flash\&quot; allowscriptaccess=\&quot;always\&quot; allowfullscreen=\&quot;true\&quot; width=\&quot;269\&quot; height=\&quot;225\&quot; wmode=\&quot;transparent\&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&quot;);
}
</pre>
<h3><span style="text-decoration: underline;">Display your Video</span></h3>
<blockquote><p>First thing to do is modify your template header.php file to call our newly created javascript file. include this line below to call that file&#8230;</p></blockquote>
<pre class="brush: php; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php bloginfo('template_url'); ?&gt;/scripts.js&quot;&gt;&lt;/script&gt;
</pre>
<blockquote><p>once that&#8217;s done grab your sidebar.php file and call our included script</p></blockquote>
<pre class="brush: php; title: ; notranslate">&lt;script type=&quot;text/javascript&quot;&gt;showVideo('&lt;?php echo mytheme_settings(&quot;youtube&quot;) ?&gt;');&lt;/script&gt;</pre>
<h3><span style="text-decoration: underline;">Conclusion</span></h3>
<p>With the themes options page, you can start to create more and more functions, to build out your overall site options, ie: create an option to choose colours? choose font size? at this point the limits are endless..</p>
<p>You could go ahead and add as many options as you need, in-order to do what you want&#8230;</p>
<blockquote><p>I hope you find this post useful feel free to leave any comments..</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/how-to-add-a-wordpress-theme-admin-page/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>How To Create A WordPress Copyright Footer Message</title>
		<link>http://www.martin-gardner.co.uk/how-to-create-a-wordpress-copyright-footer-message/</link>
		<comments>http://www.martin-gardner.co.uk/how-to-create-a-wordpress-copyright-footer-message/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 22:14:05 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1097</guid>
		<description><![CDATA[This is a very simple method on how you can generate a Dynamic copyright notice on your wordpress footer which will update each year without manually changing it&#8230; To edit the text in your footer you will have to locate the footer.php file inside your template directory normally located inside: /wp-content/themes/YourThemeNamefolder/ You can use the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a very simple method on how you can generate a Dynamic copyright notice on your wordpress footer which will update each year without manually changing it&#8230;</p>
<p><span id="more-1097"></span></p>
<p>To edit the text in your footer you will have to locate the footer.php file inside your template directory normally located inside:</p>
<blockquote><p>/wp-content/themes/YourThemeNamefolder/</p></blockquote>
<p>You can use the build-in editing feature located in the admin area -</p>
<blockquote><p>Appearance-&gt;Editor-&gt;Select Theme-&gt;footer.php</p></blockquote>
<p><img class="size-full wp-image-1103 alignnone" title="edit-footer" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/edit-footer.jpg" alt="edit-footer" width="327" height="175" /></p>
<p>You will notice the copyright notice in the footer text of this website,</p>
<p>The following code will produce the below.</p>
<pre class="brush: php; title: ; notranslate">
Copyright &amp;copy;
&lt;?php $the_year = date(&quot;Y&quot;); echo $the_year; ?&gt;
&lt;?php bloginfo('url'); ?&gt;
All Rights Reserved.
</pre>
<p>Copyright &copy; 2009 Martin Gardner.co.uk. All Rights Reserved.</p>
<blockquote><p>
OR Include a link back to your site
</p></blockquote>
<pre class="brush: php; title: ; notranslate">
Copyright &amp;copy; &lt;?php $the_year = date(&quot;Y&quot;); echo $the_year; ?&gt;
&lt;a href=&quot;&lt;?php bloginfo('url');?&gt;&quot;&gt;&lt;?php bloginfo('url'); ?&gt;&lt;/a&gt; All Rights Reserved.
</pre>
<p>Copyright &copy; 2009 <a href="http://www.martin-gardner.co.uk/">Martin Gardner.co.uk</a>. All Rights Reserved.</p>
<p>copy the code and paste it into your theme,</p>
<p>like i said &#8220;nice and simple&#8221;&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/how-to-create-a-wordpress-copyright-footer-message/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Counterstrike Server Info Plugin for WordPress</title>
		<link>http://www.martin-gardner.co.uk/counterstrike-server-info-plugin-for-wordpress/</link>
		<comments>http://www.martin-gardner.co.uk/counterstrike-server-info-plugin-for-wordpress/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 00:20:05 +0000</pubDate>
		<dc:creator>Marty</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.martin-gardner.co.uk/?p=1021</guid>
		<description><![CDATA[Counterstrike server info plugin for wordpress was inspired by [rick gold] a relative of mine who enjoys a good Lan party &#38; who is now back on the scene resurrecting his old Clan base -H-omeless. Playing games such as Counterstrike, Battlefield, Call of Duty, Their new website (by me) is running on wordpress, he was [...]]]></description>
			<content:encoded><![CDATA[<p>Counterstrike server info plugin for wordpress was inspired by [<a href="http://www.homelessclan.co.uk/team-members/" target="_blank">rick gold</a>] a relative of mine who enjoys a good Lan party &amp; who is now back on the scene resurrecting his old Clan base <a title="-H-omeless Clan Official Website" href="http://www.homelessclan.co.uk/" target="_blank">-H-omeless</a>.</p>
<p><span id="more-1021"></span><br />
<img class="alignright size-full wp-image-1044" title="wp-cs-server-info-header" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/wp-cs-server-info-header.jpg" alt="wp-cs-server-info-header" width="260" height="200" align="right" />Playing games such as Counterstrike, Battlefield, Call of Duty, Their new website (<em>by me</em>) is running on <a title="Wordpress" href="http://wordpress.org/" target="_blank">wordpress</a>, he was asking me if any such plugins existed that could pull the server information from his CS game server and publish it on his website sidebar, including the current map and current number of players on the server.</p>
<p>So I set about looking into the possibility of building such a plugin, so was born</p>
<blockquote style="width: 200px; margin-left: 30px; text-align: center; font-weight: bold;"><p>`wp-cs-server-info plugin`</p></blockquote>
<p style="text-align: left;">This plugin uses the `CStrike 1.6 Server Query class` by <a title="Markus Schanz - Server Queries Developer wiki" href="http://developer.valvesoftware.com/wiki/Server_Queries Developerwiki" target="_blank">Markus Schanz</a></p>
<h2 style="text-align: left;"><strong>Features</strong></h2>
<blockquote>
<ul>
<li>Widget Control Panel</li>
<li>Enable disable server values</li>
<li>Current Map image</li>
</ul>
</blockquote>
<h2><strong>Installation</strong></h2>
<blockquote><p><strong>Install</strong></p>
<ol>
<li>Unzip the `wp-cs-server-info.zip` file.</li>
<li>Upload the the `wp-cs-server-info` folder to your `wp-contents/plugins` folder.</li>
</ol>
<p><strong>Activate</strong></p>
<ol>
<li>In your <a title="http://wordpress.org/" href="http://wordpress.org/" target="_blank">WordPress</a> Administration, go to the Plugins page</li>
<li>Activate the plugin `WP CS SERVER INFO`.</li>
<li>Navigate to the Widgets page, `-&gt;Appearance-&gt;Widgets` .</li>
<li>Drag the `wp-cs-server-info` module to the sidebar that&#8217;s in use.</li>
<li>Enter the Widget Title, Server IP &amp; Port Number (mandatory).</li>
<li>Select the options to Show on the front end.<br />
default={MapName, ServerIP, Port, Map Image}</li>
<li>Visit your homepage (or were the sidebar will be loaded)and you should see the server info.</li>
</ol>
<p>If you find any bugs or have any ideas, please mail me.</p></blockquote>
<h2>Changelog</h2>
<blockquote><p>1.0: Added Options to widget to show different server values<br />
0.9 beta: Added widget control panel.<br />
0.8 beta: Added more map images.<br />
0.7 beta: Tested up to wp 2.7.<br />
0.6 beta: Added strip_tags, stripslashes to user input.<br />
0.5 beta: Created separate php pages for Functions, Widget, Widget_control.<br />
0.4 beta: Tidy up code on main plugin php file.<br />
0.3 beta: Removed Admin Options page for future releases.<br />
0.2 beta: Fixed Cstrike Class Include with Absolute paths<br />
0.1 beta: Created Admin Options Page for adding servers.</p></blockquote>
<h2>Screen-shots</h2>
<blockquote>
<p style="text-align: left;">Widget Module to be Dragged to appropriate sidebar</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1025" title="screenshot_01" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/screenshot_01.png" alt="screenshot_01" width="540" height="286" /></p>
</blockquote>
<blockquote>
<p style="text-align: left;">Widget Control panel.<br />
display each option using the check boxes.<a href="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/screenshot_02.png"></a></p>
<p style="text-align: center;"><img class="size-full wp-image-1026  aligncenter" title="screenshot_02" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/screenshot_02.png" alt="screenshot_02" width="264" height="505" /></p>
</blockquote>
<blockquote>
<p style="text-align: left;">The Output on the front-end.<br />
*Default options selected.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1027" title="screenshot_03" src="http://www.martin-gardner.co.uk/wp-content/uploads/2009/08/screenshot_03.png" alt="screenshot_03" width="158" height="233" /></p>
</blockquote>
<h2>Frequently Asked Questions</h2>
<blockquote>
<p style="text-align: left;"><strong style="font-size:14px;">Q: </strong><span style="color: #ff0000;">The front end web page doesn&#8217;t load properly after widget was added</span><br />
<strong style="font-size:14px;">A:</strong> <span style="color: #333300;">This could be that your host doesn&#8217;t allow connections from their network of servers to the game server, so all communications to and from the server wont happen, &#8220;Check Back soon for more Updates!&#8221;</span></p>
</blockquote>
<h2>Donate</h2>
<blockquote><p>If you really like it! Feel free to leave a Donation.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="phpMyAdmin" value="-KRo3Zrq8dvxiqBjjjnT2cPkBhc" />
<input name="cmd" type="hidden" value="_s-xclick" />
<input name="hosted_button_id" type="hidden" value="6198222" />
<input alt="PayPal - The safer, easier way to pay online." name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" type="image" />
<img src="https://www.paypal.com/en_GB/i/scr/pixel.gif" border="0" alt="" width="1" height="1" /><br />
</form>
</blockquote>
<h2 style="text-align: left;">Download</h2>
<blockquote><p><a href="http://wordpress.org/extend/plugins/wp-cs-server-info/" target="_blank"><img class="alignright" title="Download version 1.0 Now" src="http://www.martin-gardner.co.uk/wp-content/uploads/2008/11/download_now.gif" alt="" width="226" height="44" align="right" /></a></p>
<p style="text-align: left;">
The plugin is now hosted at the wordpress repository you can click the download link to visit the page and download. if it doesn&#8217;t work chances are its your web-hosts server network blocking connection.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.martin-gardner.co.uk/counterstrike-server-info-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

