[wp-hackers] an idea / tags

Sam Angove peasant at gmail.com
Sun Jan 16 08:38:02 GMT 2005


Thanks for that! It's much better than my version, so let's just
pretend that little episode never happened. :)

I ended up turning it into a plugin just to install it, which is available here:

   <http://rephrase.net/miscellany/05/kellan_post_tags.phps>
   <http://rephrase.net/miscellany/05/autocomplete.js>
   <http://rephrase.net/miscellany/05/autocomplete_misc.js>

Or zipped:
   <http://rephrase.net/miscellany/05/kellan_post_tags.zip>

(The two js files go in /wp-content/, the plugin -- obviously -- in
wp-content/plugins/.)

It only uses the default plugin hooks now (it's a real plugin, not an
abomination), but it *is* pretty inefficient -- after every post, WP
adds categories, then plugin removes them and runs its own category
adding function  -- but it works.

It uses a few globals for options instead of putting them in the
database, since it was easier than writing an admin page to control
them properly.

Instead of your changes to write_nested_categories to disable the
category checkboxes, I added JavaScript to do the same thing. And
since the JavaScript was already crawling through the list, I got it
to prepopulate the tag box (when editing) from the menu items instead
of making another query. And added onclick events so clicking on the
categories in the menu adds them to the tag box.

It's fragile (it's going to break if write_nested_categories() is ever
changed), but works. In the WP alpha I have installed, anyway -- I do
hope the current builds haven't changed that much. As for browser
compatibility, I can only test in Firefox/IE6/Opera7, but it works in
those. (Except for clicking the category menu to add tags; that
doesn't work in IE.)

The autocomplete doesn't work properly with categories containing
spaces, but that's a small price to pay. I was tempted to rewrite it
to use XMLHttpRequest (like LiveSearch/Google Suggest) -- probably
more efficient on large datasets than the "load the entire post2cat
table" code that's there now, and definitely more elegant -- but it
was far too much bother. :)

Thanks again, it's an awesome plugin/patch/whatever.

-Sam


On Sat, 15 Jan 2005 09:23:56 -0800, kellan <kellan at gmail.com> wrote:

> I've fixed the link, sorry about that.  The patch includes the
> avar.icio.us code.
 
> -kellan


More information about the hackers mailing list