Upgraded to WordPress 3 auto-style and then decided to upgrade K2 automatically too. The K2 upgrade nuked my stylesheet. So there’s been a slight hiccup with respect to my site style at the moment. I need to find the last backup I made, it was on the hard drive of the laptop that failed last month, and restore the site style. Should be back soon.
Tag Archive for 'wordpress'
Hey gang,
Just a quick update to let you all know that I just updated the about me widget over at codex to be compatible with the new WordPress Widget API. I decided to contact Sam and get access to the repository on codex, rather than host the download on my blog locally. Feel free to discuss installation or other issues in here.
I bumped the number up to 2.0 since it was a complete re-write to make it work in the new Widget API. The new API makes it incredibly easy to write regular widgets, but incredibly difficult to write plugins that require rich controls that use their own kind of ajax, tinyMCE being the candidate in this instance.
I had to do some very evil things to make the tinyMCE editor able to save it’s html into the textarea on the save button click event (since that triggers the ajax postback, not the form submit event that tinyMCE is watching for).
I also had to do some very bad things with respect to page loading and click event binding to get tinyMCE control to survive the ajax widget re-ording events. Apparently drag-and-drop destroys the underlying controls in the widget div which leaves the tinyMCE editor orphaned with no active window. The only way I was able to work around this issue was to bind the widget settings button (the down arrow) click event and literally remove the editor from the DOM, using jQuery().remove() and then re-init the editor and show it.
This is the only way i was able to get the tinyMCE editor able to both survive a sort event, and bind to the textarea. I don’t like because it means everyvtime you try to edit the about me widget you have destroy and re-create the tinyMCE editor and rebind it to the textarea. It works, it’s just not clean.
I suspect the WordPress dev’s will be changing the API to give it more hooks and mature it’s ajaxy-ness as time goes on.
Plugin link: http://wordpress.org/extend/plugins/about-me-widget/
So I’ve been migrating the about-me widget over to the new widget API in WordPress 2.8.2+ for the past week and I’ve not been having fun.
Actually I’ve had the majority of the widget done, and simplified for more than half that time, but I’ve been struggling with one issue since; how to get the rich text from the tinyMCE instance into the textarea on form submit so it will be saved. And let me tell you… it’s been a tail of one annoying discovery after another.
First let me say that the new widget API is impressively simple and a breeze to work with, however in many ways it reminds me of the iPhone, fantastic so long as all you need to do is what the original engineers thought you would ever want to do. In other words it has some limitations, and they’re mainly around the wp-admin/widgets.php page itself instead of the api.
Where to start?
Each widget admin form is rendered in it’s own form, fantastic, but the form has no id or name, boo. It took me a ridiculous amount of time to figure out the correct jQuery foo to get the form encompassing the current widget so that I could try and add a submit hook. Which brings us to the next issue, try as I might I could not find a way to actually catch the form submit event and force the tinyMCE widget to copy the html to the textarea. I soon discovered that this was because the form is never action submited, in fact the widgets admin page wires the ajax request to the onclick event of the save button. That’s right, rather than adding an onsubmit event handler to catch the form and ajax-ify it, they use an onclick event. If they’d actually used the form submit event then the tinyMCE auto detection would have worked on it’s own.
So as it stands we have a whole bunch of html foms with no id’s or names, which are ajax-submitted by an onclick event of the button. Not the best way to do it, but workable. So the next step is to register an onclick event hook on the button using jQuery and just force the tinyMCE.triggerSave() call in there.
Nope. That won’t work either, since jQuery fires all the click event’s asynchronously and the generic form submission click event is bound before my custom event. There is no way in jQuery to reorder the event bindings, you can only unbind them and add your own. Dirty, dirty, dirty.
I’m going to digress now to talk about Anthem.Net, an ajax library that knew how to integrate on both the client and server. Anthem did ajax exactly as I’d expected it above, it caught the form submit event, built an asynch request, fired it off and then updated the page with the new content. This conversion of a .net form postback concept to an ajax mechanism was named a callback in Anthem terminology, and Anthem provided a way to catch the event on both the client and server. On the client side it provided another event called onprecallback (or similarly named), which would allow the developer to hook in any client side code that needed to be run before the form was submitted. I was sorely missing this feature while working on this widget.
So now to the widget, what I have to do is unbind the save button’s click event, bind my own event that does the tinyMCE.triggerSave() call and manually call whatever functions it was that the save button’s click event was meant to call.
Not a clean solution at all, but it works
So I installed the WordPress Mobile Edition plugin. I tested it on my iPhone and it seems to work rather well. Not sure about how good the default user agent matches are though.
I’m disappointed that this plugin uses yet another theme engine (Carrington as opposed to K2).
Let me know in the comments if your phone doesn’t render nicely or you experience other issues.
So the site style is largely there now.
I still have to tweak some subtleties (text and link corlours as well as header sizes), but it’s still pretty indicative of what the intended design was to look like.
K2 made this job far more easier than I thought it would be, though I did have a few issues with it’s use of padding css. In my experience padding and cross-browser design just don’t go together. You better served to try and make the design work with margins.
Thanks to my friend Joe Smith, for the original inspiration for this site’s current look and feel

About Me widget working in WordPress 2.7
So I’ve been doing some spot cleaning in preparation for the new look and got side tracked making the rich text editor work in the about me widget on wordpress 2.7.
I thought I should share it with the rest of the world, so I guess I’ll add a zip file containing the widget to this post. The question is, do I go through all the effort of adding it to the wordpress plugin directory, and if so do I add it as a new plugin?
Download: About Me Widget for WordPress 2.7 (247)
Update: Make sure not to change the folder name in the plugins folder as there is a hard-coded reference to it as in this comment.
P.S. If you do download it, please leave a comment to let me know how it goes for you.
Final Update (20 Oct 09): I have updated this plugin to work in the new WordPress Widget API (as of 2.8.2). Rather than host the download here I have updated the plugin at the WordPress plugin repository. See this blog entry. For now, I’ve closed comments on this blog entry, please leave any comments in the new entry.
Going to be moving my blog to the K2 theme in preparation for application of my new blog design.
In the interim it will be this boring default style.
Loving the WordPress Auto Updater plugin. Just upgraded from 2.5 to 2.61 without having to download or manually back up a thing. took 5 minutes tops. Fantastic.
Even backedup and brought accross my customised plugins and themes.
I caved and got one. Will give it a few months before I consider going back to a more fuller featured phone.
The first app I installed was the worspress app that this post was made from.
Recent Comments