Wordpress

Countdown Timer Update is in the Works

It’s been over a year since I’ve had the chance to update Countdown Timer. However, a couple of weeks ago the stars aligned just so and I started working on a slew of updates. Nothing huge, mostly just updating code in the back end to do things properly and rewriting some sections of code to take advantage of new methods WordPress has implemented in the last few releases.

So far I have almost 100 diffs involving a shit ton of source code1

It’s not quite ready yet, but I am working on it; as is hopefully evident by this freakishly late night/early morning post.

Please consider yourselves informed that a new version is on its way.

0
  1. yes, that’s a technical unit of measurement, similar to the Hella- prefix [See: The Official Petition to Establish ‘Hella-‘ as the SI Prefix for 10^27] 

Stay Up To Date on Comments

As I work on planning my upcoming trip abroad, there’s been some great discussion and feedback in the comments. Those of you who are super-savy WordPress users might know about the sort-of-secret Comment RSS feed that you can subscribe to, however most people don’t.

So I figure I’d make it super easy for everyone and provide the RSS URL for those using RSS Readers (such as Google Reader) and an email sign up in case you’re not ready to make the plunge into the RSS realm.

RSS URL: http://feeds.andrewferguson.net/afdn_comments

Email Signup: Subscribe to Comments for Andrew Ferguson dot NET by Email
Note: The email list is run by FeedBurner (aka Google) and is the same organization that I use to send out the regular AFdN updates.

0

WordCamp Denver

Last weekend I attended WordCamp Denver, the “conference created for enthusiasts, users, developers, designers, and fans of WordPress“. It was basically a time to geek out with fellow programmers, developers, and bloggers.

For me, the highlights were Matt Mullenweg’s State of the WordPress, Ben Huh’s I Can Has WordPress, and learning about the Carrington Theme Framework. I also got to meet (and have a quick photo op) with Matt, Ben, and Lorelle VanFossen. Matt even took a picture of me…well, my t-shirt at least.

It was also great to finally meet Alex King and most of the rest of his crew (Devin, Shawn, Sean, Gordon, and Jeremy) at Crowd Favorite. They did a great job organizing the event and without them this would have never gotten off the ground. I also think that if I ever got tired of engineering and wanted to do web development full time, Alex/Crowd Favorite would be the first person I’d talk to.

Interesting side note: Alex grew up in Seattle just around the block from me. Small world, eh?

Lorelle and Me

Lorelle and Me

Me and Ben Huh

Me and Ben Huh

© 2009 Matt Mullenweg

A picture of my WordPress/WordCamp Denver t-shirt and all of all my gear - © 2009 Matt Mullenweg

Per usual, you can see the rest of my photos on Flickr at: WordCamp Denver
You can see the rest of Matt’s photos at: http://ma.tt/2009/02/wordcamp-denver/
And you can see all photos tagged with “wordcampdenver” at: http://flickr.com/photos/tags/wordcampdenver/

By the way, I think Matt Mullenweg is infinity better/cooler/more awesome than Mark Zuckerberg. And I feel safe in saying that without actually having met Mark. Two words: Open. Source.

0

New Plugin: WP Plugin Data

For better or worse, I’ve released a brand new plugin. It was one of those things I did spur of the moment because I wanted to implement something and the way I wanted to do it wasn’t available (insert some comment about necessity being the mother of invention here).

The new plugin is WP Plugin Data. It’s designed to use the WordPress.org Plugin API to get data about a specific plugin. John Blackbourn already wrote a plugin, Plugin Info, that does something similar. However, it requires that you set a Custom Field to the plugin name. I didn’t like this approach because I could only grab data for one plugin per a page.

So, using John’s plugin as a template, I wrote my own plugin that used shortcodes to add the data. And then I released it. This is why I love the GNU GPL. As for naming, I really hate it when plugins use the “WP” moniker in their titles. Typically, the plugin has absolutely no affiliation to WordPress and I feel the only reason they put “WP” in their name is to gain some form of (undeserved) recognition. For this reason, I really didn’t want to put “WP” in the title. However, I did end up using because this plugin actually does integrate itself into the WP.org backend using the API…so I feel the use is justified.

Anyway, enough about that.

Read more, or download version 0.5!

0

Countdown Timer v2.3.5

Hot off the press, Countdown Timer 2.3.5 is now available for consumption.

This is a small update that resolves a few issues, including:

  • Updated calculation routine to ensure that dates are accurately when “Months” are not displayed.
  • Updated readme.txt file to make some things more clear
  • Fixed small display issue in the administration menu

