我设法订购了链接管理器。通过使用以下内容的自定义列创建php:
/*
* Sort links using the custom column link_image
*/
function sort_on_field(&$objects, $on, $order = \'ASC\') {
$comparer = ($order === \'DESC\')
? "return -strcmp(\\$a->{$on},\\$b->{$on});"
: "return strcmp(\\$a->{$on},\\$b->{$on});";
usort($objects, create_function(\'$a,$b\', $comparer));
}
function brsfl_link_manager_order($links) {
global $current_screen;
if($current_screen->id == \'link-manager\' && $_GET[\'orderby\'] == \'link_image\') {
$order = ($_GET[\'order\'] === \'asc\') ? \'ASC\' : \'DESC\';
sort_on_field($links, \'link_image\', $order);
}
return $links;
}
if(is_admin()) add_filter(\'get_bookmarks\',\'brsfl_link_manager_order\');
对于站点。php清单,事情似乎更棘手。。。我找到了一个
interesting code 在里面
this thread, 但最终使其与:
public function callback_for_plugins_loaded()
{
global $pagenow;
if(
is_super_admin()
&& \'sites.php\' == $pagenow
&& isset( $_GET[\'orderby\'] ) && \'site-category\' == $_GET[\'orderby\']
)
add_filter( \'query\', array( $this, \'filter_site_query\' ) );
}
public function filter_site_query( $query )
{
global $wpdb;
$search_query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = \'1\' LIMIT 0, 20";
if( isset( $_GET[\'order\'] ) )
$order = ( \'asc\' == $_GET[\'order\'] ) ? \'ASC\' : \'DESC\';
else
$order = \'DESC\';
if( strpos( $query, $search_query ) !== FALSE )
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = \'1\' ORDER BY mature $order LIMIT 0, 20";
return $query;
}
我正在使用该列
wp_blogs.mature
作为
index for site categories. 我想可以进行更复杂的查询,但现在该列似乎没问题。