From bc9e544b978d2305c92600aaeec7665b8a550535 Mon Sep 17 00:00:00 2001 From: Ozh Date: Wed, 9 Jan 2013 10:07:26 +0000 Subject: [PATCH] Plugin management page: now properly sorted by name. git-svn-id: http://yourls.googlecode.com/svn/trunk@833 12232710-3e20-11de-b438-597f59cd7555 --- admin/plugins.php | 2 ++ includes/functions-plugins.php | 28 +++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/admin/plugins.php b/admin/plugins.php index 8aea3d3..0a6ab90 100644 --- a/admin/plugins.php +++ b/admin/plugins.php @@ -61,6 +61,8 @@ diff --git a/includes/functions-plugins.php b/includes/functions-plugins.php index e74c5ab..ae7dc9f 100644 --- a/includes/functions-plugins.php +++ b/includes/functions-plugins.php @@ -550,4 +550,30 @@ function yourls_plugin_admin_page( $plugin_page ) { yourls_html_footer(); die(); -} \ No newline at end of file +} + + +/** + * Callback function: Sort plugins + * + * @link http://php.net/uasort + * + * @param array $plugin_a + * @param array $plugin_b + * @return int 0, 1 or -1, see uasort() + */ +function yourls_plugins_sort_callback( $plugin_a, $plugin_b ) { + $orderby = yourls_apply_filters( 'plugins_sort_callback', 'Plugin Name' ); + $order = yourls_apply_filters( 'plugins_sort_callback', 'ASC' ); + + $a = $plugin_a[$orderby]; + $b = $plugin_b[$orderby]; + + if ( $a == $b ) + return 0; + + if ( 'DESC' == $order ) + return ( $a < $b ) ? 1 : -1; + else + return ( $a < $b ) ? -1 : 1; +} -- 2.45.0