[wp-hackers] Link metadata?
mikeschinkel at newclarity.net
Mon Jun 15 06:28:02 GMT 2009
I'm pondering an architectural decision and wanted to run it by the hackers.
I'm building a plugin to provide "Post Links", i.e. "Links associated with a given Post." I've got a site where I'm using posts in ways that would model a Wikipedia entry more than it would a blog post. For example purposes let's say I had a tourism site that had a post for each of the 50 US states (I don't, this is just an example.) For my example I'd like to have the ability to add links to external travel articles related to each state.
WordPress already has the (almost) perfect data structure for these links: the wp_links table along with the taxonomy tables for defining link categories (i.e. a link category "Post Links") I can also define a custom post field in wp_postmeta that contains a list of the link_ids in comma-seperated form. This would allow me to pass the comma-seperated list of link_ids using the 'include' parameter of get_bookmarks() to get the list of links. All good so far. (Right?)
The next step is that I'd like to import blocks of links into my "Post Links" link category (I've already built the plugin for this) and then set up some workflow that would capture a screenshot for the URL (using another plugin I'm building), download the page title and meta description, and then finally present to me in a form to edit any of the links in much the same way Flickr.com lets you edit titles and descriptions when you mass upload photos.
The problem arises in that there are not any fields in wp_links where I can store anything to tell me which links have had their screenshot generated, their title and description downloaded, nor their titles and descriptions manually reviewed and edited (excepting the "notes" field which IMO is not a viable candidate.) Posts have wp_postmeta and Users has wp_usermeta but there is no wp_linkmeta for Links. My usecase needs some metadata for workflow but I'm sure there are many other uses for link metadata as well.
So here are the solutions I've considered:
1.) Storing everything in a 'links_workflow' option as a serialized array (this just doesn't feel right.)
2.) Creating a wp_linksmeta table and hoping that if WordPress ever adds it they add it like what I've added (Don't want to add a table but would be cleanest for SQL.)
3.) Adding a "link_meta" field to the wp_links table and storing serialized array data for each link (This is okay, but can't do a performant SQL query against.)
Maybe there's a fourth option but if so it hasn't occurred to me.
So, what would you do if you had this need? Also would there be any pushback to seeing #2 or #3 added into core?
Thanks in advance for pondering with me.
Custom Wordpress Plugins
More information about the wp-hackers