New Plugin: WP-Asides
This isn’t so much a downloadable plugin as a feature writeup. For a long time I’ve been looking for a good way to do asides in Wordpress, so I decided to start writing a plugin. The way Asides work in Wordpress, you choose a category you want to publish in a seperate column, and then exclude all the posts from that category from the home page. The best way (in 2.xx) to do this is to use the post_where and post_join filters to tack onto the main SQL query, like so:
function ea_where($query) {
global $wpdb;
if(is_home() || is_feed())
return $query . ‘ AND category_id != ‘ . get_option(‘ea_category’) . ‘ ‘;
else
return $query;
}function ea_join($query) {
global $wpdb;if(is_home() || is_feed())
return $query . ” LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) “;
else
return $query;
}
The whole WP-Asides presentation ends up looking something like this:

Every 5 seconds the old aside fades out (with a little AJAX and scriptaculous) and a new one fades in. You can check out it in action at the top of this blog’s index page.
Now, the reason I’m not releasing this as a Wordpress plugin is that it adds a nice, exclusive feature to my network of blogs, and that it’s pretty easy to make. Call a few wordpress functions, sprinkle in AJAX and scriptaculous effects, design a little CSS and imaging, and you have a cute asides solution!
WP Autoblog: A Syndication Plugin
This plugin was intended so I could aggregate some of my and my family members blogs together on my front page using an all-Wordpress solution. However, it seemed to attract spammers who abused it, which is even worse for me, because it puts “Post by XXXXX and software by me” on the bottom of every import, leading some people to believe that I am a spammer.
This software is PERMANTLY ON HOLD. Go use Feedwordpress, you vile spammers, or the recently announced WP o’ Matic. I will not provide this plugin, or anything like it, because the potential for abuse is way too high.
I am not, and I encourage you to go after anyone abusing this with a DMCA notice. You can follow these instructions, which should get the offending site removed in short order. I’ve had my own sites ripped off by people abusing this plugin, and filed dozens of DMCA notices against spammers. In the web 2.0 world, information is money, and there are far too many people–often located outside of the US–who want to rip off your work, rather than writing for themselves.
Digg Defender: A Plugin For Wordpress
An article I wrote about well-designed blogs got more than 1,200 diggs yesterday, causing an influx of some 20,000 to 30,000 new visitors, each pulling down the following page elements:
- 10 large images totalling 969,582 bytes
- CSS and JS totalling 21,655 bytes
- HTML totalling 45,492 bytes
With over a dozen files per request, and 1 MB of transfer, it’s clear that a Digg or Slashdot will overload my poor server. However, there exists a global cache system called Coral Cache which can be used in times of stress to distribute abnormal, spiky load. This will save your onsite HTML and Wordpress system from being hit every time a visitors comes through one of those high traffic sites. Since these visitors will be setting their referrer field, we can identify them, create a special cache redirect URL for them, send them there, and exit. No messy rendering needed.
Yesterday I opted for a solution with mod_rewrite and .htaccess to send traffic to Flickr and Coral Cache instead of my server. It looked like this:
# Digg Effect RewriteBase /wp/ RewriteRule ^archives/2006/04/16/top-ten-best-designed-blogs[/]? elliottback.com.nyud.net:8080/wp/?p=1351 [R,L] RewriteRule ^wp-content/uploads/2006/04/10-best-sites-01.* static.flickr.com/56/130439205_51ccaa4a21_o.jpg [R,L] [...] RewriteRule ^wp-content/uploads/2006/04/10-best-sites-10.* static.flickr.com/49/130439322_f0ba846651_o.jpg [R,L] RewriteRule ^wp-content/themes/greenmarinee/index.css elliottback.com.nyud.net:8080/wp/wp-content/themes/greenmarinee/style.css [R,L]
Making a Plugin
Clearly this won’t work for a general solution. Instead, we’ll take advantage of Wordpress’ new cache hook, which is the symlink advanced-cache.php in the wp-content folder. There’s one problem–there could already be something there. So, we’ll have to follow the following flow:
- If advanced-cache.php doesn’t exist, create it pointing to us
- If advanced-cache.php exists, create it pointing to us, and include_once() whatever it pointed to when we’re done.
Then we just redirect to a Coral Cache version of our page. This way, when your Wordpress blog gets hit by a DDOS from the popular linksites, it can respond quickly and fluidly without having to load all of your plugins, Wordpress, or even make a single mySQL database call. This will optimize the performance significantly. There’s going to be a problem if something else–say WP-Cache is installed after us, and steals our symlink, but I’ll just have Digg Defender repeat the initialization steps on every activation.
The second part will be a post_content filter that rewrites all external references in the post, such as js or images, to use Coral Cache links–but only for the Coral Cache robots. This way, Coral Cache will cache a copy of the html of a page which has been injected with Coral Cache links everywhere else. Not a single Digg user request will ever touch your website, because Coral Cache will act as a continuous buffer.
Features
- Prevents high-traffic sites from overloading your site
- Integrates Coral Cache with Wordpress
- Runs before WP loads
- Compatible with WP-Cache
- Extremely fast (benchmarks coming soon!)
Download
Version 1.0 of the plugin can be downloaded as a 4KB zip file: digg-defender.zip. It contains four files:
- digg-defender-config.php
- digg-defender-functions.php
- digg-defender-phase1.php
- digg-defender.php
These are contained in a folder called digg-defender.
Installation
Extract the folder digg-defender, copy it to your wordpress/wp-content/plugins/ folder, and activate the plugin in your admin interface. It will spit out numerous textual warnings and errors if permissions are incorrectly set. Note that if WP-Cache is also installed, only raw pages will be buffered, and not their contents, because WP-Cache will have already cached the page.
Support
If you encounter any bugs, or can suggest a website I add to the hitlist, please leave a comment. Currently the plugin recognizes the following sites: digg.com, slashdot.com, slashdot.org, fark.com, somethingawful.com, kuro5hin.org, engadget.com, boingboing.net, and del.icio.us. I am testing this on my main production blog as we speak, so if there are problems I will probably encounter them first. Update: Please note that Coral Cache is hit/miss and can be slow sometimes to load. That’s not my fault–reload or wait for it to finish loading.
Update
A little update fixes a couple of possible typos / bugs in servers with base_dir restrictions.