wordpress

Dang addslashes() And GPC Magic Quotes

Somewhere in the WordPress code extra slashes are being added to my query terms.

I’ve turned GPC magic quotes off via a php_value magic_quotes_gpc 0 directive in the .htaccess file (we have far too much legacy code that nobody wants to touch to turn it off site-wide). And I know my code is doing one run of addslashes(), but where are the other two sets of slashes coming from?

Two Events, Two Coasts

Matt Mullenweg announced WordCamp in San Francisco, then ten days later Abby announced the LibraryThing cookout in Portland (Maine). Both are set for August 5. The LibraryThing event promises free burgers and potato salad, while WordCamp attendees will enjoy both free BBQ and free t-shirts. I’d like to go to both, but rather than have to make some decision about which one I’d most like to go to, I’m leaning on the fact that I’d already bought my flight to SFO when the LT event was announced.

Anyway, it’s casual Friday here, so this post is really just an excuse to (again) link to the funniest BBQ-related video I’ve seen in a while.

WordCamp

As noted here, I’m going to WordCamp in SFO in early August.

Matt describes it as a BarCamp-style event (where “’BarCamp-style’ is a code phrase for ‘last minute’”) with “a full day of both user and developer discussion.” I’m just going for the free t-shirt, of course, but I can imagine a number of folks will get a good value out of the sessions and discussions that will likely run, especially all the developer stuff.

Also, if you’ve got some suggestions about what else I should be doing in San Fran, leave a comment or contact me with any suggestions.

bsuite Bug Fixes (release b2v6)

Contentsbsuite FeaturesFixed/Changed/AddedInstallationUpgradingCommandsOptionsTag SupportUsing bsuite FunctionsKnown BugsUpdate: bugfix release b2v7 available. It’s been a while since I released a new version of bsuite, my multi-purpose WordPress plugin. I’d been hoping to finish up a series of new features, but those have been delayed and this is mostly just a collection of bugfixes. This update is recommended […] » about 500 words

WordPress Baseline Changes To Support WPopac

I’ve whittled things down to the point where the only baseline change from WordPress 2.0.2 is in the next_posts_link function of the wp-includes/template-functions-links.php file. The change is necessary because WPopac rewrites the SQL search queries in a way that’s incompatible with a piece of this function, but necessary for performance reasons.

Here’s how my version reads:

`

function next_posts_link($label='Next Page »', $max_page=0) {
	global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages;
	if ( !$max_page ) {
			if ( isset($max_num_pages) ) {
				$max_page = $max_num_pages;
			} else {
				preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);

				// added April 5 2006 by Casey Bisson to support WPopac
				// necessary because the preg_match above fails with some queries
				if(!$fromwhere)
					$fromwhere = $wpdb->posts;
				
				// changed April 5 2006 by Casey Bisson to speed the query by eliminating
				// the slow DISTINCT clause
				//$numposts = $wpdb->get_var(“SELECT COUNT(DISTINCT ID) FROM $fromwhere”);
				$numposts = $wpdb->get_var(“SELECT COUNT(*) FROM $fromwhere”);
				$max_page = $max_num_pages = ceil($numposts / $posts_per_page);
			}
	}
	if ( !$paged )
		$paged = 1;
	$nextpage = intval($paged) + 1;
	if ( (! is_single()) && (empty($paged) || $nextpage < = $max_page) ) {
		echo '<a href=“';
		next_posts($max_page);
		echo '”>'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
	}
}

`

Where’d All My Rewrite Rules Go?

Between WordPress 1.x and 2.x there was a big change to the way rewrite rules are handled.

In the old days, everything got written out to a <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule">.htaccess</a> file. Every condition, every form of permalink could be found there, and I had some comfort knowing I could see and mess with it all. I was a bit surprised to find that with 2.0.2, WP writes out a sparse file that has only one significant rule. Something that looks like this:

RewriteRule . /blog/index.php [L]

That one line takes everything in your request URL and passes it through to index.php for processing. The beauty of this is that WP doesn’t need to write to the file system with every change to the permalink structure (which used to include every new “page” added or renamed).

The only downside to this is that you can no longer expect a $_REQUEST array full of all the query terms your plugin might use. Instead you’ll have to use the <a href="http://codex.wordpress.org/Function_Reference/WP_Query">$wp_query</a> object. All of this was probably mentioned in the API docs before I built a bunch of dependancies on $_REQUEST, but it was easy enough to fix.

More bsuite Hacking

Update: bugfix release b2v6 available. Some conversations with Chow Kah Soon, who’s site is full of diversions from work , finally convinced encouraged me to solve some small problems that were giving him big trouble. Chow Kah Soon is in the lucky, but rare, position of having over 20,000 unique daily visitors to his site, […] » about 400 words

bsuite Feature: User Contributed Tags

Ross Singer gets the prize for submitting the first reader contributed tag, the latest feature in bsuite.

There are arguments about whether user-contributed tags are useful or even valid, or whether they should be stored in my site or aggregated at places like del.ici.ous. But who’s to worry about such questions? Who’s to worry when you can put together the work already done to support author’s tags with WordPress’s pretty good comment system and get user contributed tag support with just a few extra lines of code? Who’s to worry when we can try it and see what comes of it?

