Steve Taylor photo

Developer’s Custom Fields 0.7 released

I’ve just released 0.7 of my Developer’s Custom Fields plugin, which is now available for download from wordpress.org or automatically via your WordPress plugins page.

There’s quite a few fixes and changes in this version. I’ll try and detail the most significant changes here in this post.

Cleaning up

0.6.1 switched from using “yes” for checked single checkboxes (and an empty value for unchecked) to storing either “1” or “0”. This is because the string “0” evaluates to false, but “no” evaluates to true! However, the switch may have caused some issues if anyone has code like this:

if ( slt_cf_field_value( 'checkbox-field' ) == 'yes' )
      [do some stuff]

I did! There’s not much I can do automatically to fix this, so I’ve included an alert at the top of admin screens that directs people to a new page for tools for this plugin under Tools > Custom Fields data. There’s a cleanup tool here that:

  1. Converts any old “yes” / empty checkbox values to “1” and “0”
  2. Deletes any empty values for fields defined through the plugin (0.7 now only creates meta table entries for fields with a value to store)
  3. Deletes any meta table entries for fields that have the prefix used by the plugin, but which are no longer defined

Needless to say, I’ve included plenty of warning to back up data before doing this. But once the tool has been run, enough attention should have been drawn to the potential issue with checkbox code (above), and the alert disappears.

The Google map geocoder and jQuery autocomplete

There had been an issue in that the handy address-finding geocoder field that is include with gmap fields used jQuery UI’s autocomplete. Turns out that this had been dropped from the version of jQuery UI in the WP core since 3.0—only I didn’t notice because I habitually use the Use Google Libraries plugin, and Google’s jQuery UI does include autocomplete.

WP 3.0 switched to suggest, and converting to this didn’t look like a simple case of switching functions. In the end, it turns out that WP 3.3 will ship with “jQuery 1.6.4 and jQuery UI 1.8.16. […] the full UI including widgets and effects.” So autocomplete will soon be there for everyone again. Until then, Developer’s Custom Fields includes the geocoder field via JS, on the condition that autocomplete is present.

Scope defaults to all

The scope parameter now, instead of being required, defaults to an empty array, which will apply the field to all items within the box’s scope.

Globally disable functionality

Some people have requested the ability to globally disable features like the gmap and file field types, which come with a load of JS and other stuff. Now you can do with using constants in wp-config.php, e.g.:

define( 'SLT_CF_USE_GMAPS', false );
define( 'SLT_CF_USE_FILE_SELECT', false );

Both values default to true.

Documentation and issue tracking

I was going to shift most stuff for this plugin to GitHub with this version, but that’ll have to wait until I get more time to work out git for myself. For now, full documentation is now here on this site.

If you find a bug in the plugin, please raise an issue via GitHub. And if you’re not sure your problem is a genuine issue with the plugin or not, just start a WP forum thread.

Other highlights

Other important changes include:

  • Added terms as an options_type for populating multiple value fields with taxonomy terms
  • Added a notice field type for text-only notices to the user
  • Added an above-content settings for the box context parameter, to place boxes on post edit screens above the content editor
  • Added except_posts and except_users options to the scope field parameter, to exclude certain posts or users that would otherwise be included
  • Added $file_attach_to_post parameter for file field types, so you can choose whether a file uploaded on a post edit screen is attached to that post or not
  • Minified JS and CSS (full versions loaded when SCRIPT_DEBUG is true)

You can see the full list of changes in the changelog.