WP-Amazon Reloaded Gets a New Name

I’ve had a lot of success with WP-Amazon Reloaded so far. People have been happy with the results of my development efforts thus far. As such, I am happy to announce that I finally received WordPress.org repository access today to host the plugin.

Unfortunately, WP-Amazon Reloaded was no longer available as a name for a plugin on the official WordPress.org plugins repository so I went ahead and renamed the plugin. From now on, WP-Amazon Reloaded is Amazon Reloaded for WordPress. You can view the official repository and download the latest version there.

If you have any feature requests, please don’t hesitate to ask.

WordPress Plugin — Restore Id

In the latest version of the WordPress blogging system, the administrative UI was completely revamped. One of the biggest differences comes with the manage posts screen. The Id column was removed from the posts table, making it somewhat ponderous to attempt to find the Id of a specific post. This is bad news for designers, as the Id of a post sometimes determines what kind of styling to apply to the content.

The WordPress community’s solution to this problem is the following:

Q. How can I find the Post ID or Page ID?

A. If your browser shows the URL in the status bar, when you mouse over a link, you can see the ID in the as part of the URL displayed in the browser status bar. In FireFox you can show the status bar by checking the Status bar choice under View. A more complicated method to finding the ID is to use something like phpMyAdmin to look at the database table wp_posts–look down the column of post_title to find your Post or Page Title. The ID field on that row will be your Post (or Page) ID.

(from WordPress 2.5 FAQ)

Someone on the WordPress ideas page suggested that the Id column be restored, and that’s exactly what this plugin does. [EDIT]You can now download the plugin from it’s official plugin page on WordPress.org. Please let me know if you have any problems.

Loading Javascript Libraries in Wordpress Plugins with wp_enqueue_script()

Have a lot of Wordpress plugins? You may need server web hosting if you’ve got limited server space. Whether you use Outlook or Exchange 2007 for your email, you can get it hosted at an outside company so that you save room on your own server. Outsourcing Microsoft Exchange will definitely save you time, money and server
space.

In the process of modifying my Pre-Publish Reminders plugin for WordPress, I came upon an instance where I wanted to use a javascript library that is packaged with WordPress by default, but I couldn’t figure out how. However, after a little bit of frustration, followed by a little bit of detective work, I found an elegant solution included in the WordPress core.

First, let me share with you what doesn’t work. I originally had planned on placing things in the admin <head> section like so:

function nfoppr_add_js_libs() {
?>

}

Now, this approach didn’t work. The reason is that ABSPATH has to do with the file system and not the URL of the blog. So you end up with something like:

... src="./home/usr/nickohrn/wp-includes/js/prototype.js" ..

and this will not include your script. So, I had to find an alternative that would work. Searching through the function reference on WordPress I came across a note about the WP_Scripts object. This looked promising so I started to dig into the core WordPress files. I ended up finding the function wp_enqueue_scripts() within /wp-includes/script_loader.php which allows you to add a script to the <head> section of the page very easily. The function call looks like this:

wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false );

If WordPress recognizes the handle you provide, the library will be added for you. If it doesn’t support calling the library by handle (or the library is something custom you wrote) you’ll have to supply the path to the file as a second argument. The third argument lists any dependencies that the library you are loading may have (in the form of an array or false if there are no dependences). Finally, the fourth argument is the script version which, according to the documentation is primarily for cache busting.

To use the function, you’d do something like this:

function nfoppr_add_js_libs() {
//Add the Prototype framework to the header
wp_enqueue_script('prototype');
wp_enqueue_script('my_custom_prototype_extension', 'path/to/my/lib', array('prototype'));
}

//When you're in the admin menu, add the javascript libraries
add_action('admin_menu', 'nfoppr_add_js_libs');

As I couldn’t find a comprehensive listing of what library names you can call, I’ve decided to include one here. In the following table you can find the full name and handle for each library that is include by default. If applicable, I’ve included a link to the script homepage for each of the libraries that noted one within their source. There is a separate list of libraries that can be included if the logged in user is an administrator, but I’ve left those off the list for now.

Name Calling Name
Docking Boxes dbx
Fade Anything Technique fat
Simple AJAX Code-Kit sack
QuickTags quicktags
ColorPicker colorpicker
Tiny MCE tiny_mce
WordPress Tiny MCE wp_tiny_mce
Prototype Framework prototype
Autosave autosave
WordPress AJAX wp-ajax
List Manipulation listman
Scriptaculous Root scriptaculous-root
Scriptaculous Builder scriptaculous-builder
Scriptaculous Drag & Drop scriptaculous-dragdrop
Scriptaculous Effects scriptaculous-effects
Scriptaculous Slider scriptaculous-slider
Scriptaculous Controls scriptaculous-controls
Scriptaculous scriptaculous
Image Cropper cropper
jQuery jquery

So there you have it. I think this is a really elegant solution. Plus, it prevents you from loading the same javascript library multiple times if multiple plugins are using it. If you have any questions, feel free to ask me, and I’ll try to sort things out, or you can refer to the WordPress documentation (although it didn’t have much reference to this at all.)