[wp-hackers] Enforce Alpahabetical Ordering of Plugin & Options
Page
Sam Angove
sam at rephrase.net
Mon Jun 19 03:58:35 GMT 2006
On 6/19/06, Computer Guru <ComputerGuru at neosmart.net> wrote:
>
> but the code used to add a
> tab might break if you alphabetize the tabs page, no?
Not really. I assume you're talking about the menus and submenus, and
they're just a pair of global variables, $menu and $submenu. Pick a
hook somewhere after the plugin menus have been added and sort away.
Something like:
<?php
/*
Plugin Name: Alphabet Options
Description: Alphabetize "options" submenus
Version: 1
Plugin URI: http://rephrase.net/miscellany/06/alphabetoptions.phps
*/
function alphabetMenu() {
global $submenu;
usort($submenu['options-general.php'], 'alphabetMenuSort');
}
function alphabetMenuSort( $a, $b ) {
return strcmp( $a[0], $b[0] );
}
add_action('admin_head', 'alphabetMenu');
?>
More information about the wp-hackers
mailing list