Hello my dear Readers, guess who's back?

My holidays were pretty enjoyable. I spent a lot of time with my two kids, and had a very enjoyable week with my wife in Playa Del Carmen, Mexico where we had a taste of all the great stuff this country has to offer: white sand beaches, warm sea, fantastic scuba dives in the ocean and cavern diving in Cenotes, incredible Mayan places to visit, Dos Equis all day long, yummy typical food, and even local police racket (those gentlemen finedstole me 600 pesos:)

Now back to our regular affairs: while I was 40 feet deep under the sea, WordPress went 2.6 and I still have a few plugins to update. I know, I know! None of my plugins were really broken by 2.6, but some glitches require a few updates. Absolute Comments and Admin Drop Down Menus will be my main targets for the moment. I also have a very cool new plugin that's cooking and it's going to be hot, I promise. Stay tuned!

Yeepee, it's that time again. During the whole month of July, I'll be mostly offline: sporadic infrequent internet access to check any urgent email, but probably no activity on this blog. That means no code update, no great stuff for WordPress, no support for my plugins. I'm on the beach with my kids :)

Way back in 2005 someone said "Email is the universal API". This is what came to my mind when I found out and tried Posterous, a blog-by-email service. I think this service has a lot of potential for casual bloggers, and already has a few rather cool features regarding media embedding.

Blogging by email has always been a core feature of WordPress (or at least I think so, been a user since 1.01) but it has never evolved. You can't assign categories, you can't tag it, you can't embed images or any other kind of attachments. You can't do anything but raw text, which is sort of lame.

I think there are definitely a few features the WordPress folks should steal and improve from Posterous. WordPress has a nice gallery feature, right? Interface it with blog by email. WordPress knows podcast: make things so that when you email an MP3 it's added as a streamlined or downloadable audio track. Basically, WordPress does anything, anything should be doable via email.

A powerful blog-by-email feature would be great for WordPress (and a killer thing to add to wordpress.com too). I'm not always near a web browser with a (non firewalled) internet connection, but I almost always have an email client in the vicinity.

Any thoughts, readers? Did you ever, or would you, use a blog by email feature ?

A WordPress install is a bunch of directories and files, but two of them are particular: the file wp-config.php and the directory wp-content/ are personal and don't get overwritten when you upgrade your blog. In WordPress 2.6, they get so personal that you can even move them out of the WordPress root. This must bring a major change to your coding habits.

Plugin coders sometimes need their script to guess the location of their own directory (for example to require() files), or to include wp-config.php to make a file live alone in a WordPressized environment.

Guessing the path of wp-content

WordPress 2.6 allows advanced users to specify the location (physical and URL) of this directory with a constant define, so the directory might not be where it used to be.

What you used to do:

  1. $plugin_path = ABSPATH . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__));
  2. $plugin_url = get_option('siteurl') . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__));

What you will have to do, now that this directory can hide anywhere:

  1. // Pre-2.6 compatibility
  2. if ( !defined('WP_CONTENT_URL') )
  3.     define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
  4. if ( !defined('WP_CONTENT_DIR') )
  5.     define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
  6.  
  7. // Guess the location
  8. $plugin_path = WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__));
  9. $plugin_url = WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__));

In WordPress 2.6, constants WP_CONTENT_DIR and WP_CONTENT_URL are either user defined or set in wp-settings.php

Including wp-config.php

