Spring is for Speaking: JSConf, WordCamp SF, IACL
土曜日, 3月 20th, 2010I recently confirmed three different very exciting speaking gigs which I’ll be doing this spring:
I recently confirmed three different very exciting speaking gigs which I’ll be doing this spring:
Yesterday I gave a talk at the Boston WordPress Meetup. The Boston WordPress Meetup meets monthly at the Microsoft Cambridge Research Center which is a fantastic venue right on the Charles river. Last night we got to be up on the 10th floor which has a great view of Boston right over the river. There was pretty good turnout, with about thirty or fourty people there.
My talk was a general introduction to WordPress plugin development, beginning with the concepts of actions and filters, and concluding with a description of HookPress, my new plugin which enables webhooks in WordPress. Here are the slides:
I recently have spent a little time putting together a new WordPress plugin called HookPress. HookPress lets you add webhooks to WordPress, letting you easily develop push notifications or extend WordPress in languages other than PHP.
WordPress itself is built on a powerful plugin API which provides actions and filters. Actions correspond to events, so you can set a webhook to fire when a post is published or a comment is made.1 Filters let you modify some text when it is saved or displayed, so you can have your external webhook script reformat some text or insert some other content dynamically. Not all actions and filters are supported at this time, but I will continue to add more in.
There’s a webhooks meetup in San Francisco today but I unfortunately left SF this morning, so I created a video which will be played there as a lightning talk. A demo of both types of webhooks are in the video as well.
HookPress: add webhooks to WordPress from mitcho on Vimeo.
I’m really excited by this very simple but potentially high-impact plugin. I’d love to get your comments and feedback on this new plugin and hope to hear how you’re using HookPress!
ADDENDUM: Please also follow HookPress on twitter!
My friend Abi actually has already blogged about HookPress and how it can be used to tweet on post publication. ↩
A new user of my WordPress plugin tipped me off to a recent Tekzilla segment where WordPress founder Matt Mullenweg recommended Yet Another Related Posts Plugin as one of his personal favorite WordPress plugins. Thanks Matt! ^^
I recently noticed that some of my blog posts, most notably my Templates in YARPP 3 article, was producing a PHP error:
Warning: preg_match() [function.preg-match]: Compilation failed: unrecognized character after (?< at offset 3 in /…/html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2132
This seemed to be coming from the version 1.0.8.4 version of Geshi I had installed. A quick google search for “geshi line 2132” gives you over a thousand errors, so this seems to be common issue. Geshi is a fabulous and popular syntax highlighter and is the core component of the WP-Syntax plugin for WordPress.
I did some digging around and realized that the issue was with the compilation of this monstrosity of a regular expression, used (as far as I can tell) to identify PHP code snippets, for example the <?php … ?> keywords:
/(?<start><\\?(?>php\b)?)(?: (?>[^\"'?\\/<]+)| \\?(?!>)| (?>'(?>[^'\\\\]|\\\\'|\\\\\\\|\\\\)*')| (?>\"(?>[^\"\\\\]|\\\\\"|\\\\\\\\|\\\\)*\")| (?>\\/\\*(?>[^\\*]|(?!\\*\\/)\\*)*\\*\\/)| \\/\\/(?>.*?$)| \\/(?=[^*\\/])| <(?!<<)| <<<(?<phpdoc>\w+)\s.*?\s\k<phpdoc> )*(?<end>\\?>|\Z)/sm
Not knowing exactly where to start in diagnosing this crazy expression, I simply disabled those “script delimiters” in the geshi/php.php file. The sections I commented out are lines 1080-1101. Now the script delimiters like <?php don’t get highlighted nicely, but I feel that’s a small price to pay for eliminating these errors. Another solution for the WP-Syntax users seems to be to downgrade to 0.9.4. Hopefully in the near future an update to Geshi will come out which fixes this issue once and for all.
Post updated January 2012 to reflect cleaner template code available with YARPP 3.4.
If you have a YARPP support question not directly related to the templating feature, please use the YARPP support forums.
Version 3 of Yet Another Related Posts Plugin is a major rewrite which adds two new powerful features: caching and templating. Today I’m going to show you how you can use templates to customize the look of your related posts output.1
Previously with YARPP you were relatively limited in the ways you could present related posts. You were able to set some HTML tags to wrap your posts in and choose how much of an excerpt (if any) to display. This limited interface worked great for many users—indeed, these options still exists in YARPP 3.0. However, there’s also a new option for those of you who want to put your PHP skills to work and have complete control over your related posts display. The option will let you choose any files in the templates subdirectory of YARPP.

For those of you interested in the WP and SQL voodoo used to make this happen, I’ve posted a more technical article. ↩
This is what the latest release (2.1.6) of my Yet Another Related Posts Plugin looked like under Mint, using my WordPress plugin downloads pepper, which in turn gets its data from wordpress.org:

It’s always interesting to see these release spikes in download traffic. Note that this release was on the Wednesday but that was during the day, so Wednesday’s traffic is still higher than the normal ~300/day level, while the big peak (by day) is on Thursday. Too bad wordpress.org doesn’t give me hourly stats, though I guess that would be a little ridiculous.
YARPP is just about at that 35k download mark. I’m looking forward to the next release. ^^
The advanced WordPress user is intimately familiar with query_posts, the function which controls which posts are displayed in “The Loop.” query_posts gives plugin and theme writers the ability to display only posts written in Janary (query_posts("monthnum=1")) or disallow posts from a certain category (query_posts("cat=-529")1). One of the parameters you can set here is orderby which affects the ordering of the posts returned, with allowed values such as author, date, or title. But what if you want to order your posts in some other order, defined outside of your wp_posts table? Here I’m going to lay out some thoughts on rolling your own external ordering source for WordPress queries.
In order to introduce an external ordering source, we need to do four things:
1. create the external ordering source,
2. hook up (read “join”) the external ordering source
3. make sure we use that order, and
4. make it play nice. ^^
By the way, I’m going to assume you, dear reader, are PHP-savvy, proficient in MySQL, and already know a little about WordPress. This how-to is not for the PHPhobic.
Well, it’s been a while since I updated my plugin YARPP—in my humble opinion the best related posts plugin for WordPress. ^^ Today I release version 2.0, incorporating a number of important requests and bug fixes:
Check out the Yet Another Related Posts Plugin page on this site, the page on wordpress.org, or download it directly now!
I like many others am a big fan of John Gruber’s Markdown, a simple typesetting spec for entering text in a clean, legible plain-text fashion and outputting to (X)HTML. Michel Fortin did the fabulous job of porting the Markdown engine to PHP, making it a plugin for WordPress, bBlog, and TextPattern.
I’ve been using Markdown for all my blog posts here. Recently, though, I was in charge of a bbPress bulletin board (the “less is more” sister project to WordPress) for the Shoreland Scav Hunt team, and wanted to use Markdown formatting there. And I wasn’t the only one wanting to do this.
With some experimenting and research into the filters in the bbPress text flow (different than the WordPress one), I was able to make Markdown work in bbPress. This involved adding a special bbPress plugin wrapper to Michel Fortin’s PHP Markdown Extra. I’ve rereleased this plugin as Markdown for WordPress and bbPress, available at both wordpress.org and bbpress.org. Enjoy!
As I continue to work on and debug Yet Another Related Posts Plugin and WP-Smartdate, I’ve come across an issue where plugin activation fails, but I get no useful error message.
When I try to activate the plugin, I am redirected to a url of the type /plugins.php?error=true&plugin=...&_error_nonce=.... This redirect just gives me the plugins control panel with my plugin still disactivated, and with no useful error message.1 This apparently is an issue with the Plugin Protection mechanism introduced in WP 2.2. A quick fix (hack) is available on the WP forums.
Here’s hoping this helps some people scratching their heads, and that this behavior is reconsidered/fixed in future releases.
Apparently some people get a message like “Plugin could not be activated because it triggered a fatal error.” ↩
This posting is now outdated… for the latest information on YARPP, please visit YARPP’s very own page on my site, or its page on wordpress.org. If you have questions, please submit on the wordpress.org forum. Thanks!
Today I’m releasing Yet Another Related Posts Plugin (YARPP1) 1.0 for WordPress. It’s the result of some tinkering with Peter Bowyer’s version of Alexander Malov & Mike Lu’s Related Entries plugin. Modifications made include:
alter the database and enable a fulltext key. Using register_activation_hook, it does it automagically on plugin activation. Just install and go!Just put it in your /wp-content/plugins/ directory, activate, and then drop the related_posts function in your WP loop. Change any options in the Related Posts (YARPP) Options pane in Admin > Plugins.
You can override any options in an individual instance of related_posts using the following syntax:
`related_posts(limit, threshold, before title, after title, show excerpt, len, before excerpt, after excerpt, show pass posts, past only, show score);
Most of these should be self-explanatory. They’re also in the same order as the options on the YARPP Options pane.
Example: related_posts(10, null, 'title: ') changes the maximum related posts number to 10, keeps the default threshold from the Options pane, and adds title: to the beginning of every title.
There’s also a related_posts_exist) function. It has three optional arguments to override the defaults: a threshold, the past only boolean, and the show password-protected posts boolean.
For a barebones setup, just drop <?php related_posts(); ?> right after <?php the_content() ?>.
On my own blog I use the following code with <li> and </li> as the before/after entry options:
<?php if (related_posts_exist()): ?> <p>Related posts: <ol> <?php related_posts(); ?> </ol> </p> <?php else: ?> <p>No related posts.</p> <?php endif; ?>
1.0 Initial upload (20071229)
1.0.1 Bugfix: 1.0 assumed you had Markdown installed (20070105)
I recently have been working on a WordPress plugin called WP-Smartdate and I’m happy to say that it is hosted at wordpress.org starting today. As some people have noticed, my blog recently has included little links on word like “yesterday,” with a machine readable version of the date reference (called a “microformat” in the biz). Download the plugin and get started!
This blog post describes release 0.1… For the latest description, check out the WP-Smartdate plugin page or mitcho.com/code.
Please comment! I would love to hear your feedback on the plugin.
WP-Smartdate looks for relative date expressions in your blog posts, such as “tomorrow,” “this coming Monday,” “last Friday,” and adds the date reference (like “2007-11-26”) as a machine-readable microformat.
WP-Smartdate was created for three simple audiences:
2007-11-07.The following types of expressions are resolved with respect to the speech time—in WP-Smartdate’s case, the blog post date.
One could argue that relative dates are a perfect place to use the abbr tag, as they are a sort of natural-language shortcut for more static temporal expressions. In fact, WP-Smartdate’s output also follows the datetime microformat design pattern draft with two caveats:
1. Unfortunately, the datetime semantic class has not yet been set as the standard is a draft. WP-Smartdate uses datetime. See the Date and Time datatype proposal for more information.
2. The current recommendation for datetime pushes for following the W3C datetime profile, which does not support the ISO-8601 time interval specification, which is will be used by WP-Smartdate. ↩
Even though the abbr tag should only be used for machine reading. ↩