Also included are six new languages:
Latvian, Romanian, Russian, Danish, Lithuanian, and Serbian.

Read more or download version 2.3.5!

0

WordCamp Denver

I'm Attending WordCamp Denver 2009

I just submitted my registration and I’ll be attending WordCamp Denver, “a conference created for enthusiasts, users, developers, designers, and fans of WordPress1.”

Critical Details:
From denver.wordcamp.org:

When: Saturday, February 28, 2009
Where: Denver Art Museum, 100 W 14th Avenue Pkwy, Denver, CO 80204
How: (much) $20, click to register for WordCamp Denver 2009
Who: Local bloggers, web developers, publishers, designers, internet and marketing enthusiasts, companies interested in blogging and/or building on WordPress.

If you would like to attend, visit: http://denver.wordcamp.org/

Yes, I’m super nerdy. Deal with it.

0
  1. WordPress is what I use to power this blog 

Using add_meta_box()

Note: Updated to be compatible with WP2.7.

Note: Technical content to follow.

In the WordPress 2.5 upgrade, Automattic completely revamped the administration interface – including the way that boxes were created for plugins (well, really the entire administration back end; however I will be focusing on plugins). Previously, you had to create the boxes manually, hard coding something to the effect of:

<div class="dbx-b-ox-wrapper">
<fieldset id="myplugin_fieldsetid" class="dbx-box">
<div class="dbx-handle-wrapper"><h3 class="dbx-handle"><?php _e( 'My Post Section Title', 'myplugin_textdomain' ); ?></h3></div>
<div class="dbx-content-wrapper">
<div class="dbx-content">
Your plugin box content here
</div>
</div>
</fieldset>
</div>

Source: http://codex.wordpress.org/Function_Reference/add_meta_box

But how do you get those slick looking boxes seen in WordPress 2.5 and WordPress 2.6 and WordPress 2.7? I looked online and I found plenty of sites detailing how to add meta boxes to the post page. However, I didn’t find anything describing how to implement the add_meta_box() function for your own plugin page.

I spent a bit of time time and reverse engineered the process. Once you have it figured out, it’s really quite simple. At the very least, it’s a lot more intuitive.

First, you’ll want to wrap your content you want to display in a function that echos it out. You’ll need a separate function for every box you want to add. After the function has been declared, you’ll want to add it using the add_meta_box() call. The usage for add_meta_box is:

<?php add_meta_box('id', 'title', 'callback', 'page', 'context', 'priority'); ?>

Here’s the PHPDoc data:
string $id String for use in the ‘id’ attribute of tags.
string $title Title of the meta box
string $callback Function that fills the box with the desired content. The function should echo its output.
string $page The type of edit page on which to show the box (post, page, link)
string $context The context within the page where the boxes should show (‘normal’, ‘advanced’)
string $priority The priority within the context where the boxes should show (‘high’, ‘low’)

add_meta_box simply adds the box to a queue. It doesn’t actually spit out any code. Thus, after you’ve created all the content callback functions and added them to the meta box queue with add_meta_box, you’ll need to execute do_meta_boxes().

<?php do_meta_boxes('page', 'context', 'object'); ?>

string $page The edit page which you want to display; this will be the same as $page specified in add_meta_box.
string $context The context within the page where the boxes should show (‘normal’, ‘advanced’).
? $object I don’t know, I just have it set to null.

All together, the code might look something like:

<?php
function yourplugin_helloworld_meta_box(){
?>
Hello, world!
<?php
}
add_meta_box("yourplugin_helloworld", __('Say Hello', 'yourplugin'), "yourplugin_helloworld_meta_box", "yourplugin");
do_meta_boxes('yourplugin','advanced',null);
?>

One weird/interesting thing I discovered is that ‘yourplugin’ can only consist of lowercase letters a-z and the hyphen “-” symbol. For all you programmers, it must return true when matched against /^[a-z-]+$/

I don’t know what, but that’s the check run on line 620 of /wp-admin/admin-ajax.php from WordPress 2.6.2.

That’s the most basic level of creating your own meta boxes. However, there’s more. Do you notice how sometime the meta boxes are closed on the posts (or pages, or links) page? The open/closed position is remembered using some AJAX. The actual data is stored per user in the wp_usermeta table with a meta_key of ‘closedpostboxes_yourplugin’. The data is a serialized array that lists just the closed the boxes.

To get this functionality, you’ll need to perform a couple more steps. First, you’ll need to add some javascript. This code does two things, on load it closes boxes that should be closed (because they were previously closed) and it allows the boxes to be toggled open and closed.

