[wp-hackers] Accordion widget for wordpress

Ozh ozh at planetozh.com
Tue Nov 13 19:59:15 GMT 2007


On Nov 13, 2007 6:47 PM, dayaparan ponnambalam <daya at meyshan.com> wrote:
> Please comment on my new wordpress widget, that uses jquery accordion to
> enhance wordpress blog sidebar with tabbed browsing to inbuild upto 6
> plugins. You can see more details and the demo
> here<http://www.spicyexpress.net/general/accordion-the-new-wordpress-ajax-widget-to-enhance-your-sidebar-functions/>


My 2 cents, in no particular order, as I read your plugin source
(didn't try it). Consider that each of the following points starts
with "in my humble opinion" :)

- function widget_accordion_init() seems mostly useless: $option is
always undefined, so adding option then immediately getting option is
pointless

- $here in function accordion_head() is hardcoded, which is bad: if a
user renames the directory, the plugin breaks. Let the plugin guess
its own directory using plugin_basename() or something similar

- jquery is bundled with most WP version, so it's a waste of bandwidth
to include your own. Also, it's better to use wp_enqueue_script() to
add a javascript. This way you make sure it's loaded once. This is a
nice wrap up for this:
<http://nickohrn.com/loading-javascript-libraries-in-wordpress-plugins-with-wp_enqueue_script/>

- it's always a good habit to make good use of nonces &
attribute_escape() when playing with POST stuff. Nice tutorial about
this: <http://blogsecurity.net/wordpress/articles/article-280507/>

- const NUM_PLUGINS look like a candidate for a widget option, why hardcode it ?

- you're using jquery, but you're javascript is plain old stuff.
document.getElementById("accordion-" + n) instead of
jQuery('#accordion-'+n) or el.style.display = "block" instead of
jQuery(this).show(), etc... You can make your javascript shorter and
cuter.

- the plugin could also be less intrusive and more nicely degradable
(when doing stuff with JS, think "how things are going to look like
with JS disabled, or when the page is printed")
For instance, instead of :
<a href="#" onclick="dostuff()">
which is confusing with JS disabled, you can preferably do:
<span id="dostuff">
and:
jQuery('#dostuff').click(function(){dostuff();});
which is much less intrusive since it degrades to correct html with no JS.
It would make sense to me that when there is no JS, the 3 tab contents
from your accordion are displayed, or the 2 tabs with hidden content
are hidden too (it makes no sense to have an empty link on "Comment"
that does nothing when clicked)

</my 2 cents>

Cheers

Ozh

-- 
http://FrenchFragFactory.net ~ Daily Quake News
http://planetOzh.com ~ Blog and WordPress Stuff


More information about the wp-hackers mailing list