Category archive: wordpress

May 2, 2007

WordPress plugin: x-y of z 1

You can find it on the plugins download page now. This basically just gives you a function that will print out a snippet of text like “Viewing 1-10 of 423 posts” based on the contents of the page. Hopefully this is marginally useful to someone out there.

September 24, 2006

So I’ve been doing some work on the long-neglected Fontleech and today found myself removing over .25 million spam comments. That sounds herculean, but it was actually pretty easy.

The WordPress frontend pulls the comment count for each post from the ‘comment_count’ field in the wp_posts table. obviously that doesn’t get updated when you manually delete spam directly from the database, so here’s a simple ruby script that will update that for you (just define your db variables):

#!/usr/bin/ruby
require 'mysql'
 
db = Mysql.real_connect(host, user, pass, dbname)
ids = db.query("SELECT `ID` FROM `wp_posts` WHERE 1")
 
ids.each_hash do |post|
  id = post['ID']
  num = 0
  comments = db.query("SELECT COUNT(1) FROM `wp_comments` WHERE `comment_post_ID`='#{id}' AND `comment_approved`='1';")
  comments.each {|x| num = x[0]}
  up = db.query("UPDATE `wp_posts` SET `comment_count`='#{num}' WHERE `ID`='#{id}';")
end
June 7, 2006

Category Sort plugin 16

If you’re a blogger with OCD you might be interested in my new Category Sort plugin. It simply alphabetizes the category list that gets printed out when the the_category() function is called. Wordpress sorts this list according to category ID, which has always seemed completely random and bugged the hell out of me. Since I’m using this plugin, the categories for this post are “plugins, wordpress” instead of “wordpress, plugins”. This is not that exciting, but it looks nicer. Download it at the plugin page.

May 18, 2006

Snap blog launches 10

The Snap blog has launched and pretty much all hell has broken loose. Anyone who signs up can post to the blog with their “launch idea” and it will automatically get posted on the front page. Then other users can vote on the best ideas, and the winner gets $5,000. How could THAT go wrong?

I wrote several plugins for the blog, and it seems like the company is excited about releasing them to the public. This is pretty much the first significant stuff I’ve done with PHP and I really got to dig around in the guts of Wordpress to add some cool features:

Simple Vote
Adds a Digg-style vote box to posts from a certain category. Only registered users can vote.

Simple Post
Allows any user to post to the blog from a watered down interface, regardless of their privileges. Crazy, right? This way we can let users post to the blog without giving them access to anything in the admin interface.

Easy Author Info
Easily grab any author’s information. For example, you could print out any author’s “About me” text like this:

echo get_easyauthor_attr($author_id, "description");

These scripts need to be cleaned up and made more configurable before they can be released, but hopefully that should be pretty soon.

April 11, 2006

You don’t care 0

But this is mostly going to be a place to host Wordpress plugins. And maybe talk about computer stuff. And maybe post pictures of my dog.