jQuery(document).ready( function($) {
	// close postboxes that should be closed
	jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
		
	// postboxes
	<?php
	global $wp_version;
	if(version_compare($wp_version,"2.7-alpha", "<")){
		echo "add_postbox_toggles('yourpluging');"; //For WP2.6 and below
	}
	else{
		echo "postboxes.add_postbox_toggles('yourplugin');"; //For WP2.7 and above
	}
	?>
			
});

You’ll also need to add this PHP code:

<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
?>

This code registers a new nonce that your plugin will use to send authorized AJAX requests.

And that’s it. Give a holler in the comments if you have questions and I’ll try my best to answer them.

See also: http://xref.fergcorp.com/

0

Force User Field Registration End-of-Life

For better or for worse, this is the End-of-Life announcement for Force User Field Registration.

This history behind the plugin is rather odd for me. I originally wrote it as a proof-of-concept for Add Custom fields to User Profile & Registration Pages. I never planned to actually implement it and support it, which I suppose it what I get for trying to be helpful ;).

In fact, the orginial code was just posted as a snipnet on my blog over two years and required the user to copy and paste the code into a file themselves! I finally released the code in a file you could download a four months later. It’s seen several upgrades, mostly to deal with WordPress updates that broke stuff and I even forked it into a version for WordPress MU.

I think one of the most difficult things about maintaining this plugin over the last few years is the fact that I never use it myself. I really enjoy using my own plugins and not using them on a regular basis creates a very wide disconnect for me, I don’t get to eat my own dog food.

I digress.

I was answering a request related to the Force User Field Plugin and doing some research when I came across a superior plugin that not only meets all goals set out by Force User Field Registration, but far exceeds them.

It’s called Register Plus and is coded by Skullbit.

I downloaded it and played with it briefly; and I have to say, I really like it. There are a few quirks that I’m sure the developer will work out, but nothing blocking. It also implements a number of requests that users have asked for in the past and I have not added because they fall outside the scope of the plugin or I never got around to.

Thanks to everyone who has ever used the the plugin or left a comment. At last check, there were over 1600 downloads and 143 comments (probably half of which are mine, though).

The formal announcement:

Force User Field Registration is going End-of-Life on or before December 31, 2008 23:59 PST.
I will continue to provide official patch releases (i.e. 0.6.x) as needed to maintain compatibility with WordPress 2.6.x and WordPress MU based on WordPress 2.6.x.

On or before January 1, 2009 00:00 PST, I will provide help on a case by case basis, however I will no longer be releasing updates.

The code will remain posted and licensed under the GNU GPL. The official plugin page will remain up: Force User Field Registration

What I believe to be a suitable replacement:
Register Plus by Skullbit.

0

Force User Field Registration v0.6

So it seems like WordPress 2.5 ended up breaking some things in the previous version. So I did some work over the weekend and brought everything back up to speed. Here’s a list of what’s been updated:

  • Added PHPDoc
  • Updated add_action to use inbuilt filter rather then have users add their own
  • Update admin UI to 2.5 LnF1
  • Updated input tag to make it look like native input tags
  • Updated fergcorp_forceRegistrationField_updateFields to use passed variable instead of DB query
  • Updated error handling in fergcorp_forceRegistrationField_checkFields to use the new WP_Error object (note: this makes WP 2.5 a minimum requirement)

I think the best news is that you don’t need to modify files anymore to get the plugin to work, you can just drop it in and go. WordPress also has implemented a new error handling framework (WP_Error) which is pretty spiffy.

On a side note, I did take a gander at the MU version of the plugin and it appears to be working properly…at least for now.

Read more or download it!

1 LnF: Look and Feel

0

Countdown Timer v2.2

I wanted to release this earlier, but between finals, being sick, and field session, I haven’t had a lot of time. This version of Countdown Timer (almost) updates the UI to 2.5 look and feel. As it turns out, there’s actually some function calls I can use to better create the UI and I’ll be using those in the future. There’s a couple of bug updates and added some new functionality.

Also, Countdown Timer v2.2 requires WordPress 2.5 or higher!

The run down:

  • Updated some phrases that missed being i18n.
  • Updated i18n to use use sprintf’s to assist in proper translation.
  • Update the admin page to WordPress 2.5 Look and Feel.
  • Users are now able to define the data (text/HTML) that comes after the title and before the actual countdown.
  • Implemented a new function, fergcorp_countdownTimer_single($date), that allows users to create a one-off event outside of The Loop. $date should be PHP strtotime parseable string.
  • Plugin output is now XHTML 1.0 Strict compliant.

Read more or download version 2.2!

0