In WordPress 2.6 you can either leave wp-config.php in the blog root directory, or move it to the parent folder (which makes sense if this takes this critical file off of the webserver's document root)

What you used to do:

  1. require_once('../../../wp-config.php');

What you must do now:

  1. $root = dirname(dirname(dirname(dirname(__FILE__))));
  2. if (file_exists($root.'/wp-load.php')) {
  3.     // WP 2.6
  4.     require_once($root.'/wp-load.php');
  5. } else {
  6.     // Before 2.6
  7.     require_once($root.'/wp-config.php');
  8. }

Basically in WordPress 2.6 the file responsible for loading the environment is, in first instance, wp-load.php in place of the good old wp-config.php.

However, as pointed out by GamerZ in the comments, this still may not work. Why? Because not only the config file may not be there anymore, but the relative path to it may have changed since wp-content might have been moved too.

At this point though, there is no way I can think of to guess the locations of both wp-config and wp-content. To be 100% foolproof, such a "standalone" file needing to include wp-config should be editable so that advanced users moving their wp-content directory could manually edit a location path (the $root variable in the previous example)

Summary

Coders, revisit your old plugins to make sure they won't eventually break on WordPress 2.6 :)

Version 2.1 of Better Feed fixes some compatibility issues for people using the visual editor which was double-escaping HTML (boy, do I loathe this visual stuff) and introduces a new token allowing for embedding any PHP expression into feed footers, for maximum flexibility (%%<?php if ($that) do_this(); ?>%% anyone ?). Put your feed on steroids now. (0) «

Stephen, on his geek blog Nerdaphernalia, is running a series of excellent posts giving advices to plugin authors for neat subtle effects: adding a "Configure" link right next to the "Activate" link on the Plugins page, or how to give credit to your plugin without cluttering the page (I'm a big fan of the "Configure" link trick, that I've added to my latest release of Better Feed and will definitely implement in all my plugins now)

What's coming next on Stephen's blog is what seems to be my biggest pet peeve regarding plugins: saving plugin settings without cluttering the option table. I've had a draft post here for about 18 months about plugin coding tips and guidelines, and for sure its main point would be: "for f*ck sake, why don't you save all your options into just one array into just one entry??"

Taken from an actual plugin (slightly changed for anonymity) randomly found on my test blog (warning: NSFW)

  1. /*Lets add some default options if they don't exist*/
  2. add_option('xxx_email', get_option('admin_email'));
  3. add_option('xxx_subject', 'From Website');
  4. add_option('xxx_success_msg', 'Thanks, your email has been sent!');
  5. add_option('xxx_error_msg', 'Please fill in the required fields');
  6. add_option('xxx_error_msg_2', 'You have not entered a valid email address');
  7. add_option('xxx_error_msg_3', 'That destination does not appear to exist');
  8. add_option('xxx_redirect_loc', get_option('siteurl'));
  9. add_option('xxx_redirect_time', '3');
  10. add_option('xxx_css_inject', '1');
  11. add_option('xxx_cc_myself', '1');
  12. add_option('xxx_user_subject', '1');

Arrrgh. When I look at a plugin for the first time, the very first thing I do is literally count the occurrences of "add_option". More than 3 and the plugin is a no-no on my blog.

Executive summary: read Nerdaphernalia (I mean, if you're not a subscriber of Planet WordPress already). And wait a few more months for my "10 stuff to do to write proper plugins" article :Þ

wpdevel follows what gets committed into WordPress core. This may be easier (and less cluttered) than the wp-svn mailing list (except for the occasional Twitter downtime that is:) (0) «
twitvn: sends SVN commits to a Twitter feed. That’d be fun to have a Twitter account for, say, WordPress commits. (0) «

The mother of all the feed plugins is back: Better Feed version 2.0 just hit the repository and it's now even better than better.

For those who don't know it, Better Feed allows you to highly customize your feed, adding basically anything you'd like below each item: a copyright notice, an "Add to delicious" link, a promotional message, tag links, incoming links in Technorati or Google, you name it.

It also makes your feed comply to the "Read more" link, just like your blog posts: you'll be able to tease your readers and keep some surprise off the feed.

This long due update brings a very neat interface with real time preview — no more dirty coding in the plugin file itself. It's for WordPress 2.5+ and is completely happy with 2.6 as of today. Get a Better Feed today!

In: , On: 2008 / 06 / 25 Short URL: http://ozh.in/ij

According to this non-authoritative poll, nearly 50% of Firefox3 users think that the "Awesome Bar" is a huge piece of crap.

I must concur: this is a *huge* piece of crap. The sad thing is, there seem to be no way of reverting to a normal behavior. A few Firefox Addons or about:config hacks make things look like what it used to be, but unfortunately it does not act like it should.

I'm almost tempted to downgrade from FF3 back to FF2.