It’s all managed using the same tools we use to approve, moderate, and edit comments, which also means the spam filtering that works for comments works for contributed tags too. And because bsuite is already part of WPopac, that means it gains the new tagging features too (well, it will soon).

WPopac: An OPAC 2.0 Testbed

First things first, this thing probably needs a better name, but I’m not up to the task. Got ideas? Post in the comments. For the rest of this, let’s just pretend it’s an interview. What is WPopac? It’s an OPAC — a library catalog, for my readers outside libraries — inside the framework of WordPress, […] » about 1000 words

WordPress Plugin: Add To del.icio.us

I’m not running it here (only because I’m too lazy), but I was happy to find Arne Brachold’s Del.icio.us – Bookmark this! WordPress Plugin. It puts a sweet Bookmark on del.icio.us link whereever you call this function: <?php dbt_getLinkTag(“Bookmark on del.icio.us”); ?>

Arne also wrote the Google sitemap plugin I use (though it turns out I’m a few versions behind).

WordPress 2.0 & bsuite

Update: bugfix release b2v6 available.

WordPress 2.0 is out and available for download now. I don’t know how the development team did it — I mean with the holidays and all — but here it is. And now I have to admit that I haven’t even played with the betas, so I’ve got no clue how bsuite works with the big 2.0. For all I know it works just fine, or it drops all your tables and sends your browser history to your mother, so please take caution.

But WP2 has a lot of things I want too, so I’ll be checking things out and making any necessary changes to bsuite as soon as possible.

bsuite Bug Fixes (release b2v3)

ContentsFixedInstallationbsuite FeaturesI’ve fixed another bug in bsuite b2, my multi-purpose plugin. This update is recommended for all bsuite users. Fixed Previous versions would throw errors at the bottom of the page when the http referrer info included search words from a recognized search engine.  Installation Follow the directions for the bsuite b2 release. The download […] » about 300 words

bsuite Bug Fixes (release b2b)

ContentsFixesInstallationbsuite FeaturesI’ve fixed a couple bugs in bsuite b2, released last week. Fixes A bug with search word highlighting that caused it to litter the display in some cases.  A silly mistake of mine that cause a mysql error for some users. Installation Follow the directions for the bsuite b2 release. The download link there […] » about 300 words

bsuite Features: The Photo Spread

bsuite highlights the search words used to find blog posts in Google and other search engines, and uses those search terms to recommend other related posts at your WordPress site. — – — bsuite uses the tags of one post to recommend related posts in your WordPress blog. — – — bsuite includes an easy […] » about 100 words

bsuite WordPress Plugin (b2 release)

Contentsbsuite FeaturesChangesInstallationOptionsTag SupportUsing bsuite FunctionsKnown BugsThe first thing we all have to agree on is that bsuite is the replacement for bstat. The name change reflects that fact that the plugin is doing a lot more than simply track page loads. The most exciting new feature is a module I can’t help but call bsuggestive. […] » about 1000 words

bsuggestive and bsuite Tag Support

bsuite, the follow-up to bstat, now includes a module called “bsuggestive” that recommends related posts based on the current post’s tags or alternate posts based on your search words when you arrive from a recognized search engine. That is, bsuggestive does two neat things: First, visitors will see a section in each post with links […] » about 300 words

Library Catalogs Should Be Like WordPress

Library catalogs should be be like WordPress. That is, every entry should support comments, trackbacks, and pingbacks. Every record should have a permalink. Content should be tag-able. The look should be easily customizable with themes. Everything should be available via RSS or Atom. It should be extendable with a rich plugin API. And when that fails, it would be nice if it were all written in a convenient language like PHP so we can hack it ourselves.

Tech Tuesdays: Blogs and Blogging

Note: these are my presentation notes for a brown bag discussion with library faculty and university IT staff today. This may become a series…[[pageindex]] More: my presentation slides and the Daily Show video. Introduction Public awareness of blogs seems to begin during the years of campaigning leading up to the 2004 election, but many people […] » about 1400 words

Introducing bsuite_speedcache

I wrote bsuite_speedcache to reduce the number of database queries I was executing per page load. By implementing it on some of the content in my sidebar, I dropped 35 queries for each cache hit. That might not seem like much, but it should average about 525 queries per minute that that my host server […] » about 300 words

bsuite_innerindex WordPress Plugin

[[pageindex]] About “Blogging” typically connotes short-form writing that needs little internal structure, but that’s no reason to cramp your style. As people start to explore WordPress‘s Pages feature, it seems likely that we’ll need a way to structure content within posts or pages sooner or later. That’s why I’m working on bsuite_innerindex. It’s a WordPress […] » about 300 words

bsuite_geocode Plugin For WordPress

I’m a big fan of the WP Geo plugin, but I want more. My biggest complaint is that I want to insert coordinates using Google Maps or MultiMap URLs, rather than insert them in the modified story editor. So I wrote a bit of code that reads through the URLs in a post, finds the […] » about 400 words