This past weekend I gave a couple talks at the inaugural WordCamp Boston. WordCamps are local, community-organized events for WordPress users and enthusiasts. We had about 400 people at the Microsoft Cambridge campus.
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.
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!
A natural language interface is only “natural” if it’s in your natural language. With this mantra in mind, we’ve been making steady progress on the challenging problem of Ubiquity localization. The first fruit of this research is in the localization of the parser and bundled commands in Ubiquity 0.5. Here today is a visual guide on command localization in Ubiquity and different options we can take in attacking the community command localization problem. (more…)
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:
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.
A while back I created a count command for Ubiquity to count HTML elements on a page, so I’ll share it here. The idea is super simple: select some text on your page and execute count p to get the number of paragraphs, or count a to get the number of links, or count tr to get the number of table rows. This is super useful when reading articles with charts or lists online and you want to know how many there are without doing something like copy-pasting into Excel.
The count command is built using jQuery so it can even understand targets like p.class or a[href=...]. Give it a try! ^^
In this blog post I describe features in YARPP version 3.0.From those of you who were testing the beta, YARPP templates now go in your theme, and they must be of the form yarpp-template-….php.
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.
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.
Clicking on a version’s permalink will let you download the plugin. Subscribe now and be the first to find out when the upcoming version 2.1 is released!
I decided to semi-automate this RSS-producing process as well. As a plugin developer using wordpress.org’s plugin hosting, I sync a local copy of the plugin to their server using SVN. I wrote a PHP script to get the modification date information directly from the local files, parse the version log in the read me, and produce the RSS feed. If there’s an interest, perhaps I’ll release this code in the future.
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:
New algorithm which considers tags and categories, by frequent request
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.” ↩
Limiting by a threshold: Peter Bowyer did the great work of making the algorithm use mysql’s fulltext search score to identify related posts. But it currently just displayed, for example, the top 5 most “relevant” entries, even if some of them weren’t at all similar. Now you can set a threshold limit2 for relevance, and you get more related posts if there are more related posts and less if there are less. Ha!
Being a better plugin citizen: now it doesn’t require the user to click some sketchy button to alter the database and enable a fulltext key. Using register_activation_hook, it does it automagically on plugin activation. Just install and go!
Miscellany: a nicer options screen, displaying the fulltext match score on output for admins, an option to allow related posts from the future, a couple bug fixes, etc.
Installation
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.
Examples
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:
Incorporation of tags and categories in the algorithm. I’ve gotten the code working, but I still need to think about what the most natural algorithm would be for weighing these factors against the mysql fulltext score currently used (and works pretty well, I must say).
Um, something else! Let me know if you have any suggestions for improvement. ^^
Version log
1.0 Initial upload (20071229)
1.0.1 Bugfix: 1.0 assumed you had Markdown installed (20070105)
Pronounced “yarp!”, kind of like this, but maybe with a little more joy: ↩
Did you know that threshold has only two h’s!? I’m incensed and just went through and replaced all the instances of threshhold in my code. It’s really not a thresh-hold!? ↩