WordPress 101: Caching plugin-ins

December 4th, 2010 1 comment


You may have heard of them before, but do you know what they do? Or why you might want one? The world of WordPress plugins can be quite a confusing and cluttered space. One realm of plugins, however, should not be foreign to you, especially if your site get’s quite a few hits, ends up on Digg, or get’s into the Reddit realm. These plugins are ‘caching’ pulgins. Not sure what caching is?

a cache … is a component that transparently stores data so that future requests for that data can be served faster.
-via Wikipedia.org

Essentially, ‘cache’ is a holding place for data that’s requested a lot. How can this make your WordPress site faster you might ask? Well, every time a visitor lands on your website that’s using WordPress, quite a bit is happening on the backend. A typical theme will request things like your site’s Title, Tagline, Browser Title, and other items that will hardly change. Each one of these requests comes from your database. Every time WordPress has to go to your database, that is a bottle neck. We would like as few things as possible to come from the database. What a caching plugin will do is find the pages that are being requested most often, and store them as a static file on the server, reducing the load on the server to 1 page, plus the images needed, instead of making those requests from the database. Continue reading “WordPress 101: Caching plugin-ins” »

Dropbox CDN Updates to come

December 2nd, 2010 5 comments

Some of you may have read this post over at Lifehacker about the bandwidth limitations that Dropbox puts on the public folder a user shares. Well, since my Dropbox CDN plugin uses the public folder of your Dropbox account, I’m going to be including a feature that will seamlessly check to make sure that you haven’t hit your Dropbox limit before using the plugin settings.

I hope to have this feature released sometime this weekend. I’ll keep you posted.

Custom Mystique Login updated

November 21st, 2010 2 comments

I updated the post about how to create a custom theme for the DigitalNature Mystique theme for WordPess. It’s been updated to reflect new versions of WordPress and the Mystique theme. Let me know in the post comments if you have any other issues with this. Here’s a snapshot of what it looks like.

A Preview of the Login Screen

Visit the original post
Get the Mystique theme

Categories: Updates Tags: , , ,

WordPress Dev 101: Replacing post content in-line

November 18th, 2010 No comments

Something I did recently when I updated the Better AdSense Targeting plugin, was create the ability to allow users to specify certain sections of each post that Google should ignore when determining what ads to display. I did this by using the str_replace() function in PHP and a little thing called ‘add_filter’ from the WordPress hooks. It’s rather simple and looks a little like the following.

First let’s think of something we might want to replace. Let’s say we want to make every instance of the string ‘[my other site]‘ turn into a link to your another website you run. Typically you’d need to code that out or use all the tools in the editing screen to do this, but instead, we cause use the power of str_replace() to do that for us.

We’ll need to include this fix in a plugin or the functions.php of your theme. First let’s make sure we’re adding the ‘filter’ on the content that we are taking from the post loop.

add_filter( 'the_content', 'url_replace' );

This line simply runs the function url_replace() whenever the_content() is run.

Next we’ll need to create the actual function that does the replacing:

function url_replace($content='') {
return str_replace( '[my other site]', '<a href="http://myothersite.com">My Other Site</a>', $content);
}

A little explanation here, we are running the function and are looking for instances of ‘[my other site]‘ and replacing it with the full HTML anchor tag and text in the string $content.

If you are wanting to replace multiple words or phrases you’ll need to do something like the following:

function multi_replace($content='') {
$content = str_replace( '[my other site]', '<a href="http://myothersite.com">My Other Site</a>', $content);
$content = str_replace( '[WordPress]', '<a href="http://www.wordpress.org/">WordPress.org</a>', $content);

return $content;
}

I don’t think I have to explain much here now, but we’re simply replacing any instance of ‘[my other site]‘ with the full HTML link and we are also looking for ‘[WordPress]‘ and making it link to WordPress.org. Easy enough, it creates links for you quickly, and allows you to focus more on writing. I find it common practice to put things like [WordPress] in and then later look for these strings in my drafts and replace them with links. Anytime I can avoid breaking my writing flow, I do, and shorthand notes are the way to go.

There you have it, you’ve successfully replaced content. Where this is useful is if you wish to include specific code wherever need be. You don’t have to replace this text with visible text. For instance, my AdSense Plugin replaces the string ‘‘ and ‘‘ with the proper HTML that I need to use to have Google AdSense ignore the content between these tags when selecting ads.

In this practice I used the str_replace() function, which is great for unique strings like [my other site] and [WordPress] however it can cause some issues when simply replacing normal text by including parts of other words as long as they meet the requirements of the replacement. For example, the word ‘and’ would be replaced in the words ‘brand‘, ‘sand‘, or ‘stand‘. If you are looking for a more indepth and intensive replace you might want to try using preg_replace() which uses Regular Expressions for it’s replacement rules

For more information on WordPress development check out the other posts in my ‘WordPress Dev 101′ series:

Happy Coding!

Categories: WordPress Tags: , , ,

Better AdSense Targeting 1.0 Released

November 17th, 2010

I’ve updated the Better AdSense Targeting plugin to allow users to specify in-line post content that should be ignored using the and tags. An example would be like the following:

I would like this to not be ignored content. I think it’s relevant to my topic.

This however isn’t necessarily relevant, is an analogy, or contains some keywords I’d rather not have used when determining my ads

But this I would like to have included…

What the plugin will do is replace the tags with the proper HTML to notify Google’s AdSense to ignore it. The rest of the plugin works as it has been, this is the only update but will allow users to fine tune their ad results.

It’s available now via WordPress.org or your WordPress Admin area. Comments are closed on this post, however if you have any issues please comment over at the Better AdSense Targeting plugin page.

Categories: Updates Tags: , ,