Archive for August, 2009

Weblog Tools Collection: Actions and Filters and Classes, Oh My!

Ever wondered how you can manipulate WordPress filters and actions that are defined inside a PHP class?

I did! I was working on a project recently that needed a plugin. The only problem was that the plugin was inserting some unnecessary cruft into the header of my theme. So, I figured I’d just use the remove_filter function WordPress provides… right?

Hold on a second! It’s not working!? But I put in the function name just how the codex explains it:

remove_filter('wp_head', 'the_crufty_function');

Why would it not work? Time to do some troubleshooting… So, I opened up the main plugin PHP file in my code editor and began to look around. What’s this? It’s a class! Hmm… But why should that make a difference?

It seems that WordPress requires a special reference to the function if it is defined inside a class. If you, the reader, are at all familiar with PHP classes then you probably know that you can usually access a class’s functions like this:

$the_class_initiator_variable->some_function();

So, lets give that a try:

remove_filter('wp_head', $the_crufty_class->the_crufty_function);

Still nothing… Oh boy… What do I do now? I guess we’ll try some Googling…

…Hmm…

…Not finding much…

Well… after much searching and trying different things I finally came upon this:

remove_filter('wp_head', array(&$the_crufty_class, 'the_crufty_function'));

It works! Wonderful!

You take the class initiator variable and the name of the function and put it in an array. Simple as that!

Note: No, that ampersand is not a typo! It sets up a reference to the original variable instead of copying it’s value. You’d be surprised how many people don’t know what the ampersand does in PHP. I didn’t know for the longest time.

Also, because the remove_filter and remove_action functions are so similar this method applies to both.

There you have it! Just a quick little tip regarding an issue that doesn’t seem to be very well documented. I’m sure some of the experts out there already know of this but, I didn’t. I’m willing to assume there are some people out there like me who are racking their brains over this very issue.

Hope it helps!

Wednesday, August 26th, 2009

Weblog Tools Collection: WordPress Theme Releases for 08/26

Hot News Today

Hot News Today

Three columns, widget ready theme ready for WordPress 2.8. Also check out Ads Minded.

Khaki

Khaki

It’s a 3 Column Split, widget-ready theme in dark-hues of green and khaki. Fixed width featuring Custom Archives, Sitemap and Full-Width No Sidebars page templates. There is an options page for setting the text in the Info Text Box.

Shine

Shine

A clean dark three column theme, built with customization in mind. SEO friendly and semantically built using the Carrington Framework.

Broken Heart Crane

Broken Heart Crane

Two columns, fluid width, widget ready theme with nested comments

Are you a WordPress theme author? Submit your theme to get listed in these release posts.

Wednesday, August 26th, 2009

Dougal Campbell: W3 Total Cache Plugin

There’s a new WordPress cache plugin in town, and it’s called W3 Total Cache. This plugin is one of the contestants in the 2009 Weblog Tools Collection Plugin Competition.

The W3 Total Cache plugin (W3TC for short) is an advanced cache plugin, and you can only have one of those on your site at once. So if you’re currently using WP Super Cache, you’ll have to disable that first before enabling W3TC. [side note: I tried to find a good link for information about the advanced-cache functionality, but I came up empty. we need a Codex page for that]

If you’ve used WP Super Cache before, you’re probably wondering what’s different about W3 Total Cache? Everything. WP Super Cache is a static disk cache. It creates files  on disk with a certain lifespan, and gets the web server to use those instead of firing off PHP to generate pages on-the-fly, thus saving CPU and time. So, on the bright side, it saves your server a lot of work. On the down side, you lose some of the dynamic nature of your site. The entire page will remain cached as-is until the cached version expires, or until it is forced to regenerate (because you update the page, a comment is added, etc).

W3 Total Cache works differently. It utilizes multiple techniques to improve performance, including: object and query caching; page caching; HTML, CSS, and javascript minification; gzip compression; CDN (Content Distribution Network) support; and browser caching via ETags. Currently, the caching is based on APC and/or memcache. I’ve suggested that they add XCache, as well.

