<?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>Weblog Tools Collection &#187; HOW-TO</title>
	<atom:link href="http://weblogtoolscollection.com/archives/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://weblogtoolscollection.com</link>
	<description>Weblog Tools Blogging Tools Blog</description>
	<lastBuildDate>Fri, 17 May 2013 22:36:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>WordPress, IIS and Plesk &#8220;Unable to find wp-content&#8221; Woes and Solution</title>
		<link>http://weblogtoolscollection.com/archives/2011/11/23/wordpress-iis-and-plesk-unable-to-find-wp-content-woes-and-solution/</link>
		<comments>http://weblogtoolscollection.com/archives/2011/11/23/wordpress-iis-and-plesk-unable-to-find-wp-content-woes-and-solution/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 23:15:15 +0000</pubDate>
		<dc:creator>Mark Ghosh</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[WordPress Hack]]></category>
		<category><![CDATA[wordpress upgrade]]></category>
		<category><![CDATA[wp-content]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=10743</guid>
		<description><![CDATA[I tried to help a co-worker with a professional blog for a TV channel yesterday and ran into some weird issues. We host the blog on a Windows 2008 server with IIS and Plesk. The WordPress install from within the Plesk worked fine but ours did not. The &#8220;white screen of death&#8221; on the install screen was perplexing (more on that at the bottom of this article), but every time he tried to either upgrade WordPress or install or upgrade a plugin or theme, he would receive warnings or failures stating that WordPress was unable to find the wp-content directory. This warning can take various forms but circle around the fact that WordPress did not find the right directory in the expected place. The obvious and painless solution is to upload the files directly to the server using FTP and then control the blog from within wp-admin. In this case, [...]]]></description>
				<content:encoded><![CDATA[<p>I tried to help a co-worker with a professional blog for a TV channel yesterday and ran into some weird issues. We host the blog on a Windows 2008 server with IIS and Plesk. The WordPress install from within the Plesk worked fine but ours did not. The &#8220;white screen of death&#8221; on the install screen was perplexing (more on that at the bottom of this article), but every time he tried to either upgrade WordPress or install or upgrade a plugin or theme, he would receive warnings or failures stating that WordPress was unable to find the wp-content directory. This warning can take various forms but circle around the fact that WordPress did not find the right directory in the expected place.</p>
<p>The obvious and painless solution is to upload the files directly to the server using FTP and then control the blog from within wp-admin. In this case, though I knew the simple solution, I wanted to get to the root of the problem. It turns out that weird permission issues with IIS and WordPress and in some extreme cases such as mine, can be solved with simple but somewhat hidden features to get the desired results.</p>
<p>A Google search revealed that adding a few lines of code to the end of your wp-config.php can solve most issues. As from <a href="http://www.firdouss.com/2009/10/guide-solving-wordpress-update-issue-unable-to-locate-wordpress-plugin-directory/">Firdouss.com guide</a>, try this solution first. Open up your production wp-config.php, find the end of the file and add the following lines at the end. Then save the file, upload to your server and try the process again.</p>
<blockquote>
<pre>if(is_admin()) {
	add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
	define( 'FS_CHMOD_DIR', 0751 );
}</pre>
</blockquote>
<p>If that does not solve your problem, you can use WordPress constants to solve your problem. It turns out (<a href="http://www.firdouss.com/2009/10/guide-solving-wordpress-update-issue-unable-to-locate-wordpress-plugin-directory/#comment-3374">thanks to a comment on the Firdouss.com guide</a>) that there are a <a href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">host of constants</a> that can be added to wp-config that can fix broken upload and install/upgrade problems among other things. That link to the Codex contains a detailed explanation of the constants and what they should be set to. Please refer to that link since it will continue to be updated. In my case, I had to add the following to the end of my wp-config.php file. I could also have modified the above code to return ftpext instead.</p>
<blockquote>
<pre>define('FS_METHOD', 'ftpext');</pre>
</blockquote>
<p>Now in my case, there were other permission issues that had to be resolved. Our Plesk install had a borked permission system and in order for uploads to be deleted after they are unzipped and copied (WP need to switch to a move), I had to also CHMOD the files. So I ended up with the following code at the end of wp-config.</p>
<blockquote>
<pre>if(is_admin()) {
	add_filter('filesystem_method', create_function('$a', 'return "ftpext";' ));
	define( 'FS_CHMOD_DIR', 0755 );
}</pre>
</blockquote>
<p>Now the uploads/upgrades/installs work fine. YMMV.</p>
<p>As for the weird installation issue, it turns out that when I uploaded the WordPress install files on the server and visited the URI, I got redirected to the following along with a white screen of death with no errors.</p>
<p>http://example.com/index.php/wp-admin/install.php</p>
<p>I needed to change that URI manually to the following for the install to continue. That was all.</p>
<p>http://example.com/wp-admin/install.php</p>
<p>Do you have any other suggestions? Are there any tricks that have helped you get similar issues resolved?</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2011/11/23/wordpress-iis-and-plesk-unable-to-find-wp-content-woes-and-solution/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mini Guide To Choosing A Web Host</title>
		<link>http://weblogtoolscollection.com/archives/2011/01/07/mini-guide-to-choosing-a-web-host/</link>
		<comments>http://weblogtoolscollection.com/archives/2011/01/07/mini-guide-to-choosing-a-web-host/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 20:00:56 +0000</pubDate>
		<dc:creator>Jeff Chandler</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[webhosting]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=9465</guid>
		<description><![CDATA[The one thing that most of us WordPress self installers have in common is that we&#8217;re using a web host of some kind whether it be shared hosting, VPS, or a dedicated server. Web hosting is one of those industries that has a very low entry barrier thanks to reselling. This enables fly by night shops to open up as a web hosting company only to disappear a few months later. This doesn&#8217;t happen in all cases as reselling provides a great opportunity to learn a thing or two but I&#8217;ve since lost my trust in resellers. Choosing a web host is probably the most important decision you make as everything rests on their shoulders for your web site to stay online. Without further adieu, here is a list of questions and things to consider when choosing a web host. Note: This mini guide is mainly geared towards shared hosting. [...]]]></description>
				<content:encoded><![CDATA[<p>The one thing that most of us WordPress self installers have in common is that we&#8217;re using a web host of some kind whether it be shared hosting, VPS, or a dedicated server. Web hosting is one of those industries that has a very low entry barrier thanks to reselling. This enables fly by night shops to open up as a web hosting company only to disappear a few months later. This doesn&#8217;t happen in all cases as reselling provides a great opportunity to learn a thing or two but I&#8217;ve since lost my trust in resellers. Choosing a web host is probably the most important decision you make as everything rests on their shoulders for your web site to stay online. Without further adieu, here is a list of questions and things to consider when choosing a web host. <em>Note:</em> This mini guide is mainly geared towards shared hosting. </p>
<p><strong>Trend spotting: WordPress Centric Hosting</strong> &#8211; Over the past two years, a new form of web hosting has cropped up that tries to bridge the gap between all the safety nets WordPress.com offers with the freedom to do whatever you want via the self installed version of WordPress. Examples of these types of companies include <a href="http://page.ly/">Page.ly</a> and <a href="http://wpengine.com/">WPEngine</a>. I&#8217;ve noticed more and more of these types of companies starting to open shop while at the same time, long time players in the web hosting industry are starting to create WordPress centric packages. One thing you need to keep in mind is that a WordPress centric host does not make them better than all of the other options. </p>
<p><strong>How Up To Date Are Their Servers?</strong> &#8211; During the early part of 2010, there were a number of instances where large, well-known web hosting companies became victims to exploits and attacks thanks to outdated software in use on their servers. Before becoming a customer, ask the web host in question what versions they are using for php, MySQL, phpMyAdmin, etc. A good web host will generally always be using the most recent stable version of software. </p>
<p><strong>Reputation Check</strong> &#8211; Type into Google the name of the web host you&#8217;re interested in followed by the word <em>sucks</em>. You should quickly noticed that every web host sucks. What you should really be paying attention to is not only the severity and amount of problems that users report, but how the company responded to those problems. Every web host is going to encounter its share of problems but it&#8217;s how they handle those problems that makes a big difference. An excellent resource for all things web hosting that has been in existence for years is <a href="http://www.webhostingtalk.com/">WebHostingTalk.com</a>. If you&#8217;re interested in hardware, software, all things related to what it takes to make a web hosting company run, that forum will make your mind explode with detailed discussions. </p>
<p><strong>Human Recommendation –</strong> If you start a thread on the WordPress Support forum asking for advice on which web hosting company to go with, chances are you’ll get 3-5 different company names as recommendations. If one of these companies interest you, be sure to ask around to get personal experiences from folks, especially as they relate to customer service and up time. However, similar to the Google Research conundrum, it could turn out that all of your friends have had success with a particular company and you turn out to be the bad apple with a bad experience. </p>
<p><strong>Check And Double Check Policies</strong> &#8211; It&#8217;s imperative that you read the Terms Of Service and Acceptable Use Policies for the host you&#8217;re interested in using. While many hosting companies advertise unlimited everything, you&#8217;ll find out by looking in the small print within their AUP that if your site goes overboard with CPU, space, or bandwidth resources, you&#8217;ll be cut off. Unlimited is a great marketing technique but there are always limitations so take the term unlimited with a grain of salt. </p>
<p><strong>DoS And DDoS Attacks</strong> &#8211; I found this out the hard way early in 2010 when my own web site, <a href="http://www.wptavern.com/wptavern-was-trackbacked-to-death">WPTavern.com was hit</a> with a denial of service attack. When I contacted support for AnHosting, they basically told me that I must figured out a way to stop the attacks because after the site gets suspended three times in a row for using too many resources, they would remove my site along with my account. Needless to say, this infuriated me as I&#8217;ve been a loyal customer for over two years and they failed to work with me to find a cause along with a resolution. DoS attacks are a common thing these days so please make sure that whatever web host you&#8217;re interested in using has a firewall or some type of preventive measures in place to help out instead of abandoning the customer as my previous host did. </p>
<p><strong>Support</strong> &#8211; Probably one of the most important aspects of choosing a web host is their support system. Look for companies that offer a variety of support solutions such as forums, ticket system, email, and a phone number. I’d choose a web host that has 24/7 support versus week days only. Extra points to those web hosting companies that don’t outsource their support to countries/companies that don’t speak English very well. </p>
<p><strong>Redundancy</strong> &#8211; If the companies website and services go down, do they have a fail-over system in place? Is your data mirrored to that fail-over system? Does it have the same security precautions as their first system? This is not overly important as their are a number of options available specifically for WordPress users to create redundancy of their data. </p>
<p><strong>Communication</strong> – This is one area in which I see web hosting companies screwing up the most. You’d figure that by now, they would understand that communication with their customers is paramount but most of them still don’t get it. Ask the web host you’re interested in whether or not you’ll be contacted if maintenance is required on the box your site resides on. Also ask where all such service interruptions and other announcements will be published. Nothing like publishing a post in WordPress only to hit the button and see a site not found error. </p>
<p><strong>Payment Options</strong> – Make sure you understand any money back guarantee that is offered. I recommend staying away from purchasing web hosting for more than one year at a time unless the money back guarantee specifically states that refunds can be pro-rated. Preferably at 1, 3, or 6 month periods at the most. This way, you’re not locked into a specific host. You’ll regret it when you’re halfway through your contract and the web host experiences severe technical difficulties that last a week or more but you can’t move to a new web host because you’ll lose money from not fulfilling the other half of the contract. It may seem like you’ll save tons of money by purchasing 3-5 years worth of hosting, but realize this is a very high risk you’d be taking. </p>
<p><strong>SSH And SFTP –</strong> SSH stands for Secure Shell. It’s a Unix-based command interface and protocol for securely getting access to a remote computer. It is widely used by network administrators to control Web and other kinds of servers remotely. SSH is actually a suite of three utilities – slogin, ssh, and scp – that are secure versions of the earlier UNIX utilities, rlogin, rsh, and rcp. SSH commands are encrypted and secure in several ways. Both ends of the client/server connection are authenticated using a digital certificate, and passwords are protected by being encrypted.</p>
<p><a href="http://kb.iu.edu/data/akqg.html">SFTP on the other hand</a> is the secure version of the FTP protocol. SFTP, or secure FTP, is a program that uses SSH to transfer files. Unlike standard FTP, it encrypts both commands and data, preventing passwords and sensitive information from being transmitted in the clear over the network. It is functionally similar to FTP, but because it uses a different protocol, you can’t use a standard FTP client to talk to an SFTP server, nor can you connect to an FTP server with a client that supports only SFTP.</p>
<p><strong>Sandboxing</strong> &#8211; Probably the most important question you can ask to a shared hosting company is how they secure/sandbox the user account space. By default *nix systems don’t protect user home directories. Also, how do they secure/sandbox the php processes. By default, php has to run with apache privileges and any code that runs on the server, regardless of user, runs in the same security context. Sandboxing the PHP code to a specific user account is important on a shared host so that user1 can’t write some code that hijacks user2?s site.</p>
<h2>Conclusion:</h2>
<p>While this isn’t the all encompassing guide to choosing a great web host to put your WordPress powered web site on, it does provide food for thought. This is just a short list of things to consider but in reality, having a great experience with a webhosting company is almost like winning the lottery because it’s so rare. In my experience with WPTavern.com, I experienced 2 great years with my previous host and then it turned into a nightmare in just a matter of two weeks forcing me to move. In fact, I moved twice in one week due to the problems I was having with migrating my site. Ultimately, it comes down to gathering as much information as possible in order to make an informed decision as to whether a particular webhost is right for you. Price should not be the only determining factor for hosting your site, especially if you plan on taking things seriously. </p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2011/01/07/mini-guide-to-choosing-a-web-host/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Deleting WordPress Revisions</title>
		<link>http://weblogtoolscollection.com/archives/2010/09/28/deleting-wordpress-revisions/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/09/28/deleting-wordpress-revisions/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 13:00:50 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[WordPress Tips]]></category>
		<category><![CDATA[revisions]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8734</guid>
		<description><![CDATA[WordPress 2.6 introduced a post revisions feature, which automatically saves a draft as you begin to write a post or page and saves a revision for each change made afterwards. That&#8217;s right, every time you make even the slightest alteration to a post or page, a new revision is saved. Now don&#8217;t get me wrong, this is an incredibly useful feature, especially if you accidentally cut half of your post during a late night edit or lose power while composing your latest masterpiece, but these revisions can slowly build up in your database. If it&#8217;s been a few days since you&#8217;ve last edited your blog, chances are that you don&#8217;t need to keep any revisions around, and they&#8217;re probably just siting in your database taking up space and growing cobwebs. To remove all of your revisions safely without harming your published posts and pages, backup your database, then use either [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://wordpress.org/">WordPress</a> 2.6 introduced a post revisions feature, which automatically saves a draft as you begin to write a post or page and saves a revision for each change made afterwards.  That&#8217;s right, every time you make even the slightest alteration to a post or page, a new revision is saved.  Now don&#8217;t get me wrong, this is an incredibly useful feature, especially if you accidentally cut half of your post during a late night edit or lose power while composing your latest masterpiece, but these revisions can slowly build up in your database.</p>
<p>If it&#8217;s been a few days since you&#8217;ve last edited your blog, chances are that you don&#8217;t need to keep any revisions around, and they&#8217;re probably just siting in your database taking up space and growing cobwebs.  To remove all of your revisions safely without harming your published posts and pages, <a href="http://weblogtoolscollection.com/archives/2010/09/20/backing-up-wordpress/">backup your database</a>, then use either <a href="http://wordpress.org/extend/plugins/delete-revision/">Delete-Revision</a> or <a href="http://wordpress.org/extend/plugins/better-delete-revision/">Better Delete Revision</a>.  If you&#8217;re handy with SQL queries, use either phpMyAdmin or the MySQL command line to run the following query (change the table prefix as necessary):</p>
<p><code>DELETE FROM wp_posts WHERE post_type = "revision"</code></p>
<p><strong>Update:</strong> Thanks to <a href="http://planetozh.com/">Ozh</a> for pointing out that the above query &#8220;just deletes post marked as revisions. If for some reason you associated a revision with a tag or a category that was then removed when the final post was published, you will have extra entries in other tables such as terms.&#8221; The proper query to safely remove all of your revisions is as follows (change the table prefix as necessary):</p>
<p><code>DELETE a,b,c<br />
FROM wp_posts a<br />
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)<br />
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)<br />
WHERE a.post_type = 'revision'</code></p>
<p>If you want to disable the revision system, add the following line to your wp-config.php file:</p>
<p><code>define('WP_POST_REVISIONS', false );</code></p>
<p>If you want to specify the number of revisions that WordPress can save, add the following line to your wp-config.php file (change the number to your desired maximum revision count):</p>
<p><code>define('WP_POST_REVISIONS', 3);</code></p>
<p>As the revision system is a form of backup, I recommend periodically deleting revisions as opposed to disabling or limiting it.</p>
<p>I ran the above query on my blog for the first time last night and reduced the database size by almost half! How much did you save?</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/09/28/deleting-wordpress-revisions/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Using a Native WordPress Gallery</title>
		<link>http://weblogtoolscollection.com/archives/2010/09/24/using-a-native-wordpress-gallery/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/09/24/using-a-native-wordpress-gallery/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 13:00:43 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[WordPress Tips]]></category>
		<category><![CDATA[galleries]]></category>
		<category><![CDATA[gallery]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8693</guid>
		<description><![CDATA[There are many gallery plugins out there for WordPress, but did you know that WordPress has had its own gallery system since the release of version 2.5 over two years ago? To get started with a native WordPress gallery, you&#8217;ll need to create or edit the post or page that you want the gallery to appear in and then click the &#8220;Add an Image&#8221; button. You can use this to upload all of your images at full size and WordPress will automatically generate the various sizes (including thumbnails) for you. Now, it&#8217;s important to note that once you add an image via this method while writing or editing a post or page, it will be assigned to that specific post or page, which is how WordPress keeps track of the gallery&#8217;s content. Once you have uploaded all the desired images, click the &#8220;Add an Image&#8221; button again, select the &#8220;Gallery&#8221; tab, [...]]]></description>
				<content:encoded><![CDATA[<p>There are many gallery plugins out there for <a href="http://wordpress.org/">WordPress</a>, but did you know that WordPress has had its own gallery system since the release of version 2.5 over two years ago?</p>
<p>To get started with a native WordPress gallery, you&#8217;ll need to create or edit the post or page that you want the gallery to appear in and then click the &#8220;Add an Image&#8221; button.</p>
<p><img class="alignnone size-full wp-image-8694" title="Add an Image" src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/addanimage.jpg?resize=319%2C127" alt="add an image" data-recalc-dims="1" /></p>
<p>You can use this to upload all of your images at full size and WordPress will automatically generate the various sizes (including thumbnails) for you. Now, it&#8217;s important to note that once you add an image via this method while writing or editing a post or page, it will be assigned to that specific post or page, which is how WordPress keeps track of the gallery&#8217;s content. Once you have uploaded all the desired images, click the &#8220;Add an Image&#8221; button again, select the &#8220;Gallery&#8221; tab, choose your desired settings, and click the &#8220;Insert Gallery&#8221; button at the bottom to add the gallery to your post or page.</p>
<p><img class="alignnone size-full wp-image-8702" title="Gallery Settings" src="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/gallerysettings.jpg?resize=620%2C486" alt="gallery settings" data-recalc-dims="1" /></p>
<p>If you like getting your hands dirty, there are few more settings that you can tweak by altering the <a href="http://codex.wordpress.org/Gallery_Shortcode">gallery shortcode</a> in the HTML editor tab.</p>
<p>Once you have your gallery setup, there are plenty of good plugins to further enhance it, like <a href="http://www.viper007bond.com/wordpress-plugins/jquery-lightbox-for-native-galleries/">jQuery Lightbox For Native Galleries</a>.</p>
<p>What do you use to manage galleries on your blog?  If you use native WordPress galleries, what do you do to enhance them beyond their basic implementation?</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/09/24/using-a-native-wordpress-gallery/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Backing Up WordPress</title>
		<link>http://weblogtoolscollection.com/archives/2010/09/20/backing-up-wordpress/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/09/20/backing-up-wordpress/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 13:00:38 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[WordPress Tips]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8666</guid>
		<description><![CDATA[You can&#8217;t be too careful these days. You&#8217;ve put a lot of work into your blog, and it would be a shame to see it lost forever just because you accidentally deleted something you shouldn&#8217;t have, it was hacked, or your server had a catastrophic meltdown. There are many ways to backup WordPress, so I&#8217;m just going to cover some of the easiest and most complete methods. First of all, your files are easy to backup. Since WordPress can be downloaded at any time, you only need to worry about files that you&#8217;ve customized or uploaded, which should leave only your wp-config.php file and everything under the /wp-content/ directory. You can easily backup these files by accessing your server via FTP or SFTP and downloading them. Now for the database, which includes all of your content and settings. Just like almost everything in life, there&#8217;s the easy way and the [...]]]></description>
				<content:encoded><![CDATA[<p>You can&#8217;t be too careful these days.  You&#8217;ve put a lot of work into your blog, and it would be a shame to see it lost forever just because you accidentally deleted something you shouldn&#8217;t have, it was hacked, or your server had a catastrophic meltdown.</p>
<p>There are many ways to backup <a href="http://wordpress.org/">WordPress</a>, so I&#8217;m just going to cover some of the easiest and most complete methods.</p>
<p>First of all, your files are easy to backup.  Since WordPress can be <a href="http://wordpress.org/download/">downloaded</a> at any time, you only need to worry about files that you&#8217;ve customized or uploaded, which should leave only your wp-config.php file and everything under the /wp-content/ directory.  You can easily backup these files by accessing your server via <a href="http://codex.wordpress.org/FTP_Clients">FTP or SFTP</a> and downloading them.</p>
<p>Now for the database, which includes all of your content and settings. Just like almost everything in life, there&#8217;s the easy way and the hard way.</p>
<p>The easy way: Use a plugin, like <a href="http://wordpress.org/extend/plugins/wp-db-backup/">WP-DB-Backup</a> or <a href="http://wordpress.org/extend/plugins/backwpup/">BackWPup</a>.  These plugins represent the easiest and most customizable backup options, but they are subject to compatibility with your current version of WordPress and may be blocked by your hosting provider&#8217;s security filters.</p>
<p>The hard way: <a href="http://codex.wordpress.org/Backing_Up_Your_Database#Using_phpMyAdmin">Use phpMyAdmin</a>, which most hosting providers offer in their control panel.  Yes, this method is a bit more involved than simply installing a plugin and clicking a magic backup button, but you&#8217;ll be able to backup and <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">restore</a> your database on almost any hosting provider without the need to access your blog.  This method is particularly handy if you&#8217;re moving your blog to a new hosting provider.</p>
<p>Many hosting provider control panels feature their own backup systems, which can vary from provider to provider.  For example, cPanel often features a &#8220;full backup&#8221; option which provides all of your files, databases, and emails in a handy gzip archive.  While an ideal method to quickly backup everything, this archive may only be restored by a server administrator on a cPanel system. The previously listed methods will ensure the highest compatibility with most hosting providers.</p>
<p><a href="http://vaultpress.com/">VaultPress</a>, by <a href="http://automattic.com/">Automattic</a>, is a newcomer to the backup scene.  It is a paid service, but it provides a hassle-free way to automatically and remotely backup your blog whenever a change is made.  If your blog is very important to you, I highly recommend that you try VaultPress now while they&#8217;re still offering lower beta rates.  I&#8217;ve used VaultPress for about two weeks now, so you can certainly expect a review here after I&#8217;ve had a month to fully test the service.</p>
<p>Personally, I used SFTP and phpMyAdmin to backup my blog in the past, but now I use VaultPress.  How do you backup your blog?</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/09/20/backing-up-wordpress/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Boost Site Engagement and Return Visits with Evernote Site Memory</title>
		<link>http://weblogtoolscollection.com/archives/2010/09/19/boost-site-engagement-and-return-visits-with-evernote-site-memory/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/09/19/boost-site-engagement-and-return-visits-with-evernote-site-memory/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 22:45:25 +0000</pubDate>
		<dc:creator>Gilberto Perera</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8633</guid>
		<description><![CDATA[Would you like to provide 4 million users with an easy way to save information about your website? Chances are that you have heard of Evernote, the on-the-cloud note-taking application available on multiple platforms. One of the newest features announced by the Evernote team is Evernote Site Memory. Here is what Site Memory does for your website: Allows visitors to save posts from your site – When you add the Site Memory button to your site, visitors can automatically save posts, pages, and content defined by you to their Evernote your visitors can save posts and pages to Evernote as clips. You have total control of what Evernote saves, the save location of the clip, and how the clips are tagged. Easy Access to Favorites – When visitors return to your website and click on the Site Memory button they are presented with everything that they have ever clipped from [...]]]></description>
				<content:encoded><![CDATA[<p>Would you like to provide 4 million users with an easy way to save information about your website? Chances are that you have heard of Evernote, the on-the-cloud note-taking application available on multiple platforms. One of the newest features <a title="Site Memory Button Announced" href="http://blog.evernote.com/2010/09/09/evernote-site-memory-button/" target="_self">announced </a>by the Evernote team is Evernote Site Memory. Here is what Site Memory does for your website:</p>
<p><strong>Allows visitors to save posts from your site –</strong> When you add the Site Memory button to your site, visitors can automatically save posts, pages, and content defined by you to their Evernote your visitors can save posts and pages to Evernote as clips. You have total control of what Evernote saves, the save location of the clip, and how the clips are tagged.</p>
<p><strong>Easy Access to Favorites – </strong>When visitors return to your website and click on the Site Memory button they are presented with everything that they have ever clipped from your website.</p>
<p>The two items above translate to a better experience for your users as well as repeat visits from users who reference your website on their Evernote notebooks. The two items below translate increased engagement into cash.</p>
<p><strong>Make Some Moolah &#8211; </strong>Evernote employs a freemium model that provides the software and service free, if users wish to access additional features they have the option to upgrade to the premium version. This is where you make the money. For every referred user that upgrades to the premium account you will receive the first $10 Evernote collects.</p>
<p><strong>Free Advertising</strong> – The Evernote team promotes the most popular sites via social media every couple of weeks.</p>
<p>Does this sound like something you would like to implement on your sites? If so follow the instructions below to help you set up Evernote Site Memory on your website.</p>
<h3>How to Setup Evernote Site Memory</h3>
<p>The first thing you need to do is visit the <a href="http://www.evernote.com/about/developer/sitememory/index.php#a_builder">Evernote Site Memory</a> page. You might also want to sign up for the <a title="Evernote Affiliate Program" href="http://www.evernote.com/about/affiliate/" target="_self">affiliate </a>program so that you have the code handy when we get to that step.</p>
<p><a href="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory.png" rel="thumbnail"><img class="alignnone size-full wp-image-8636" title="evernote-site-memory" src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory.png?resize=423%2C197" alt="" data-recalc-dims="1" /></a></p>
<p><strong>1. </strong>Choose the button design you wish to use.</p>
<p><a href="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-a.png" rel="thumbnail"><img class="alignnone size-full wp-image-8637" title="evernote-site-memory-a" src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-a.png?resize=422%2C180" alt="" data-recalc-dims="1" /></a></p>
<p><strong>2.</strong> This is the part where you get to customize what is clipped by Site Memory. The best thing you can do is use the Inspect Element feature in Chrome or <a title="Firebug Add-on for Firefox" href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;ved=0CBYQFjAA&amp;url=http%3A%2F%2Fwww.getfirebug.com%2F&amp;ei=pHiTTKmyBYG8lQfDod2nCg&amp;usg=AFQjCNFBkks4lrZpbnqiN8-uAnYIvmcCJw" target="_self">Firebug </a>in Firefox to find which element contains the actual content you wish to include. There&#8217;s no need to include your website&#8217;s masthead, sidebar, and other irrelevant elements.</p>
<p><a href="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-a1.png" rel="thumbnail"><img class="alignnone size-full wp-image-8639" title="evernote-site-memory-a1" src="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-a1.png?resize=407%2C297" alt="" data-recalc-dims="1" /></a></p>
<p><em>Example of Inspect Element feature in Chrome to determine the Div that contains the content which should be clipped.</em></p>
<p>When choosing the div for the content to clip keep in mind that you probably don&#8217;t want to include the comments section and any other elements that may make up the end of each post.</p>
<p><a href="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-b.png" rel="thumbnail"><img class="alignnone size-full wp-image-8642" title="evernote-site-memory-b" src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-b.png?resize=422%2C206" alt="" data-recalc-dims="1" /></a></p>
<p><strong>4.</strong> The next step allows you set your website&#8217;s name that will be displayed in the Site Memory window after a visitor clicks on the button.</p>
<p>You can also include a name for the Notebook in Evernote that will be used to store clips from your website. Take this opportunity to think about a keyword or term that you would like your website to be associated with.</p>
<p>If you signed up for the <a title="Evernote Affiliate Program" href="http://www.evernote.com/about/affiliate" target="_self">affiliate </a>program, enter the referral code in the referral code text box.</p>
<p><a href="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-c1.png" rel="thumbnail"><img class="alignnone size-full wp-image-8644" title="evernote-site-memory-c" src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-c1.png?resize=426%2C269" alt="" data-recalc-dims="1" /></a></p>
<p><strong>A.</strong> If you are happy with the preview you are good to go.</p>
<p><strong>5. </strong>Select the code provided and right-click to open the menu.</p>
<p><strong>6.</strong> Click <strong>Copy </strong>to save the code to the clipboard.</p>
<p>Now comes the most difficult part of all, adding the code to your site. For some this may be as easy as pasting the code in a specific spot, but for some it will require tweaking CSS/HTML so for the sake of brevity we&#8217;ll stick to the basics.</p>
<p><strong>Warning &#8211; </strong>Before proceeding, please backup your template files.</p>
<p><strong>1.</strong> Open your theme&#8217;s <em>single.php</em> template file.</p>
<p><strong>Note:</strong> I would probably stick to using the Site Memory button on single posts only. No need to add it to archive or index templates, unless the archive and index views on your website include the entire article and not an excerpt.</p>
<p><a href="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-d.png" rel="thumbnail"><img class="alignnone size-full wp-image-8646" title="evernote-site-memory-d" src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-d.png?resize=428%2C177" alt="" data-recalc-dims="1" /></a></p>
<p><strong>2.</strong> Find the best location (usually below the title or at the end of the post) for the <strong>Site Memory</strong> button, paste it into the template and save the changes.</p>
<p><a href="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-e.png" rel="thumbnail"><img class="alignnone size-full wp-image-8647" title="evernote-site-memory-e" src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-e.png?resize=406%2C191" alt="" data-recalc-dims="1" /></a></p>
<p>To confirm that the button is working open one of your posts and try clipping the article to your Evernote notebook.</p>
<p><a href="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-f.png" rel="thumbnail"><img class="alignnone size-full wp-image-8648" title="evernote-site-memory-f" src="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-f.png?resize=413%2C435" alt="" data-recalc-dims="1" /></a></p>
<p>Notice how the information you entered in the Button Creator appears in the Clip to Evernote window. <strong>Clip from Your Site</strong> and the <strong>Notebook</strong> that is created. Again, when deciding what to use for these items consider sticking to keywords that help brand your site.</p>
<p><a href="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-f-2.png" rel="thumbnail"><img class="alignnone size-full wp-image-8650" title="evernote-site-memory-f-2" src="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-f-2.png?resize=413%2C435" alt="" data-recalc-dims="1" /></a></p>
<p>When the clip is saved to Evernote make sure to click on the View in Evernote link so that you can see what was included in the clip.</p>
<p><a href="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-g.png" rel="thumbnail"><img class="alignnone size-full wp-image-8651" title="evernote-site-memory-g" src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/09/evernote-site-memory-g.png?resize=399%2C376" alt="" data-recalc-dims="1" /></a></p>
<p>As you can see from the example above it&#8217;s worth taking the time to see how your clip turns out when the Clip button is used. I thought that by specifying a specific DIV I would segregate the content and only include information from the post, but the opposite happened. It looks like the entire site was included in the clip so it will take some tweaking and knowledge about your theme&#8217;s HTML and CSS to get the right DIV to ensure only information pertaining to the article is included.</p>
<p>Once you&#8217;ve got it down for the single posts then you have the option to use the Site Memory button on pages as well.</p>
<p>If you&#8217;re looking to customize the Site Memory button beyond the options available above you can visit the Developer page to get the inside scoop in all of the features available and how to implement them. If you don&#8217;t want to mess with your website&#8217;s template and are looking for a WordPress plugin to simplify the process, Evernote states that they are working on something to simplify the process.</p>
<p>Are you concerned about Site Memory slowing down your website? Don&#8217;t be, the buttons are static and the developer&#8217;s page even offers a <a title="Minified Evernote Javascript Library" href="http://static.evernote.com/noteit.min.js" target="_blank">minified</a> JavaScript library that can be used instead.</p>
<p>Do you think you&#8217;ll use Evernote Site Memory on your WordPress blogs? Why? Why Not?</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/09/19/boost-site-engagement-and-return-visits-with-evernote-site-memory/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Should You Remove Post Dates from Your WordPress Blog?</title>
		<link>http://weblogtoolscollection.com/archives/2010/08/27/should-you-remove-post-dates-from-your-wordpress-blog/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/08/27/should-you-remove-post-dates-from-your-wordpress-blog/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 23:24:12 +0000</pubDate>
		<dc:creator>Gilberto Perera</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress Hack]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8477</guid>
		<description><![CDATA[You may be wondering why anyone would want to do this. Think about it, you probably have hundreds of articles that you wrote years ago and when those same articles appear on Google search engine results, the dates appear next to the description.  You might think that this is great, users searching the web should be able to see when an article originally published, but research shows that users discriminate against older content just because it is old. An article that may be valuable despite its age would be subject to a user completely ignoring it and would click on the newer article, just because it was newer. As you can see in the image above, the search results page lists the post date for the article followed by the description. Do not confuse the intent here, if you are running a news site or writing about topics whose value [...]]]></description>
				<content:encoded><![CDATA[<p>You may be wondering why anyone would want to do this. Think about it, you probably have hundreds of articles that you wrote years ago and when those same articles appear on Google search engine results, the dates appear next to the description.  You might think that this is great, users searching the web should be able to see when an article originally published, but research shows that users <a title="Move Post Date to Bottom of Post - Tim Ferriss" href="http://www.fourhourworkweek.com/blog/2009/06/29/how-to-build-a-high-traffic-blog-without-killing-yourself/" target="_self">discriminate </a>against older content just because it is old. An article that may be valuable despite its age would be subject to a user completely ignoring it and would click on the newer article, just because it was newer.</p>
<p><a href="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/08/post-date-wordpress.png" rel="thumbnail"><img class="alignnone size-full wp-image-8478" title="post-date-wordpress" src="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/08/post-date-wordpress.png?resize=538%2C244" alt="" data-recalc-dims="1" /></a></p>
<p>As you can see in the image above, the search results page lists the post date for the article followed by the description.</p>
<p>Do not confuse the intent here, if you are running a news site or writing about topics whose value is short lived then the adequate thing to do is to continue using dates. However if your traffic from search engines is suffering from users who refuse to visit an old article (and your topics are timeless) then you might want to consider removing the post date from your articles.</p>
<h3>So how would you go about removing dates in WordPress?</h3>
<p>Google is smart about locating dates on posts so you have to be aware of all the dates present on your WordPress site. Based on discussions on the web it appears that Google uses the post date when listed on a page and when the post date is missing, Google uses dates in comments and even within the post itself. So removing dates will take some cunning.</p>
<p>In order to remove the post date from the posts on your WordPress site you will have to remove the post date from your theme’s template file. In terms of indexing the post date, it appears that Google uses the post date from the single post and not the archive, so for the sake of users and simplicity we are only going to remove the post date from the “single.php” template file.</p>
<p><strong>WARNING! </strong>Before proceeding with the modification of any template files, please make sure that you back up your files.</p>
<p><strong>Remove date from single posts</strong></p>
<p><strong>1.</strong> Open the single.php file located in the theme directory in WordPress (usually server//wordpress/wp-content/themes/your theme name).</p>
<p><strong>2.</strong> Locate the following line of code and remove it (or comment it out) from the template;</p>
<p><strong>&lt;?php the_time(); ?&gt;</strong></p>
<p><strong> </strong></p>
<p>Note: The code used by the theme developer may vary from theme to theme and location so make sure you look for the <strong>&lt;?php the_time</strong> within the <em>single.php</em> template to be sure.</p>
<p><strong>3. </strong>Save the changes and refresh your website to see the modification. If the changes don&#8217;t appear right away make sure to clear the cache if you are using a plugin like WP-Supercache.</p>
<p><strong>Remove date from comments</strong></p>
<p>In order to make sure that Google cannot find a date on your blog post we will also need to remove the dates associated with comments. This can be a bit frustrating for users who want to follow a comment thread so it is entirely up to you.</p>
<p><strong>1.</strong> Open the comments.php file located in the theme directory in WordPress (usually server//wordpress/wp-content/themes/your theme name).</p>
<p><strong>2.</strong> Locate the following line of code and remove it (or comment it out) from the template;</p>
<p><strong>&lt;?php comment_date() ?&gt;</strong></p>
<p>Note: The code used by the theme developer may vary from theme to theme and location so make sure you look for the <strong>&lt;?php the_time</strong> within the<em> comments</em><em>.php</em> template to be sure.</p>
<p><strong>3. </strong>Save the changes and refresh your website to see the modification. If the changes don&#8217;t appear right away make sure to clear the cache if you are using a plugin like WP-Supercache.</p>
<p>When removing these PHP functions make sure that you take into account the formatting of your posts and comments to ensure that the removal of this element doesn&#8217;t interfere with your theme&#8217;s design or break the code.</p>
<p>After these changes are made you will need to wait a couple of hours or days in order for Google&#8217;s index to reflect those changes. The variance in time is due to your site&#8217;s crawl rate so if your site is very popular and is crawled frequently you may see the update in hours. If your site still appears in the search results with the date, make sure you visit the page and search for the date, remember even dates within the content (originally published on [date]) will be used by Google to stamp a date on the site.</p>
<p><strong>Other solutions for the removal of comments and post dates</strong></p>
<p>If you use a commenting system like <a title="Disqus Home Page" href="http://www.disqus.com" target="_self">Disqus </a>or <a title="IntenseDebate Homepage" href="http://www.intensedebate,com" target="_self">IntenseDebate </a>that is based on JavaScript then there is no concern for the removal of the date from the comments template. If you are using an older version of WordPress or you feel a bit adventurous you could download the <a title="Date Exclusion SEO Plugin" href="http://wordpress.org/extend/plugins/date-exclusion-seo-plugin/" target="_self">Date Exclusion SEO</a> Plugin from the WordPress plugin directory, just keep in mind that the plugin hasn&#8217;t been updated in over 500 days and it&#8217;s officially compatible up to 2.71.</p>
<h3>Will You Remove Dates from Your Posts?</h3>
<p>I&#8217;ve mentioned some of the Pro&#8217;s related to removal of post and comment dates on your blog:</p>
<ul>
<li>Users searching for content on search engines are more likely to click on your link compared to others with older dates.</li>
<li>Visitors arriving from search engines will not discriminate the age of the content and will instead focus on the content itself, which should increase readership, time on site, etc.</li>
</ul>
<p>Of course, as with anything as radical as this there can be some repercussions:</p>
<ul>
<li>If you employ this &#8220;hack&#8221; and you run a news site, visitors will arrive, but will quickly realize that the content is dated and leave the site.</li>
<li>Some users like to know when an article was published and may get frustrated if there is no publish date.</li>
<li>If you decide to stay away from Disqus or IntenseDebate to manange your comments and remove the dates from the comments, users may be confused and frustrated because they can&#8217;t follow a comment thread or identify when it a particular comment was posted. In which case they respond by leaving the site or by leaving a nice comment.</li>
</ul>
<p>If the content on your blog is timeless and you could increase the amount of traffic coming to your blog from search engines, would you remove the post and comment dates?</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/08/27/should-you-remove-post-dates-from-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>WordPress and the new Twitter Button</title>
		<link>http://weblogtoolscollection.com/archives/2010/08/15/wordpress-and-the-new-twitter-button/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/08/15/wordpress-and-the-new-twitter-button/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 13:00:41 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[WordPress Tips]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress.com]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8393</guid>
		<description><![CDATA[I&#8217;m sure you&#8217;ve all heard about the new Twitter button, which finally provides an official way to share links to Twitter and display the number times each link has been shared, but how do you go about adding it to WordPress? If you love messing with your theme, you can use the official Twitter button generator to generate just a few lines of HTML code that can be inserted into your theme templates, but why not use a plugin to simplify the whole process? I highly recommend Simple Twitter Connect. This plugin, or rather series of plugins, will provide a simple yet customizable way to automatically add the new Twitter button to your posts and pages. You&#8217;ll also enjoy a wealth of additional features, including the ability to automatically tweet your posts while publishing, display a list of followers, use your Twitter credentials to login to the admin panel, and [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m sure you&#8217;ve all heard about <a href="http://blog.twitter.com/2010/08/pushing-our-tweet-button.html">the new Twitter button</a>, which finally provides an official way to share links to <a href="http://twitter.com">Twitter</a> and display the number times each link has been shared, but how do you go about adding it to <a href="http://wordpress.org">WordPress</a>?</p>
<p>If you love messing with your theme, you can use <a href="http://twitter.com/goodies/tweetbutton">the official Twitter button generator</a> to generate just a few lines of HTML code that can be inserted into your theme templates, but why not use a plugin to simplify the whole process?  I highly recommend <a href="http://wordpress.org/extend/plugins/simple-twitter-connect/">Simple Twitter Connect</a>.  This plugin, or rather series of plugins, will provide a simple yet customizable way to automatically add the new Twitter button to your posts and pages.  You&#8217;ll also enjoy a wealth of additional features, including the ability to automatically tweet your posts while publishing, display a list of followers, use your Twitter credentials to login to the admin panel, and allow readers to post comments with their Twitter credentials.</p>
<p>Perhaps Simple Twitter Connect is a little bit more than what you need.  In that case, try <a href="http://wordpress.org/extend/plugins/wp-tweet-button/">WP Tweet Button</a> for a simple Twitter button only experience.</p>
<p>If you&#8217;re a <a href="http://wordpress.com/">WordPress.com</a> user, simply visit the Appearance/Extras section of your admin panel and select &#8220;Show a Twitter &#8216;Tweet Button&#8217; on my posts.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/08/15/wordpress-and-the-new-twitter-button/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WordPress 3.0 Walkthrough: Getting Started with Multisite</title>
		<link>http://weblogtoolscollection.com/archives/2010/06/02/wordpress-3-multisite/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/06/02/wordpress-3-multisite/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 04:30:20 +0000</pubDate>
		<dc:creator>Klint Finley</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[multisite]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress 3.0]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8138</guid>
		<description><![CDATA[WordPress 3.0 Walkthrough: Multsite Multisite is the most talked about new feature in WordPress 3.0 &#8211; the WordPress team has folded the functionality of WordPress Multiuser into the main WordPress project. So how do you use it? This tutorial assumes your are comfortable using FTP clients such as Filezilla and doing basic edits of WordPress files. 1. Download WordPress 3.0 release candidate. You can find it here. 2. Edit wp-config in your favorite text editor and add the following line: define(&#8216;WP_ALLOW_MULTISITE&#8217;, true); (I&#8217;d suggest adding it just above the line &#8220;// ** MySQL settings &#8211; You can get this info from your web host ** //&#8221;) 3. Install WordPress normally NOTE: If you&#8217;ve already installed WordPress 3.0, just edit wp-config and add that line of code, there&#8217;s no need to re-install. 4. Under Tools on the sidebar, you&#8217;ll now have an &#8220;Network&#8221; option. Click it. 5. Here you&#8217;ll setup your [...]]]></description>
				<content:encoded><![CDATA[<p>WordPress 3.0 Walkthrough: Multsite</p>
<p>Multisite is the most talked about new feature in WordPress 3.0 &#8211; the WordPress team has folded the functionality of WordPress Multiuser into the main WordPress project. So how do you use it?</p>
<p>This tutorial assumes your are comfortable using FTP clients such as <a href="http://filezilla-project.org/">Filezilla</a> and doing basic edits of WordPress files.</p>
<p>1. Download WordPress 3.0 release candidate. You can find it <a href="http://wordpress.org/development/2010/05/wordpress-3-0-release-candidate/">here</a>.</p>
<p>2. Edit wp-config in your favorite text editor and add the following line:</p>
<p>define(&#8216;WP_ALLOW_MULTISITE&#8217;, true);</p>
<p>(I&#8217;d suggest adding it just above the line &#8220;// ** MySQL settings &#8211; You can get this info from your web host ** //&#8221;)</p>
<p>3. Install WordPress normally</p>
<p>NOTE: If you&#8217;ve already installed WordPress 3.0, just edit wp-config and add that line of code, there&#8217;s no need to re-install.</p>
<p>4. Under Tools on the sidebar, you&#8217;ll now have an &#8220;Network&#8221; option. Click it.</p>
<p><img src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/06/screenshot-0.jpg?resize=144%2C118" alt="WordPress 3.0 Multisite Screenshot" title="WordPress 3.0 Multisite Screenshot" class="alignnone size-full wp-image-8139" data-recalc-dims="1" /></p>
<p>5. Here you&#8217;ll setup your &#8220;Network&#8221; &#8211; a Network is all the blogs or sites you&#8217;ll have under your WordPress install (if you&#8217;re migrating back to WordPress from WordPress Multiuser this might be confusing. In WordPress Multiuser the term for network was &#8220;site&#8221; and the term for site was &#8220;blog.&#8221; Explanation <a href="http://www.andrewnacin.com/2010/03/25/terminology-nightmare-blogs-sites-networks/">here</a>).</p>
<p><img src="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/06/screenshot-1.jpg?resize=611%2C226" alt="WordPress 3.0 Multisite Screenshot" title="WordPress 3.0 Multisite Screenshot" class="alignnone size-full wp-image-8140" data-recalc-dims="1" /></p>
<p>If your host supports it, you&#8217;ll have the option here to choose between subdomains and subdirectories.</p>
<p>Example of a subdomain: site1.yourdomain.com<br />
Example of a subdirectory: yourdomain.com/site1</p>
<p>Fill out your Network Title and Admin E-mail Address and press install.</p>
<p>6. You&#8217;ll be greeted with your next list of steps: creating a blogs.dir directory, editing wp-config.php, and .htaccess. WP recommends, as do I, backing up wp-config.php and .htaccess files before proceeding.</p>
<p>After completing the steps, you&#8217;ll need to log back into WordPress.</p>
<p>7. On your next login, you&#8217;ll notice a new menu: &#8220;Super Admin.&#8221;</p>
<p><img src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/06/screenshot-2.jpg?resize=149%2C168" alt="WordPress 3.0 Multisite Screenshot" title="WordPress 3.0 Multisite Screenshot" class="alignnone size-full wp-image-8141" data-recalc-dims="1" /></p>
<p>8. Click &#8220;Sites&#8221; under this option to create a new site. Fill out the forms accordingly.</p>
<p><img src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/06/screenshot-3.jpg?resize=414%2C300" alt="WordPress 3.0 Multisite Screenshot" title="WordPress 3.0 Multisite Screenshot" class="alignnone size-full wp-image-8142" data-recalc-dims="1" /></p>
<p>9. After creating a new site, click Users. You&#8217;ll see a new user was created for the new site.</p>
<p>10. You can control all sites on your network through the Super Admin menu, but for right now you might find it easier to administer individual sites through their own admin menus. You can access them as you would a normal wordpress site. In the example above, it would be: http://mydomain.net/malta/wp-admin</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/06/02/wordpress-3-multisite/feed/</wfw:commentRss>
		<slash:comments>74</slash:comments>
		</item>
		<item>
		<title>How to show ads to only search engine visitors using Who Sees Ads</title>
		<link>http://weblogtoolscollection.com/archives/2010/05/24/how-to-show-ads-to-only-search-engine-visitors-using-who-sees-ads/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/05/24/how-to-show-ads-to-only-search-engine-visitors-using-who-sees-ads/#comments</comments>
		<pubDate>Mon, 24 May 2010 06:46:40 +0000</pubDate>
		<dc:creator>Klint Finley</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8085</guid>
		<description><![CDATA[Perennial Weblog Tools Collection community favorite Who Sees Ads can be used to show ads only to certain visitors &#8211; such as people who have arrived on your site from a search engine. It&#8217;s a useful way to improve your click-through-ratio, and please your regular readers by hiding ads from them. This is a quick introduction to using the plugin. Showing ads only to search engine visitors is extremely simple &#8211; Who Sees Ads can do much, much more. Check out the links at the end of this article for more information. NOTE: Although the plugin says it&#8217;s for WordPress 2.5, it works fine with WordPress 2.92. I haven&#8217;t been able to test it with 3.0 yet because I don&#8217;t have any 3.0 test sites indexed in any search engines yet. Anyone else know if it works with 3.0? If you don&#8217;t want to do this with a plugin, you [...]]]></description>
				<content:encoded><![CDATA[<p>Perennial Weblog Tools Collection community favorite <a href="http://planetozh.com/blog/my-projects/wordpress-plugin-who-sees-ads-control-adsense-display/">Who Sees Ads</a> can be used to show ads only to certain visitors &#8211; such as people who have arrived on your site from a search engine. It&#8217;s a useful way to improve your click-through-ratio, and please your regular readers by hiding ads from them.</p>
<p>This is a quick introduction to using the plugin. Showing ads only to search engine visitors is extremely simple &#8211; Who Sees Ads can do much, much more. Check out the links at the end of this article for more information.</p>
<p><strong>NOTE:</strong> Although the plugin says it&#8217;s for WordPress 2.5, it works fine with WordPress 2.92. I haven&#8217;t been able to test it with 3.0 yet because I don&#8217;t have any 3.0 test sites indexed in any search engines yet. Anyone else know if it works with 3.0?</p>
<p>If you don&#8217;t want to do this with a plugin, you can do it with some simple PHP, see <a href="http://www.scratch99.com/2008/09/avoid-smart-pricing-show-adsense-only-to-search-engine-visitors/">here</a>.</p>
<p>1. Install and activate Who Sees Ads.</p>
<p><strong>NOTE:</strong> If you use WordPress Firewall (and <a href="http://weblogtoolscollection.com/archives/2010/04/27/more-plugins-for-securing-your-wordpress-install/">I recommend you do</a>), you&#8217;ll need to deactivate it while you install, activate, and configure this plugin.</p>
<p>2. Click &#8220;Who Sees Ads&#8221; under &#8220;Settings&#8221; on the dashboard.</p>
<p>3. Under &#8220;Edit Contexts&#8221; type a name for your context, preferably something descriptive like &#8220;Search Engines Only.&#8221;</p>
<p>4. Drag the &#8220;if Visitor comes from a search engine then Display&#8221; box from the &#8220;Possible Rules&#8221; box to the &#8220;Active Rules&#8221; box.</p>
<p><img src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/05/screenshot-11.jpg?resize=400%2C321" alt="Who Sees Ads? Screenshot 1" title="Who Sees Ads? Screenshot 1" class="alignnone size-full wp-image-8087" data-recalc-dims="1" /></p>
<p>5. Paste the code for your ad (from Adsense or wherever) into the &#8220;Ad Code&#8221; box.</p>
<p><img src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/05/screenshot-2.jpg?resize=400%2C371" alt="Who Sees Ads? Screenshot 2" title="Who Sees Ads? Screenshot 2" class="alignnone size-full wp-image-8089" data-recalc-dims="1" /></p>
<p>6. Under &#8220;Edit Context&#8221; select the context your just created. Code for your new context should appear. You can now copy and paste this into posts or into your theme templates.</p>
<p><img src="http://i2.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/05/screenshot-3.jpg?resize=400%2C131" alt="Who Sees Ads? Screenshot 3" title="Who Sees Ads? Screenshot 3" class="alignnone size-full wp-image-8090" data-recalc-dims="1" /></p>
<p>That&#8217;s all you need to do to get this very simple configuration to work &#8211; but wouldn&#8217;t it be nice if you could drop that PHP code into a widget? You can, but you&#8217;ll need another plugin for that.</p>
<p>7. Install and activate <a href="http://wordpress.org/extend/plugins/samsarin-php-widget/">Samsarin PHP Widget</a> &#8211; this plugin allows you to add widgets to your sidebar that can execute PHP code.</p>
<p>8. Go to &#8220;Widgets&#8221; under &#8220;Appearance&#8221; on the dashboard.</p>
<p>9. Drag an instance of Samsarin PHP Widget to your sidebar and position it where you want the ads to appear.</p>
<p>10. Paste the code from step 6 in the widget.</p>
<p><strong>Don&#8217;t forget to turn WordPress Firewall back on if you turned it off.</strong></p>
<p>For a look at some other things you can do with this plugin:</p>
<p><a href="http://weblogtoolscollection.com/archives/2009/04/29/9-ways-to-make-your-wordpress-blog-smart/">9 Ways to Make Your WordPress Blog “Smart”</a></p>
<p><a href="http://weblogtoolscollection.com/archives/2008/06/11/hiding-advertisements-for-single-posts/">Hiding Advertisements For Single Posts</a></p>
<p>And of course <a href="http://planetozh.com/blog/my-projects/wordpress-plugin-who-sees-ads-control-adsense-display/">visit the plugin homepage</a> for even more documentation and ideas!</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/05/24/how-to-show-ads-to-only-search-engine-visitors-using-who-sees-ads/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Adding Scripts Properly to WordPress Part 3 – Page Detection</title>
		<link>http://weblogtoolscollection.com/archives/2010/05/08/adding-scripts-properly-to-wordpress-part-3-page-detection/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/05/08/adding-scripts-properly-to-wordpress-part-3-page-detection/#comments</comments>
		<pubDate>Sat, 08 May 2010 19:38:40 +0000</pubDate>
		<dc:creator>Ronald Huereca</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[$_GET]]></category>
		<category><![CDATA[$_SERVER]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[page detection]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8032</guid>
		<description><![CDATA[You might find yourself in the situation where you only want a script to run on a certain page. In fact, it’s good practice to only load your JavaScript files when absolutely necessary; loading the files on every single page is a big no-no (I’ve been chastised before for this). While on the blog’s front-end, WordPress makes it super-easy with its conditional tags. I’m not going to go over the conditional tags here, but here are a few you can take advantage of: is_home() is_front_page() is_single() is_page() And much more. While being selective on the front-end is relatively straightforward, the admin-panel is another monster. Sure, there’s the is_admin() conditional, but what if you only want to run a script in a certain section within the admin panel? One technique is to use the PHP reserved variable called $_GET. Say you have a plugin options page with a URL of: http://www.mydomain.com/wp-admin/options-general.php?page=my-plugin-file.php [...]]]></description>
				<content:encoded><![CDATA[<p>You might find yourself in the situation where you only want a script to run on a certain page.  In fact, it’s good practice to only load your JavaScript files when absolutely necessary;  loading the files on every single page is a big no-no (I’ve been chastised before for this).</p>
<p>While on the blog’s front-end, WordPress makes it <strong>super-easy</strong> with its conditional tags.</p>
<p>I’m not going to go over the conditional tags here, but here are a few you can take advantage of:</p>
<ul>
<li><a href="http://codex.wordpress.org/Conditional_Tags#The_Main_Page">is_home()</a></li>
<li><a href="http://codex.wordpress.org/Conditional_Tags#The_Front_Page">is_front_page()</a></li>
<li><a href="http://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page">is_single()</a></li>
<li><a href="http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page">is_page()</a></li>
<li><a href="http://codex.wordpress.org/Conditional_Tags">And much more</a>.</li>
</ul>
<p>While being selective on the front-end is relatively straightforward, the admin-panel is another monster.</p>
<p>Sure, there’s the <strong>is_admin()</strong> conditional, but what if you only want to run a script in a certain section within the admin panel?</p>
<p>One technique is to use the PHP reserved variable called <strong>$_GET</strong>.</p>
<p>Say you have a plugin options page with a URL of:</p>
<blockquote><pre><code>http://www.mydomain.com/wp-admin/options-general.php?page=my-plugin-file.php</code></pre>
</blockquote>
<p>You can use the <strong>$_GET</strong> variable to capture the page and run a conditional to determine if the page is yours.</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800000; background:#ffffe8; font-weight:bold; '>if</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>isset</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$_GET</span><span style='color:#808030; background:#ffffe8; '>[</span><span style='color:#0000e6; background:#ffffe8; '>'page'</span><span style='color:#808030; background:#ffffe8; '>]</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '> </span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>if</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$_GET</span><span style='color:#808030; background:#ffffe8; '>[</span><span style='color:#0000e6; background:#ffffe8; '>'page'</span><span style='color:#808030; background:#ffffe8; '>]</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"my-plugin-file.php"</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#696969; background:#ffffe8; '>/*load your scripts here */</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>If there are no variables to capture, you may have to use the reserved variable <strong>$_SERVER</strong> to capture the page name.  From there, you would use a conditional or a switch statement.</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800000; background:#ffffe8; font-weight:bold; '>switch</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#400000; background:#ffffe8; '>basename</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$_SERVER</span><span style='color:#808030; background:#ffffe8; '>[</span><span style='color:#0000e6; background:#ffffe8; '>'SCRIPT_FILENAME'</span><span style='color:#808030; background:#ffffe8; '>]</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>case</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"edit-comments.php"</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#696969; background:#ffffe8; '>/*load scripts here*/</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>break</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>case</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"upload.php"</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#696969; background:#ffffe8; '>/*load other scripts here*/</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>break</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>default</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>break</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<h3>A Real-World Example</h3>
<p>For a WordPress plugin I modified (<a href="http://wordpress.org/extend/plugins/wp-grins-lite/">WP Grins Lite</a> &#8211; I&#8217;m not the original author), I wanted to include the JavaScript file only on specific pages.</p>
<p>In the admin panel, I wanted the script to load when adding/editing posts and pages, and when editing a comment.</p>
<p>On a post, I wanted the script to load only on posts and pages.  To make things interesting, I also wanted to only load the script if comments were open.</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800000; background:#ffffe8; font-weight:bold; '>function</span><span style='color:#000000; background:#ffffe8; '> add_scripts</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>global</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$post</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>if</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>is_admin</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>switch</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#400000; background:#ffffe8; '>basename</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$_SERVER</span><span style='color:#808030; background:#ffffe8; '>[</span><span style='color:#0000e6; background:#ffffe8; '>'SCRIPT_FILENAME'</span><span style='color:#808030; background:#ffffe8; '>]</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>case</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"post.php"</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>case</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"post-new.php"</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>case</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"page.php"</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>case</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"page-new"</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>case</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"comment.php"</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>break</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>default</span><span style='color:#800080; background:#ffffe8; '>:</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>return</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>else</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>if</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>!</span><span style='color:#000000; background:#ffffe8; '>is_single</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>&amp;</span><span style='color:#808030; background:#ffffe8; '>&amp;</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>!</span><span style='color:#000000; background:#ffffe8; '>is_page</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>|</span><span style='color:#808030; background:#ffffe8; '>|</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'closed'</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$post</span><span style='color:#808030; background:#ffffe8; '>-></span><span style='color:#000000; background:#ffffe8; '>comment_status</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>return</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '> </span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'wp_grins_lite'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> plugins_url</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'wp-grins-lite'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'/js/wp-grins.js'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>"jquery"</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#008000; background:#ffffe8; '>1.0</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '> </span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;wp_localize_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'wp_grins_lite'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'wpgrinslite'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>this</span><span style='color:#808030; background:#ffffe8; '>-</span><span style='color:#808030; background:#ffffe8; '>></span><span style='color:#000000; background:#ffffe8; '>get_js_vars</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>And there you have it.  Page detection in a nutshell.</p>
<p><em>This article is an excerpt from <a href="http://www.ronalfy.com/about/">Ronald Huereca&#8217;s</a> e-book entitled WordPress and Ajax (used with permission).</em></p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/05/08/adding-scripts-properly-to-wordpress-part-3-page-detection/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Adding Scripts Properly to WordPress Part 2 – JavaScript Localization</title>
		<link>http://weblogtoolscollection.com/archives/2010/05/07/adding-scripts-properly-to-wordpress-part-2-javascript-localization/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/05/07/adding-scripts-properly-to-wordpress-part-2-javascript-localization/#comments</comments>
		<pubDate>Sat, 08 May 2010 03:16:45 +0000</pubDate>
		<dc:creator>Ronald Huereca</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript localization]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[wp_localize_script]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8029</guid>
		<description><![CDATA[When adding scripts to WordPress, you will inevitably run into a small, but painful, issue of localization. Localizing a plugin or theme is relatively straightforward, but JavaScript presents its own difficulties since we can’t easily call the PHP functions necessary (which is one reason authors embed JavaScript in PHP files). Since embedding JavaScript in PHP files is never a good technique, we use localization to save the day. With JavaScript localization, you can use PHP magic to build your localized strings, and then use JavaScript to read/parse those strings. What you do with them is only limited to your imagination. Furthermore, if you display anything with JavaScript, chances are your users will want the strings to be localized. Fortunately, WordPress provides the ultra-handy wp_localize_script function. wp_localize_script The wp_localize_script takes three arguments: handle object_name l10n Handle The handle argument will be the same handle you use for your script name. For [...]]]></description>
				<content:encoded><![CDATA[<p>When adding scripts to WordPress, you will inevitably run into a small, but painful, issue of localization.</p>
<p>Localizing a plugin or theme <a href="http://weblogtoolscollection.com/archives/2007/08/27/localizing-a-wordpress-plugin-using-poedit/">is relatively straightforward</a>, but JavaScript presents its own difficulties since we can’t easily call the PHP functions necessary (which is one reason authors embed JavaScript in PHP files).</p>
<p>Since embedding JavaScript in PHP files is <strong>never</strong> a good technique, we use localization to save the day.</p>
<p>With JavaScript localization, you can use PHP magic to build your localized strings, and then use JavaScript to read/parse those strings.  What you do with them is only limited to your imagination.</p>
<p>Furthermore, if you display anything with JavaScript, chances are your users will want the strings to be localized.</p>
<p>Fortunately, WordPress provides the ultra-handy <strong>wp_localize_script</strong> function.</p>
<h3>wp_localize_script</h3>
<p>The <strong>wp_localize_script</strong> takes three arguments:</p>
<ul>
<li>handle</li>
<li>object_name</li>
<li>l10n</li>
</ul>
<h4>Handle</h4>
<p>The handle argument will be the same handle you use for your script name.<br />
For example, if you have a handle of <strong>my_script</strong>, you would use the same name when calling the <strong>wp_localize_script</strong> function.</p>
<h4>Object_name</h4>
<p>The <strong>object_name</strong> argument is a string that tells WordPress to create a JavaScript object using the name you specify.</p>
<p>It’s important that the string you pass <em>is as unique as possible</em> in order to minimize naming conflicts with other scripts.</p>
<p>For the upcoming example, our object name will be <strong>my_unique_name</strong>.</p>
<h4>l10n</h4>
<p>The <strong>l10n</strong> argument is an array of strings you would like to localize.<br />
Within this array, you will want to take advantage of the <strong>__</strong> function.</p>
<h4>wp_localize_script Example</h4>
<p>For the purpose of this example, let’s create a function called <strong>localize_vars</strong> and have it return an array.</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800000; background:#ffffe8; font-weight:bold; '>function</span><span style='color:#000000; background:#ffffe8; '> localize_vars</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>return</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#0000e6; background:#ffffe8; '>'SiteUrl'</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#808030; background:#ffffe8; '>></span><span style='color:#000000; background:#ffffe8; '> get_bloginfo</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'url'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#0000e6; background:#ffffe8; '>'OtherText'</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#808030; background:#ffffe8; '>></span><span style='color:#000000; background:#ffffe8; '> __</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my text'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"my_localization_name"</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#696969; background:#ffffe8; '>//End localize_vars</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>Please note the use of the <strong>__()</strong> function.  It takes in the text we want to localize, and our localization name. This will be the same name you use if you take advantage of localization within WordPress.</p>
<p>The variable <strong>SiteURL</strong> gives us the http path to our WordPress site, which comes in handy in certain situations.</p>
<p>From another area in our code, we call the <strong>localize_vars</strong> function:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> </span>
<span style='color:#000000; background:#ffffe8; '>wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> plugins_url</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'your-plugin-name'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#0000e6; background:#ffffe8; '>'/my_script.js'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'1.0.0'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>wp_localize_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'my_unique_name'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> localize_vars</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>WordPress then conveniently adds localization JavaScript immediately before our main script is included.  Viewing the page source will reveal:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#696969; '>/* &lt;![CDATA[ */</span>
    my_unique_name <span style='color:#808030; '>=</span> <span style='color:#800080; '>{</span>
        SiteUrl<span style='color:#800080; '>:</span> <span style='color:#0000e6; '>"http://www.mydomain.com"</span><span style='color:#808030; '>,</span>
        OtherText<span style='color:#800080; '>:</span> <span style='color:#0000e6; '>"my localized text"</span>
    <span style='color:#800080; '>}</span>
<span style='color:#696969; '>/* ]]&gt; */</span>
<span style='color:#808030; '>&lt;</span><span style='color:#808030; '>/</span>script<span style='color:#808030; '>></span>
<span style='color:#808030; '>&lt;</span>script type<span style='color:#808030; '>=</span><span style='color:#0000e6; '>'text/javascript'</span> src<span style='color:#808030; '>=</span><span style='color:#0000e6; '>'http://www.mydomain.com/wp-content/plugins/my_plugin/my_script.js?ver=1.0.0'</span><span style='color:#808030; '>></span><span style='color:#808030; '>&lt;</span><span style='color:#808030; '>/</span>script<span style='color:#808030; '>></span>
</pre>
<p></code></p></blockquote>
<p>With the localize example, you can use PHP magic to add just about anything to your localization object.  Hence, no need to ever embed JavaScript within a PHP file.</p>
<p>Now you can call your localized JavaScript variables from your <strong>my_script.js</strong> file.  Here’s an example of an alert:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'>alert<span style='color:#808030; '>(</span>my_unique_name<span style='color:#808030; '>.</span>SiteUrl<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
alert<span style='color:#808030; '>(</span>my_unique_name<span style='color:#808030; '>.</span>OtherText<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
</pre>
<p></code></p></blockquote>
<p>It’s really as easy as that.  You can now localize JavaScript strings.</p>
<h3>Other Localization Techniques</h3>
<p>While the <strong>wp_localize_script</strong> function does great work, it has one inherent flaw: each localized string is on a new line.  For plugins that require a lot of localized strings, the size of the page source can easily balloon to unacceptable levels.</p>
<p>To remedy this, we can use two additional localization techniques: one uses JSON, and the other is a custom function.</p>
<h3>The JSON Technique</h3>
<p>The JSON Technique uses WordPress’ built-in JSON class in order to parse our localized variables.</p>
<p>We would use the same <strong>localize_vars</strong> function, but would modify the way we queue our scripts.</p>
<p>First, let’s create a helper function that will instantiate the JSON class and spit out our localized variables to screen.</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800000; background:#ffffe8; font-weight:bold; '>function</span><span style='color:#000000; background:#ffffe8; '> js_localize</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$name</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$vars</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#a65700; background:#ffffe8; '>?></span><span style='color:#000000; background:#ffffff; '></span>
<span style='color:#000000; background:#ffffff; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#a65700; background:#ffffff; '>&lt;</span><span style='color:#800000; background:#ffffff; font-weight:bold; '>script type='text/javascript'</span><span style='color:#a65700; background:#ffffff; '>></span><span style='color:#000000; background:#ffffff; '></span>
<span style='color:#000000; background:#ffffff; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#696969; background:#ffffff; '>/* &lt;![CDATA[ */</span><span style='color:#000000; background:#ffffff; '></span>
<span style='color:#000000; background:#ffffff; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffff; font-weight:bold; '>var</span><span style='color:#000000; background:#ffffff; '> </span><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>echo</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$name</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#a65700; background:#ffffe8; '>?></span><span style='color:#000000; background:#ffffff; '> </span><span style='color:#808030; background:#ffffff; '>=</span><span style='color:#000000; background:#ffffff; '> </span>
<span style='color:#000000; background:#ffffff; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> </span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>require_once</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>ABSPATH </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'/wp-includes/class-json.php'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#000000; background:#ffffe8; '>$wp_json</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>new</span><span style='color:#000000; background:#ffffe8; '> Services_JSON</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>echo</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#400000; background:#ffffe8; '>stripslashes</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$wp_json</span><span style='color:#808030; background:#ffffe8; '>-</span><span style='color:#808030; background:#ffffe8; '>></span><span style='color:#000000; background:#ffffe8; '>encodeUnsafe</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$vars</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '> </span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#a65700; background:#ffffe8; '>?></span><span style='color:#800080; background:#ffffff; '>;</span><span style='color:#000000; background:#ffffff; '></span>
<span style='color:#000000; background:#ffffff; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#696969; background:#ffffff; '>/* ]]&gt; */</span><span style='color:#000000; background:#ffffff; '></span>
<span style='color:#000000; background:#ffffff; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#a65700; background:#ffffff; '>&lt;/</span><span style='color:#800000; background:#ffffff; font-weight:bold; '>script</span><span style='color:#a65700; background:#ffffff; '>></span><span style='color:#000000; background:#ffffff; '></span>
<span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>The <strong>js_localize</strong> function takes in a <strong>$name</strong> (our object name) and an array of our localized variables (<strong>$vars</strong>).  </p>
<p>The function then instantiates the JSON class and encodes the variables for output.</p>
<p>Here’s how the code would look when queueing up your scripts:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> </span>
<span style='color:#000000; background:#ffffe8; '>js_localize</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_unique_name'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> localize_vars</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> plugins_url</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'your-plugin-name'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'/my_script.js'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'1.0.0'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>Please note that the <strong>js_localize</strong> function is run before the script is queued.</p>
<p>While this technique does eliminate the newlines and creates cleaner source code, it does have one major flaw.  It doesn’t work for all languages.</p>
<p>For example, the Turkish language causes the above technique to crash and burn.</p>
<p>However, if you don’t plan on having additional languages and want localization purely for the ability to access the JavaScript variables, then I would recommend this technique.</p>
<h3>A Custom Function</h3>
<p>For those wanting to eliminate the newlines caused by <strong>wp_localize_scripts</strong>, and still have the ability to handle complex languages, then a custom function will have to suffice.</p>
<p>We’ll use the same exact code to queue our scripts, but the <strong>js_localize</strong> function will change a bit.</p>
<p>My technique is to iterate through the localized variables, save them to an array, and output the array to screen. </p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800000; background:#ffffe8; font-weight:bold; '>function</span><span style='color:#000000; background:#ffffe8; '> js_localize</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$name</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$vars</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#000000; background:#ffffe8; '>$data</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"var </span><span style='color:#0000e6; background:#ffffe8; '>$name</span><span style='color:#0000e6; background:#ffffe8; '> = {"</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#000000; background:#ffffe8; '>$arr</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>foreach</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$vars</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>as</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$key</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#808030; background:#ffffe8; '>></span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$value</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#000000; background:#ffffe8; '>$arr</span><span style='color:#808030; background:#ffffe8; '>[</span><span style='color:#400000; background:#ffffe8; '>count</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$arr</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>]</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$key</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>" : '"</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> esc_js</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#000000; background:#ffffe8; '>$value</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"'"</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#000000; background:#ffffe8; '>$data</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#400000; background:#ffffe8; '>implode</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>","</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '>$arr</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#000000; background:#ffffe8; '>$data</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#808030; background:#ffffe8; '>=</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"};"</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>echo</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"&lt;script type='text/javascript'></span><span style='color:#0f69ff; background:#ffffe8; '>\n</span><span style='color:#0000e6; background:#ffffe8; '>"</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>echo</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"/* &lt;![CDATA[ */</span><span style='color:#0f69ff; background:#ffffe8; '>\n</span><span style='color:#0000e6; background:#ffffe8; '>"</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>echo</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#000000; background:#ffffe8; '>$data</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>echo</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"</span><span style='color:#0f69ff; background:#ffffe8; '>\n</span><span style='color:#0000e6; background:#ffffe8; '>/* ]]&gt; */</span><span style='color:#0f69ff; background:#ffffe8; '>\n</span><span style='color:#0000e6; background:#ffffe8; '>"</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>echo</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>"&lt;/script></span><span style='color:#0f69ff; background:#ffffe8; '>\n</span><span style='color:#0000e6; background:#ffffe8; '>"</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>It might not be the most poetic thing you’ve ever seen, but it works pretty well, even for those complex languages.</p>
<h3>Localization Conclusion</h3>
<p>Within this article you learned the how and the why of JavaScript localization.</p>
<p>The benefits of localizing your JavaScript are:</p>
<ul>
<li>No need to embed JavaScript and PHP.</li>
<li>Can capture PHP variables without having to load the WordPress environment.</li>
<li>Can enable others to translate your JavaScript strings.</li>
</ul>
<p>You also learned three different techniques to achieve localization.</p>
<ul>
<li>Using wp_localize_script &#8211; Recommended for general use.</li>
<li>Using JSON &#8211; Recommended for non-complex localization and performance.</li>
<li>Using a Custom Function &#8211; Recommended for complex localization and performance.</li>
</ul>
<p><em>This article is an excerpt from <a href="http://www.ronalfy.com/about/">Ronald Huereca&#8217;s</a> e-book entitled WordPress and Ajax (used with permission).</em></p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/05/07/adding-scripts-properly-to-wordpress-part-2-javascript-localization/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Adding Scripts Properly to WordPress Part 1 – wp_enqueue_script</title>
		<link>http://weblogtoolscollection.com/archives/2010/05/06/adding-scripts-properly-to-wordpress-part-1-wp_enqueue_script/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/05/06/adding-scripts-properly-to-wordpress-part-1-wp_enqueue_script/#comments</comments>
		<pubDate>Thu, 06 May 2010 23:04:12 +0000</pubDate>
		<dc:creator>Ronald Huereca</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[admin_print_scripts]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[wp_enqueue_script]]></category>
		<category><![CDATA[wp_print_scripts]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=8016</guid>
		<description><![CDATA[Starting in WordPress 2.1 (if I remember correctly), the awesome folks at Automattic gave us the even awesomer function of wp_enqueue_script. Before that, it was every plugin or theme author for himself. If you wanted to add in a script, it was hard-coded in. As you might imagine, this presented a ton of problems. Scripts were loaded twice, out of order, or even when they weren’t needed at all. Furthermore, some themes and plugins had the JavaScript embedded within the plugin’s or theme’s PHP file just to capture a few PHP variables. Not good! In order to add scripts properly to JavaScript, you must always keep your PHP and JavaScript separate. And by separate, I mean separate files. There’s just no excuse anymore (I’ll get into this in Part 2 of this series). The wp_enqueue_script function is the first step in loading your scripts properly. Not only can you add [...]]]></description>
				<content:encoded><![CDATA[<p>Starting in WordPress 2.1 (if I remember correctly), the awesome folks at <a href="http://www.automattic.com">Automattic</a> gave us the even awesomer function of <strong>wp_enqueue_script</strong>.</p>
<p>Before that, it was every plugin or theme author for himself.  If you wanted to add in a script, it was hard-coded in.</p>
<p>As you might imagine, this presented a ton of problems.  Scripts were loaded twice, out of order, or even when they weren’t needed at all.</p>
<p>Furthermore, some themes and plugins had the JavaScript embedded within the plugin’s or theme’s PHP file just to capture a few PHP variables.  Not good!  In order to add scripts properly to JavaScript, you must always keep your PHP and JavaScript separate.  And by separate, I mean separate files.  There’s just no excuse anymore (I’ll get into this in Part 2 of this series).</p>
<p>The <strong>wp_enqueue_script</strong> function is the first step in loading your scripts properly.  Not only can you add your script, but you can also specify the dependencies (e.g., jQuery), and the version number.</p>
<p>This prevents duplicate JavaScript files from loading, which is always a good thing.</p>
<h3>So How Does wp_enqueue_script Work?</h3>
<p>Aside from <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">the excellent documentation</a> from WordPress, you’ll find my regurgitated version below (gross, I know).</p>
<p>The function <strong>wp_enqueue_script</strong> takes in five arguments, with the last four being optional.</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'handle'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'src'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'deps'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'ver'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'in_footer'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>The <strong>handle</strong> argument is a string that names your script, or references someone else’s.</p>
<p>For example, you can add the jQuery script to any page by calling:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>Likewise, if you have previously registered your script (using <strong>wp_register_script</strong>), you can call your script by calling:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<h4>Src</h4>
<p>The src argument is asking for the URL of the file.  If you supply the src of the script, the <strong>wp_enqueue_script</strong> function automatically registers your script for others to use (no need to use <strong>wp_register_script</strong>).</p>
<p>An example of it in use is: </p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> WP_CONTENT_URL </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'plugins/my_plugin/my_script.js'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>Themers would use:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '> wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> WP_CONTENT_URL </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'themes/my_theme/my_script.js'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<h4>Deps</h4>
<p>The <strong>deps</strong> argument is an array of dependencies.  For example, if your script requires jQuery or other JavaScript files, it’ll load these files before your plugin’s JavaScript file.</p>
<p>Here’s an example:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> WP_CONTENT_URL </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'plugins/my_plugin/my_script.js'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'another_script'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>See that array up there (it’s pretty, I know)?  That’s what’s calling your dependencies. </p>
<p>jQuery is built into WordPress by default, so calling it via dependency is no problem as long as you queue it via <strong>wp_enqueue_script</strong>.  </p>
<p>The <strong>another_script</strong> dependency assumes you have already used <strong>wp_enqueue_script</strong> to assign it a handle and a src.</p>
<p>The outcome in this scenario is that <strong>jQuery</strong> and <strong>another_script</strong> will load before <strong>my_script</strong>.</p>
<h4>Ver</h4>
<p>The <strong>ver</strong> argument is simply the version of the JavaScript file for caching purposes.  If you are supplying your own script, it’s a good idea to supply a version.</p>
<p>The version is string based and looks like this:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> WP_CONTENT_URL </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'plugins/my_plugin/my_script.js'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'another_script'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'1.0.0'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>As you update your JavaScript file, update the <strong>ver</strong> argument.  If you don’t, you’ll inevitably run into caching issues with WordPress.</p>
<h4>In_footer</h4>
<p>The <strong>in_footer</strong> argument (since WP 2.8) determines if the script will load in the header or footer (header is the default).</p>
<p>To load your script in the footer, simply pass it a <strong>1</strong> (or <strong>true</strong>).</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'my_script'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> WP_CONTENT_URL </span><span style='color:#808030; background:#ffffe8; '>.</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'plugins/my_plugin/my_script.js'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'another_script'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'1.0.0'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>true</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>Great care should be used when setting the scripts to load in the footer as some themes do not have this functionality built in (the theme must make use of the <strong>wp_footer</strong> function call).</p>
<h3>Naming Your Handler</h3>
<p>One last thing (err, warning?) to take note of is naming your handler for <strong>wp_enqueue_script</strong>.  If you are using a third-party script (say, Colorbox), use common sense in naming the handler.  There’s no reason to name it “lightbox” or “mybox”.  The handler name should be obvious, right? </p>
<p>The same goes for the built-in scripts with WordPress.  </p>
<p>For example, the handler &#8216;jquery&#8217; is built-in.  Do you want to supply your own version of jQuery?  </p>
<p>How about ruin everybody&#8217;s day and give it a handler of &#8216;jquery.js&#8217;?  The result will inevitably be two jQuery instances loading on the same page and causing mayhem with other scripts.</p>
<p>Instead, use the function <strong>wp_deregister_script</strong> to remove the WordPress reference and supply your own.</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>wp_deregister_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'your-jquery-path.js'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>With this technique, however, you should have a pretty darn good reason for not including the default scripts.  After all, you&#8217;ll essentially be running a piece of software that may not be fully tested and/or compatible with WordPress.  </p>
<h3>Great, I have wp_enqueue_script down.  Now what?<br />
</h3>
<p>You have to call <strong>wp_enqueue_script</strong> from the appropriate hook in WordPress.</p>
<p>Fortunately, WordPress has two such action hooks you can tap into: <strong>admin_print_scripts</strong> and <strong>wp_print_scripts</strong>.</p>
<p>The <strong>admin_print_scripts</strong> hook allows you to add scripts in the admin panel, while the <strong>wp_print_scripts</strong> hook allows you to add scripts everywhere else.</p>
<p>Adding your <strong>wp_enqueue_script</strong> code is as simple as adding an action inside your plugin or theme code.</p>
<p>An example of the code being used inside of a class constructor is:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>add_action</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'admin_print_scripts'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>array</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>&amp;</span><span style='color:#000000; background:#ffffe8; '>$</span><span style='color:#800000; background:#ffffe8; font-weight:bold; '>this</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'add_admin_scripts'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>And for those not using a class (classes help avoid conflicts with other plugins):</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>add_action</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'admin_print_scripts'</span><span style='color:#808030; background:#ffffe8; '>,</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#0000e6; background:#ffffe8; '>'add_admin_scripts'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<p>For the above example, we have a callback method of <strong>add_admin_scripts</strong>.  An example of it in use is:</p>
<blockquote><pre><code><pre style='color:#000000;background:#ffffff;'><span style='color:#a65700; background:#ffffe8; '>&lt;?php</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800000; background:#ffffe8; font-weight:bold; '>function</span><span style='color:#000000; background:#ffffe8; '> add_admin_scripts</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#000000; background:#ffffe8; '> </span><span style='color:#800080; background:#ffffe8; '>{</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#000000; background:#ffffe8; '>&#xa0;&#xa0;&#xa0;&#xa0;wp_enqueue_script</span><span style='color:#808030; background:#ffffe8; '>(</span><span style='color:#0000e6; background:#ffffe8; '>'jquery'</span><span style='color:#808030; background:#ffffe8; '>)</span><span style='color:#800080; background:#ffffe8; '>;</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#800080; background:#ffffe8; '>}</span><span style='color:#000000; background:#ffffe8; '></span>
<span style='color:#a65700; background:#ffffe8; '>?></span>
</pre>
<p></code></p></blockquote>
<h3>Conclusion</h3>
<p>Here are the steps you should follow in order to add scripts to a WordPress theme or plugin:</p>
<ul>
<li>Add the appropriate action to your WordPress theme or plugin (themers will want to use <strong>functions.php</strong>).</li>
<li>Determine your script dependencies.</li>
<li>Code your <strong>wp_enqueue_script</strong> calls appropriately.</li>
</ul>
<p><em>This article is an excerpt from <a href="http://www.ronalfy.com/about/">Ronald Huereca&#8217;s</a> e-book entitled WordPress and Ajax (used with permission).</em></p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/05/06/adding-scripts-properly-to-wordpress-part-1-wp_enqueue_script/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>More plugins for securing your WordPress install</title>
		<link>http://weblogtoolscollection.com/archives/2010/04/27/more-plugins-for-securing-your-wordpress-install/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/04/27/more-plugins-for-securing-your-wordpress-install/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 11:48:42 +0000</pubDate>
		<dc:creator>Klint Finley</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[Wordpress for Beginners]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[WordPress Security]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=7987</guid>
		<description><![CDATA[I wrote previously on securing a fresh WordPress install. Today, I&#8217;ll cover several WordPress plugins that can be used with fresh or existing WordPress installations to enhance security. I&#8217;m not going to cover recovering a hacked site, or exploit scanning tools like Exploit Scanner or WordPress Antivirus in this tutorial. As before, I&#8217;ll emphasize a few things: 1. Your WordPress security is only as good as the security on your local computer. If you&#8217;re not running good antivirus and anti-malware software or are using an insecure wireless connection, none of this will matter. 2. Likewise, if you&#8217;re not keeping your WordPress install updated, none of this will matter. 3. I should have at least mentioned this in my previous security article but didn&#8217;t: your WordPress security is also only as good as your web server&#8217;s security. Since the audience for these tutorials is beginners, I&#8217;m going to assume that you [...]]]></description>
				<content:encoded><![CDATA[<p>I wrote previously on <a href="http://weblogtoolscollection.com/archives/2010/04/15/how-to-improve-basic-security-on-a-fresh-wordpress-install/">securing a fresh WordPress install</a>. Today, I&#8217;ll cover several WordPress plugins that can be used with fresh or existing WordPress installations to enhance security. I&#8217;m not going to cover recovering a hacked site, or exploit scanning tools like <a href="http://wordpress.org/extend/plugins/exploit-scanner/">Exploit Scanner</a> or <a href="http://wordpress.org/extend/plugins/antivirus/">WordPress Antivirus</a> in this tutorial.</p>
<p><span id="more-7987"></span></p>
<p>As before, I&#8217;ll emphasize a few things:</p>
<p>1. Your WordPress security is only as good as the security on your local computer. If you&#8217;re not running good antivirus and anti-malware software or are using an insecure wireless connection, none of this will matter.<br />
2. Likewise, if you&#8217;re not keeping your WordPress install updated, none of this will matter.<br />
3. I should have at least mentioned this in my previous security article but didn&#8217;t: your WordPress security is also only as good as your web server&#8217;s security. Since the audience for these tutorials is beginners, I&#8217;m going to assume that you don&#8217;t have a lot of control over your host&#8217;s security settings. So I&#8217;m not going to say anything else about this other than to look for a reputable host with experience hosting WordPress.<br />
4. Make sure you&#8217;re using a strong password. See step 2 of <a href="http://weblogtoolscollection.com/archives/2010/04/15/how-to-improve-basic-security-on-a-fresh-wordpress-install/">my previous tutorial</a>.<br />
5. I&#8217;m going to assume you already know how to install WordPress plugins.</p>
<p>NOTE: I&#8217;m writing this guide for WordPress 2.92, the current stable release. All of these plugins seem to work with WordPress 3.0, but I haven&#8217;t thoroughly tested them.</p>
<p><strong>WP Security Scan</strong></p>
<p>Let&#8217;s start by checking for the biggest security holes first, using the plugin <a href="http://semperfiwebdesign.com/plugins/wp-security-scan/">WP Security Scan</a>.</p>
<p>After you install you should see a new &#8220;Security&#8221; section on the left column of your dashboard:</p>
<p><img class="alignnone size-full wp-image-7988" title="screenshot-1" src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/04/screenshot-1.png?resize=150%2C336" alt="" data-recalc-dims="1" /></p>
<p>Let&#8217;s click &#8220;Scanner&#8221; and check our file permissions, the most crucial of security settings in WordPress. Chances are everything will be shaded green, and everything&#8217;s ok. However, if anything&#8217;s not set correctly it will be highlighted in red. Changing file permissions is beyond the scope of this tutorial &#8211; contact your web host if you need to change anything.</p>
<p><img class="alignnone size-full wp-image-7994" title="screenshot-2" src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/04/screenshot-2.png?resize=535%2C83" alt="" data-recalc-dims="1" /></p>
<p>Next, let&#8217;s change our database prefix. This is a &#8220;<a href="http://en.wikipedia.org/wiki/Security_through_obsurity">security through obscurity</a>&#8221; technique. What we want to do is make your WordPress database harder to exploit by using a database prefix other than the default one &#8211; this way any sort of generic, automated attack on the database will likely fail because the hacker will be using the wrong database prefix.</p>
<p><strong>BEFORE ATTEMPTING THIS MAKE SURE YOU BACKUP</strong>. I can&#8217;t stress this enough. I wrote a tutorial on <a href="http://weblogtoolscollection.com/archives/2010/04/21/backing-up-your-wordpress-database-with-wp-db-backup/">backing up your WordPress tutorial</a>. Even if you don&#8217;t use the plugin I describe there, make sure you&#8217;ve got a good backup before proceeding.</p>
<p>If you followed my last security tutorial and changed your database prefix during install, you can skip this step.</p>
<p>Otherwise, click &#8220;Database&#8221; on the Security section. You&#8217;ll see something like this:</p>
<p><img class="alignnone size-full wp-image-7995" title="screenshot-3" src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/04/screenshot-3.png?resize=628%2C195" alt="" data-recalc-dims="1" /></p>
<p>If you see something other than &#8220;wp_&#8221; in the field labeled &#8220;Change the current&#8221; field, then you can skip the next step.</p>
<p>Change &#8220;wp_&#8221; to something else. It&#8217;s highly recommended that you still keep the _ for database readability in the future, however.</p>
<p>Click &#8220;Start Renaming&#8221;</p>
<p>If this fails, you&#8217;ll either have to change the database prefix manually or not at all. Manual changes of the prefix table are beyond the scope of this tutorial.</p>
<p><strong>Secure WordPress</strong></p>
<p>Next, let&#8217;s install <a href="http://bueltge.de/wordpress-login-sicherheit-plugin/652/">Secure WordPress</a>. After you install it click &#8220;Secure WP&#8221; in the settings column of the left column of the dashboard. Most of the defaults should be fine, except one: if you&#8217;re not planning on using Windows Live Writer, check the box next to that option and click &#8220;Save Changes.&#8221;</p>
<p><strong>WordPress Firewall</strong></p>
<p>The steps above will help prevent attacks by hiding information about your WordPress install from attackers, making sure the correct file permissions are set, and plugging a few potential security holes. Next we&#8217;ll install some plugins that actually stop attacks on your blog.</p>
<p>WordPress Firewall is a handy plugin for preventing a variety of attacks. This one is especially important if you weren&#8217;t able to change your database prefix. It&#8217;s quite simple &#8211; just install it. There should be no need to change the default settings. <strong>Important:</strong> WordPress Firewall has only been tested up to WordPress 2.8. It has not been tested with WordPress 2.92 or WordPress 3.0 beta 2.</p>
<p><strong>Bad queries</strong></p>
<p><a href="http://wordpress.org/extend/plugins/block-bad-queries/">Block Bad Queries</a>, like Firewall, prevents hackers from performing certain common dangerous actions on your site. This one you just install and activate &#8211; there are no settings to change.</p>
<p><strong>Chap Secure Login</strong></p>
<p>If you&#8217;re not using SSL to login (once again, beyond the scope of this tutorial), you can use <a href="http://wordpress.org/extend/plugins/chap-secure-login/">Chap Secure Login</a> to encrypt your password. This is especially recommended if you use a lot of different computers to access WordPress, or frequently use public wireless Internet connections. Chap is another remarkably simple plugin &#8211; just install it and activate it and you&#8217;re ready to go. Note: you&#8217;ll get a warning the first time you login after installing. According the plugin developers, this is to be expected.</p>
<p><strong>Login Lockdown</strong></p>
<p>Finally, we&#8217;ll want to protect against brute force or dictionary attacks. In an out of the box WordPress installation, users can attempt and fail to login an infinite number of times. This means someone could try thousands of password combinations until they got the right one. <a href="http://wordpress.org/extend/plugins/login-lockdown/">Login Lockdown</a> will ban users from IP addresses that have tried and failed to login too many times.</p>
<p>Install the plugin and click &#8220;Login Lockdown&#8221; in the &#8220;Settings&#8221; section. You should get an options menu that looks like this:</p>
<p><img class="alignnone size-full wp-image-7991" title="screenshot-4" src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/04/screenshot-4.png?resize=345%2C450" alt="" data-recalc-dims="1" /></p>
<p>If you have a hard time typing your password correctly, you might want to set the &#8220;Max Login Retriess&#8221; a little higher.</p>
<p>I also recommend using the &#8220;Mask Login Errors&#8221; option. Normally, if a user types an incorrect username WordPress will return an invalid user name error. But if the user types a correct username but an incorrect password, WordPress will return an invalid password error. This gives someone trying to crack your password an extra hint as to whether they at least have the right username. If you use the &#8220;Mask Login Errors&#8221; option, WordPress will return a generic &#8220;username or password is incorrect&#8221; error instead.</p>
<p><strong>Ask Apache</strong></p>
<p>Many people swear by <a href="http://wordpress.org/extend/plugins/askapache-password-protect/">AskApache Password Protect</a>. However, I have not been able to get it to work with my host. Your mileage may vary. If I understand it correctly, this plugin adds an additional password to the /wp-admin directory. If you allow open registrations and have lot of users logging in, you might not want to use this plugin.</p>
<p><strong>Conclusion</strong></p>
<p>There&#8217;s still much more you can do, such as using .htaccess to protect directories, moving core WordPress files, and monitoring for exploits. Those are things we&#8217;ll have to cover in the future. If you have need to harden things further now, please see the <a href="http://codex.wordpress.org/Hardening_WordPress">Hardening WordPress Codex entry</a>. Remember no (usable) site will ever be completely secure, but if you&#8217;ve installed the plugins above your chances of getting hacked will be greatly reduced.</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/04/27/more-plugins-for-securing-your-wordpress-install/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Backing up your WordPress database with WP-DB-Backup</title>
		<link>http://weblogtoolscollection.com/archives/2010/04/21/backing-up-your-wordpress-database-with-wp-db-backup/</link>
		<comments>http://weblogtoolscollection.com/archives/2010/04/21/backing-up-your-wordpress-database-with-wp-db-backup/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 12:05:10 +0000</pubDate>
		<dc:creator>Klint Finley</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[Wordpress for Beginners]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[backup]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=7963</guid>
		<description><![CDATA[I emphasized the importance of backing up in my basic security tutorial, but I discovered all of the backup tutorials I found were out of date. So here&#8217;s a tutorial on backing up your WordPress database with the terrific WP-DB-Backup plugin. The great thing about this plugin is that you can have it automatically send you backups by e-mail that you can save both to your local computer and optionally store in your Gmail or other web mail account and an additional off-site backup. This tutorial assumes you already know how to install plugins. This tutorial should be forward-compatible with WordPress 3.0 1. Install WP-DB-Backup by Austin Matzko 2. Mouse over Tools so that the down arrow appears 3. Click the down arrow 4. Click Backup 5. You&#8217;ll see something like this: On the left are the default database tables included with WordPress. All of these are included every time [...]]]></description>
				<content:encoded><![CDATA[<p>I emphasized the importance of backing up in <a href="http://weblogtoolscollection.com/archives/2010/04/15/how-to-improve-basic-security-on-a-fresh-wordpress-install/">my basic security tutorial</a>, but I discovered all of the backup tutorials I found were out of date. So here&#8217;s a tutorial on backing up your WordPress database with the terrific <a href="http://wordpress.org/extend/plugins/wp-db-backup/">WP-DB-Backup plugin</a>. The great thing about this plugin is that you can have it automatically send you backups by e-mail that you can save both to your local computer and optionally store in your Gmail or other web mail account and an additional off-site backup.</p>
<p>This tutorial assumes you already know how to install plugins.</p>
<p>This tutorial should be forward-compatible with WordPress 3.0</p>
<p><span id="more-7963"></span></p>
<p>1. Install WP-DB-Backup by Austin Matzko</p>
<p>2. Mouse over Tools so that the down arrow appears</p>
<p><img class="alignnone size-full wp-image-7964" title="backup1" src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/04/backup1.jpg?resize=154%2C237" alt="" data-recalc-dims="1" /></p>
<p>3. Click the down arrow</p>
<p>4. Click Backup</p>
<p>5. You&#8217;ll see something like this:</p>
<p><img class="alignnone size-full wp-image-7965" title="backup2" src="http://i1.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/04/backup2.jpg?resize=500%2C170" alt="" data-recalc-dims="1" /></p>
<p>On the left are the default database tables included with WordPress. All of these are included every time you backup. The only thing you have to decide here is whether to exclude spam comments from being backed up (I recommend this) and whether to exclude post revisions (I recommend excluding these too, unless you have a specific reason for keeping revisions).</p>
<p>On the right is a list of additional database tables, most of which were probably created by plugins. There&#8217;s also a table called that will end with the name &#8220;commentmeta&#8221; &#8211; this can be used by plugins.</p>
<p>If your plugins have created a lot of data that you would like to save, or you&#8217;ve spent a lot of time configuring particular plugins, you&#8217;ll want to backup these tables. Otherwise, you can keep your database backups smaller by not checking them.</p>
<p>7. Next we see the Backup Option. There are three choices here:</p>
<p>A. Save to the server</p>
<p>This will save a backup of your database as a file on your web server. I don&#8217;t recommend this.</p>
<p>B. Download to your computer.</p>
<p>This will create a database backup file that you can save to your local computer.</p>
<p>C. Email backup to:</p>
<p>This allows you to send a copy of the backup to any e-mail address you&#8217;d like.</p>
<p>8. Let&#8217;s go ahead and download a copy to our hard drives now.</p>
<p>Check options you want in the Tables section then click &#8220;Backup now!&#8221;</p>
<p>You should see a progress bar, and when that&#8217;s done your browser will prompt you to save the file. You can save this file wherever you&#8217;d like.</p>
<p>9. There&#8217;s another section called &#8220;Scheduled Backup.&#8221; This is where this program gets really great.</p>
<p>Here we can schedule a backup to be e-mailed to a particular e-mail address however often we&#8217;d like. I recommend checking selecting &#8220;Once Daily.&#8221;</p>
<p>10. On the right, you&#8217;ll see that list of optional tables again. Check the ones you want to backup every time the backup runs.</p>
<p><img class="alignnone size-full wp-image-7968" title="backup3" src="http://i0.wp.com/weblogtoolscollection.com/wp-content/uploads/2010/04/backup31.jpg?resize=500%2C301" alt="" data-recalc-dims="1" /></p>
<p>11. Enter the e-mail address you want the backups delivered to in the &#8220;Email backup to:&#8221; field.</p>
<p>12. Click &#8220;Schedule backup.&#8221;</p>
<p>13. You should now get a backup file as an e-mail attachment every day. You should save these attachments to your local computer. If you&#8217;re using Gmail or another web mail host that has a lot of storage space, you might want to leave your databases on their server as an additional off-site backup. Be aware that that&#8217;s an additional security risk &#8211; if your e-mail account is ever compromised, the would have access to all of your database backups.</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2010/04/21/backing-up-your-wordpress-database-with-wp-db-backup/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  weblogtoolscollection.com/archives/category/how-to/feed/ ) in 1.49412 seconds, on May 18th, 2013 at 8:03 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 18th, 2013 at 9:03 pm UTC -->