wordpress admin widget reorder
I have being toying with rearranging the order of the admin widgets in开发者_运维知识库 the dashboard with no luck- i need my own custom widget at the top.... Wordpress's own method for doing this (http://codex.wordpress.org/Dashboard_Widgets_API) simply doesnt work...
Anybody have any working ideas?
Thanks!
It doesn't work because there is a call to usort()
at line 23 in includes/widgets.php
that uses strnatcasecmp()
for comparisons. There is no obvious way to override or change this call.
One possible workaround would be to do a little hackery that removes your widget from $wp_registered_widgets
and then re-inserts it with a name that begins with a space, thereby putting it at the top of the sort order. Note: I have not tried doing this, and there may be other things that break using this approach, but there aren't a whole lot of other options short of hacking the core file itself, which is a Bad Thing®.
Ps: Since the sort takes a string arg, I have one nasty thought involving an on-the-fly search and replace in the core code itself ... nah, that would involve Flying Monkey Patching™, which means Flying Monkeys, and you know what happened to Dorothy. Better to not go there.
精彩评论