Page caching is what WP Super Cache does. Except that W3TC uses your in-memory cache (APC or memcache). Memory being faster than disk, you’ll typically see an improvement when serving pages cached in this way. This does mean, however, that you want to have a decent amount of memory reserved for your cache. The W3TC docs suggest dedicating at least 128M with APC. If your server is strapped for RAM, or you can’t set up a dedicated memcache server, this plugin might not be for you.

Object and query caching means that the results of MySQL database queries are saved in the memory cache for later use. For example, when someone views your page normally, WordPress (or any other dynamic web application) will fetch things like your category list, your blogroll, and other information from the database, build the HTML page for the browser, and then promptly discard all of the database results when it finishes. The next time someone views the page, it runs all those same database queries again, even if nothing has changed, wasting CPU cycles and time. W3 Total Cache will save the results of these queries and other objects that WordPress builds in the memory cache for re-use.

Minification is the technique of stripping out unneeded information from your HTML, CSS, and javascript. This can include extra whitespace and comments. Depending on how your original files are formatted, this can result in fairly significant savings (probably 10-20% in many cases). The smaller the files, the faster they can be delivered to the browser. This technique also includes combining multiple CSS or javascript files into a single request. Normally, each CSS and javascript file linked to from your theme requires your browser to make a separate network connection to fetch it (a relatively slow operation). By combining these, the plugin reduces the number of network connections needed.

Gzip compression is a binary compression like you see with ZIP files. This is a more advanced method of converting a large file into a smaller one. Again, meaning you can serve it up to the browser faster. Delivering content to the browser as fast as possible is important, because the browser speed perception of the user can often determine whether or not they stick around to read that content.

Support for CDNs (Content Distribution Networks) means that you can host static files like images, CSS, and javascript on a seperate server. Typically, CDNs are optimized for static content. Some CDNs are also geographically distributed, and automatically route the requests to the nearest/fastest location. Even if you don’t use an external CDN (like Akamai, Amazon S3, or Voxel), you can set up your own server optimized for static content, and use that.

ETag support is currently supported in WordPress for feeds (I added that to the core myself, way-back-when). This is a feature of the HTTP specs designed to let servers and browsers coordinate caching. Basically, the first time a browser requests a page from a server, the server will generate an ‘ETag’ header with a unique identifier based on the last time the page was modified. The browser can save a local copy of the page in its cache, along with the ETag. The next time the browser requests the same page, it can send the ETag back to the server. If the ETag on the server-side hasn’t changed (the page hasn’t been modified), then the server returns a “304 Not Modified” response, which tells the browser to just display its cached copy of the page. W3 Total Cache extends this support to other WordPress-generated pages, not just feeds.

I’ve got the plugin running on this server currently. The only problem I’ve run into was that with the HTML minification “line break removal” option turned on, it caused my reinvigorate.net analytics script to fail for some reason. I haven’t fully explored all the options yet, and I don’t have as much memory allocated to memcached as I’d like, but it seems to be working pretty well so far. I should be able to judge more after it’s been running for a few days.

You can enable various optimizations independently of each other, so there is a lot of flexibility for utilizing various caching techniques while still allowing some things to remain dynamic. I’m curious to hear from others who try this plugin out, and see what they think about the balance between performance improvements and dynamic elements.

W3 Total Cache Plugin

Wednesday, August 26th, 2009

Publisher Blog: Brazil’s Culture Ministry Selects BuddyPress

Thanks Cátia Kitahara for lettings us know about a new BuddyPress site which is being used to enable and foster debate about various aspects of today’s digital life in Brazil. Built by the Brazilian Culture Ministry, the beta site is now live at culturadigital.br:
Brazil-Culture-Ministry-BuddyPress

