Some handy functions I use to grab values from arrays and objects (especially $_REQUEST and friends), without having to constantly run isset or !empty checks everywhere (to avoid undefined index notices). You can specify a default value if the index doesn’t exist in the array or object. Also lets you sanitize the value(s) using a callback before returning them.
With the custom post type enhancements introduced in WordPress 3, site builders and plugins developers now have access to what you could call “dynamic scaffolding”. With a couple of lines of code, you can easily generate the necessary UIs to help users easily manage and create new types of content.
You can add new post types (e.g. Movies, Reviews, Products, Projects, etc.) and specify the features each should support (e.g. title, body, authors, revisions, etc.) . Beyond that, you can add use the ever-flexible hook and filter system to add your own features. Combine that with custom fields and you can add your own fields (so a “movie” post type can have new fields to add things like “release date”, “rating”, and so on) .
However the code involved in adding those additional fields can get cumbersome, especially when you start looking at lots of content types with numerous fields. Add in other object types like users and comments and you’re now looking at a huge code base that needs to be maintained, updated and so on.
Well, I’m making it easier.
Overview
Custom Metadata Manager introduces a very WordPress-like way of adding additional fields to your object types. The goal is to help you rapidly build familiar, intuitive interfaces for your users.
Consider this:
That one line of code kicks into gear some of that “dynamic scaffolding” magic I mentioned earlier. The Edit Post page now has a metabox with a text field. The plugin handles all the heavy-lifting for you behind-the-scenes, so that you can focus on more on building out and connecting your data rather than all the minor details. Checkit:
A magical new field with one line of code!
The API is similar to that used for registering custom post types and taxonomies so it should be familiar territory.
Object Types
But let’s not stop there. Let’s say I want comments and users to all have this magical new field. Let’s try something like this:
And we get the same field added for users and comments!
A magical new field for users with one line of code!
Note: I’ve omitted a screenshot for comments since it looks exactly the same as the posts screen.
Custom Metadata Manager supports fields for:
posts (built-in and any custom post types)
comments
users
If/when links and taxonomies get metadata support, I’ll add support for them as well.
Labels and Descriptions!
Avoid cryptic slug-like names and make it easy for users by assigning friendly labels and descriptions!
'Field Label',
'description' => 'This is a friendly description for the field to help you enter your data.'
) );
?>
Groups
To avoid clutter on the Edit Post page, you can group sets of fields together.
Text fields can get boring, so I’ve cooked in a number of different field types (just specify the field_type in the $args parameter and go!):
All sorts of different field types
Custom Callbacks
Notice that last one in the screenshot above? That’s using a custom display callback! You can override a bunch of different things (display callback, sanitize callback, etc.) to get even more control over the fields you add. That means you can do cool stuff like this:
Custom callbacks make custom fields even more fun!
Columns
We’ll throw in an easy way to add your fields to the Manage Post/User/Comments pages as well (in your $args, just set display_column to true). By default, the column will just the value of the field, but if you’ve got something complex going on, you can just as easily include a display_column_callback.
Columns made easy!
Example Code
I’ve included fairly detailed docs on Extend and for kicks, I’ve thrown in example code along with the plugin. (To see it in action, turn on WP_DEBUG.)
Why this plugin?
Don’t get me wrong: this isn’t anything revolutionary. Lots and lots and lots and lots have come before me. But my approach is probably the most “WordPress-like” there is (Bonus points to Easy Custom Fields which uses a code-based and very object-oriented approach).
The API is simple, intuitive and very flexible, providing lots of overrides if you don’t like the default functionality (or have specific use cases).
The plugin doesn’t use extra tables and stores all data in a WordPress native way, so you can use the standard get_metadata function to retrieve your custom data. That way you also don’t have to worry about losing your data should you choose to stop using this plugin.
(I have already deployed and used the plugin across a number of production sites and it’s working great and saving me significant amounts of time and code!)
Why a code-based approach instead of a UI?
Because most of the plugins I mentioned above do the UI thing (and some it really well!) and it’d be lame to just copy them. The code-based approach, though, more closely aligns with the existing WordPress approach of registering new types of content (post types, taxonomies, etc.).
This is also a developer feature, aimed towards site builders. And real developers don’t need UIs ;)
TODOs
What stuff am I cooking up for future versions?
Improved styling of rendered fields
Ability Pass in attributes for built-in fields (e.g. class, data-*, etc.)
Additional field types
Limit or exclude groups and fields for specific ids (e.g. show only on post id = 145)
Autosave support for fields on post types
Option to enqueue scripts and styles
Client- and server-side validation support
Add groups and fields to Quick Edit
—-
Download
Grab it from the WordPress Plugin Directory or just search for “Custom Metadata Manager” from the Plugin Manager within your WordPress install.
If you’ve read all the way through, thanks! Like what you see? Want more field types and features added? Just want say hi? Get in touch.
Update (2010-04-20): These Gleeks are crazy. Since being released, the clock has been viewed over 200,000 times. Insane.
If you like Glee, you’ll like this. If you like image processing using PHP, you’ll like this even more.
Using PHP and the GD image library*, it’s pretty easy to create a static, image-based countdown clock, which is useful for situations where javascript cannot be used (think WordPress.com/Blogger). A new image is automatically generated server-side for every minute (assuming a request is made for the clock for that minute), and all images are cached to avoid killing the server processor. Check it out in action on Gleeks United or after the jump.
Don’t have code yet, but I’ll post it when I get a chance.
Using Mockingbird, a recently launched Cappuccino-based wireframing tool, I was able to whip up some quick UI concepts I’ve been thinking of for the next iteration of Edit Flow. Though obviously not as fast as a hand-drawn sketch, it’s far more convenient when you’re working with other people since you don’t have to get cameras and/or scanners involved.
Mockingbird has a fairly intuitive interface, and most functionality you’d expect from a wireframing/diagramming tool. Best part: no Flash! Check out the result below. It’ll be updated as I make changes to the diagram.
Ever look through your list of plugins and forget just exactly what one of them does? I know they have descriptions next to them, but that doesn’t always speak to exactly what you are using it for and why. This plugin would just put a text field in each plugin field you could type some notes in there, theoretically to keep information about why and how you are using this plugin.
And since I was bored (and thought this was a pretty useful idea), I delivered. Plugin Notes is exactly what it sounds like.
Once you install and activate, the plugin adds a link “Add plugin note” that lets you add in a little note next to each plugin. It’s totally ajaxified and full of cool goodness. (Unfortunately, I was a bad programmer and didn’t make plugin gracefully degrade when javascript is turned off. Sorry, folks. Maybe next time.)
Plugin Notes: adding a note is easier than milking a cow.
When a note is added, it shows up inside a little blue box and includes the name of the user that added the note as well as the date and time when the note was added. You also get handy dandy options to “Edit” or “Delete” notes.
WordPress plugin: Plugin Notes - blue boxes make things look pretty.
Each plugin can only have one note. I can imagine there would be cases where multiple notes may come in handy, but those would be rare so I’m passing on that functionality.
The plugin is pretty simplistic, and unlikely to see any future feature additions (unless someone really, really wants one). I’ll keep a watch for compatibility with future versions of WordPress though, so rest easy.
Excited, enough? Grab Plugin Notes (from the WordPress Plugin Directory) or download it from within WordPress.
Note: you’ll need PHP5 and a javascript-enabled browser for the plugin to work.
Yeah, I’d messaged him, but he was never able to get it to work. I found the probably error a month or two later but never messaged him back. Might be worth it now.
My independent digital design project (DAC 400) completed as part of my Digital Arts Communication specialization explored the push by magazines into the online and technology spaces. The goal of the project was to explore viable technologies to use as a platform for developing an online presence for The Boar, an arts and literary magazine produced by and for the students in the Faculty of Arts at the University of Waterloo. I explored the traditional online website format but looked further by designing a prototype of an up-and-coming Flash-based technology known as the “digital edition.” This “new technology” is being adopted industry-wide like wildfire (see Issuu, Scribd, Zinio, etc.). It takes a traditional PDF and converts it into an interactive magazine-like object on a webpage that can be used and manipulated much like a physical magazine. My prototype (although not entirely functional) took a step further and explored the possibilities of creating greater ties between a magazine’s website and their digital edition via a synchronization of comments, bookmarking, and other social networking type tools.
As supplementary materials, I have attached 3 documents that I completed as part of my project:
Technology Research: exploration of various technologies in use by the magazine industry and what movements the trends were indicating.
Strategy, Scope & Structure: Documentation outlining requirements for the online presence and drill down into specifics, as well as a high-level architectural diagram.
Final Analysis: Analysis of the end result of my project, including rationale for technical and design choices as well as possible enhancements for the future.
KiwiShake was a prototype Facebook application. The idea was to provide users with the ability to create eCards that could be customized with photos, videos, etc. It’s not even close to completion and it pretty terrible overall, but there’s a lot of potential.
I programmed the interface of the application, which involved lots of JavaScript and some AJAX work.
What do you get when you marry the Adobe Scripting Engine with the magic of XML Parsing? Well, one thing you can come out with is a web publishing system that automates the process of publishing the online version of a weekly newspaper.
This is exactly what I did for Imprint. Online publishing for Imprint was always seen as a chore and took forever to do. I searched for a solution, but could not find anything substantial. So it was time to hack something together.
Using the powerful Adobe Scripting Engine and some cleverly crafted JavaScript, I was able to turn an (almost) semantically dead laid out newspaper page (in Adobe InDesign) into a meaningful XML file. (I have to note that some user input was involved; the Web Editor had to appropriately label related Text Boxes within InDesign to associate story elements together). This XML file could then be pumped into a custom administration component for the Mambo CMS, that would parse through the XML and create the appropriate database entries and automagically publish the newspaper online (I should also note here, that some user input was involved; Users were walked through the list of articles extracted from the XML file and had to indicate the Section and Category each belonged to). Goodbye copy-pasting!
Clever, no?
Tools used: JavaScript, Adobe Scripting Engine, Adobe InDesign, XML, PHP, MySQL, DOMIT XML Parser, Mambo, and hours of rigorous testing
This is great. Do you have any experience with College Publisher 5? It would be great to port some of this over to the vaguely useful XML-output they accept…
No, I’ve never worked with College Publisher before. Though, if they have options for XML-import then I’m sure it’s easy enough to make the script work for it. I’ll send you an email to discuss further.
In conjunction with the 50 years of campus journalism celebration at the University of Waterloo, Imprint took made a push to make available online, all 50 years worth of its archives. I took the lead on this as I managing the Imprint website at the time.
We received scanned copies of all the archives in PDF format. To incorporate the archives into our existing system, and to make them easy to browse through, we needed certain pieces of information, such as the volume, issue number, etc. The files were all named with a certain convention and contained all the required pieces except for a key component: the date. Getting the date would be hard; there was no easy solution other than simply opening each PDF file and recording the date manually. The downside to this was that 50 years worth of archives meant that a lot of PDF files needed to be sifted through.
Given the access to a healthy and willing volunteer base, I decided to use “community” power to streamline the process. I set up a quick PHP script that extracted volume and issue information from the file name, and on top of that, threw a quick streamlined interface that asked the user to enter the date information for the PDF file presented. With volunteers working at the task in their spare time, we managed to codify 50 years worth of archives (1,000+ issues in less than a week), whereas, my going at it alone would have taken easily over a month.
Update (2008-06-04): I recently upgraded the archives to make use of the Scribd API to generate on-the-fly “iPaper” versions of PDFs in the archives. The main benefits of this are savings in bandwidth usage (since some of the PDFs are ~100MB) and a faster, enriched user experience.
Tools used: Healthy and willing volunteers, PHP, MySQL, Regular Expressions
After several years in the online game, Imprint, the University of Waterloo’s official student newspaper, decided that it needed a fresh new website to adapt to the changing trends in the Internet news industry.
I modified the core code of the Mambo content management system to meet the unique needs of a newspaper’s online counterpart, such as having an issue-based publishing system, among others. This involved modifications to both front- and back-end code+interfaces. Beyond this, I investigated add-ons provide additional functionality such as a commenting system and integrated those into the website. If add-ons were not readily available or were not up-to-standard in terms of quality, I wrote them from scratch. A great example is the PDF Archive.
Tools used: Mambo CMS, lots and lots of coffee (for all the late nights spent analyzing and writing code)
How can i put this on my facebook profile?