The site describes itself as “an open public space destined to democratically create and build a public policy of digital culture, integrating citizens, government institutions, state companies, civil society and the market.” Making use of all the “Facebook-in-a-box” features of BuddyPress, this site is off to a great start and could be a model for other organizations and companies looking to build this kind of community engagement and interaction.

[Visit culturadigital.br ]

Tuesday, August 25th, 2009

Matt: Blog Mothership

Your Blog is Your Mothership.

Monday, August 24th, 2009

Weblog Tools Collection: 21 Great Plugins for Manage Multi-Author Blogs

21 Great Plugins to Manage Multi-Author Blogs Efficiently: This is an interesting collection of plugins to manage multi-author blogs and add extra visibility to your co-authors. Weblog Tools Collection is a multi-author blog that is put together by highly dedicated and talented authors in various parts of the planet. We collect and put together news, information and articles throughout a 24 hour period and are probably watching over the blog and the comments in one way or another. We rarely ever meet face to face and tend to communicate via IM, email and a very rare phone call from time to time.

Some of the plugins mentioned in this list are popular such as Role Manager, which is very useful in and of itself. However, there are others that sparked immediate interest in my. The ability to add co-authors to a post would be quite cool, as would the ability to add quick information about the particular author to the various posts. Many of the larger multi-author blogs such as Mashable and TechCrunch already do this (I am not sure how, but I assume there are some custom plugins involved) and now you can do the same.

Speaking of multiple authors, are you a passionate plugin picker and a theme tamer? If you are not afraid to speak to thousands of people in an instant, have confidence in your writing abilities and are interested in breaking into the blogging world with aplomb, we would like to hear from you. Tell us what you will do to make this blog better using the Contact form above.

Thanks Thrive Creative Group via WeblogToolTips

Monday, August 24th, 2009

BuddyPress: The New BuddyPress Theme Architecture

For the next version of BuddyPress there has been a fair amount of re-factoring work done. We’ve listened to your feedback from version 1.0 and made a number of internal changes that are going to make your lives as plugin developers and theme designers easier.

One of the biggest changes in BuddyPress 1.1 will be the way themes are built.

In version 1.0 BuddyPress required two themes to function. The first theme was a “WordPress home” theme that handled the blog and front page of your site. It was essentially a standard WordPress theme. The second was a “BuddyPress member” theme that would handle the display of pages generated by BuddyPress. There were many reasons for handling themes this way but as time passed it was evident theming in this fashion was hurting the majority to help the minority.

In BuddyPress 1.1 there will be one single theme to handle everything. BuddyPress will ship with a theme framework that acts as a parent theme. The default theme will be a child theme based on this framework and contain only images and css. Building a new BuddyPress theme will be as simple as creating a child theme based on the framework. If you’re not familiar with child themes a quick google search will bring up lots of useful information.

This approach brings big benefits. When building a new theme you don’t need to re-create every template file. You can override specific template files where needed. Most importantly though, your theme will update automatically with the latest functionality when the framework theme is updated.

If you’ve already created a BuddyPress theme using the old system don’t worry, these themes will continue to work for at least the next couple of versions. You should find it fairly simple to convert your themes to the new system. The old default themes only took a few hours to convert over.

Using the framework theme is of course, just an option. You can still go ahead and create your own frameworks or mashups with a completely unique style or structure. As with WordPress themes, the possibilities are infinite.

If you’d like to get started with the new framework, I’d recommend running the trunk version of BuddyPress. The best way is to fetch this via Subversion, or you can download a zip of the current snapshot using the link at the bottom of this Trac browser page.

BuddyPress 1.1 is on track for a September release.

Monday, August 24th, 2009

Alex King: The Carrington Framework Q&A Part II

I’ve published another Q&A on the Carrington Framework on the Carrington web site. This one covers some additional questions I saw popping up in the forums and comments.

It’s great to see folks being able to get into Carrington a little more of late, I guess the additional documentation has been helpful.

Also, remember to submit your Carrington powered sites to the Showcase once they go live, I’m looking forward to seeing what people have built.

Monday, August 24th, 2009

Weblog Tools Collection: WordPress Plugin Releases for 08/24

New Plugins

Super Cat Lister

SuperCatLister greatly extends the abilities of Wordpress as a content management system. It does this by giving site designers the ability to insert links or content from posts in specified categories into other posts.

Testimonials Manager

Testimonials Manager is a WordPress plugin that allows you to manage and display testimonials for your blog, product or service. It can be used to build your portfolio or to encourage readers to subscribe / buy your products.

Search API

This plugin creates a basis for a new search engine to replace the simple input box search currently employed. The plugin creates an API to support advanced search capabilities such as boolean search, multiple content searches (posts, tags, pages, authors and any available metadata) and flags (finding posts with A string in category C) through additional plugins.

Contest Burner

The Contest Burner Viral Marketing Wordpress plugin will integrate the use of Twitter to start and manage your own online marketing campaign.

WP-PreventCopyBlogs

Track visitors who try to copy your content

Updated Plugins

Last Modified Footer

The Last Modified Footer plugin generates a message stating the date / time the content being viewed was last modified. This information can be placed in the site footer, or elsewhere on the page.

PhotoQ

PhotoQ is a plugin for photo enthusiasts or anyone who has a lot of pictures to post. It turns your WordPress blog into a full featured photoblog and starting with this newest version supports virtually any theme there is. The plugin is aimed at automating publishing of photos as much as possible.

SpamTask

SpamTask is a spam protection plugin for WordPress, created to prevent comment spam in the most efficient way. The blog spam filter is known to catch all spam robots.

Ezy Nav Menu

Makes use of WP’s built in ‘Edit Links’ to create and manage a website navigation menu that can be displayed using a custom template tag.

Store Locator

The Store Locator plugin empowers web developers & web site owners to easily manage and display any set of important stores, products, or other locations on their website in an easily searchable manner. Uses Google Maps.

K2 Style Switcher

This plugin is the K2 equivalent of a theme switcher. It allows your visitors to re-skin your site from a list of K2 styles that you select.

Monday, August 24th, 2009

Weblog Tools Collection: WordPress Threaded Comments the Easy Way

Comments are the incentives you get for writing a post and if you write good ones you are bound to get 100s and 1000s of comments on your posts.

But wait not every comment on your blog is directly related to the post itself, there are times when commentators respond to other commentators, in short we call that a discussion.

Flashback to WordPress 2.7, there was a new introduction in the form of threaded comments, this was done so that people on your blog can comment and respond to each other and communicate and discuss.

Coming back to future, it has been so long and many users still do not have threaded comments on their blogs.

Reason 1: Most of the WordPress users are not programmers and use themes created by others, so unless they use a theme that has support for threaded comments they don’t make use of that feature.

Reason 2: Many users have knowledge to program and edit but are just plain lazy (example me) and do not update their themes to add threaded comments support.

Now how does one implement threaded comments in WordPress when we fall into the above two categories? Pretty simple, by using the power that WordPress itself provides users with, in the form of extensibility, in short with a WordPress plugin.

WordPress Thread Comment is a excellent choice for adding threaded comments to your blog without having to have any coding skills, once you install the plugin it does everything for you, you do not even have to edit your themes to add threaded comment support on your blog.

Another option is to use Brian’s Threaded Comments which was actually the first one to add threaded comments to WordPress blog, however it still requires users to do a bit of theme changes.

Of course there are other options available in the form of third party services, like, take for instance Automattic’s own Intense Debate and Disqus, these services make commenting and discussion more easier.

Now do you have an excuse for not having threaded comments on your blog? BTW do you use threaded comments? If not why, if yes how? Don’t stop short of just reading this we have threaded comments enabled so discuss as much you wish -) .

I would be thankful if you take part in this small poll with regards to threaded comments.

You can find more options for threaded comments by visiting this search on WordPress extend.

Sunday, August 23rd, 2009