Lose the snack menu. see #14772

git-svn-id: http://svn.automattic.com/wordpress/trunk@16055 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-10-28 17:29:44 +00:00
parent ec51413035
commit d4ef5a4029
1 changed files with 0 additions and 136 deletions

View File

@ -10,8 +10,6 @@ function wp_admin_bar_superadmin_settings_menu() {
/* Add the main superadmin menu item */ /* Add the main superadmin menu item */
$wp_admin_bar->add_menu( array( 'id' => 'superadmin', 'title' => 'μ', 'href' => '', 'meta' => array( 'class' => 'ab-sadmin' ), ) ); $wp_admin_bar->add_menu( array( 'id' => 'superadmin', 'title' => 'μ', 'href' => '', 'meta' => array( 'class' => 'ab-sadmin' ), ) );
wp_admin_bar_build_snackmenu();
/* Get the settings we need for the current site */ /* Get the settings we need for the current site */
$matureaction = $current_blog->mature ? 'unmatureblog' : 'matureblog'; $matureaction = $current_blog->mature ? 'unmatureblog' : 'matureblog';
$maturetext_confirm = $current_blog->mature ? $maturetext_confirm = $current_blog->mature ?
@ -45,138 +43,4 @@ function wp_admin_bar_superadmin_settings_menu() {
$wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => ( $current_blog->spam ? __('Unsuspend site') : __('Suspend site') ), 'href' => $suspend_url, 'position' => 80, ) ); $wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => ( $current_blog->spam ? __('Unsuspend site') : __('Suspend site') ), 'href' => $suspend_url, 'position' => 80, ) );
} }
function wp_admin_bar_build_snackmenu() {
global $wp_admin_bar, $menu, $submenu, $pagenow;
// Hide moderation count, filter removed at the bottom of this function
add_filter( 'wp_count_comments', 'wp_admin_bar_removemodcount' );
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
// menu.php assumes it is in the global scope and relies on the $wp_taxonomies global array
$wp_taxonomies = array();
require_once( ABSPATH . 'wp-admin/menu.php' );
/* Add the snack menu submenu to the superadmin menu */
$wp_admin_bar->add_menu( array( 'parent' => 'superadmin', 'title' => __( 'Snack Menu' ), 'href' => '/wp-admin/',) );
/* Loop through the submenus and add them */
foreach ( (array) $menu as $key => $item ) {
$admin_is_parent = false;
$submenu_as_parent = false;
if ( $submenu_as_parent && !empty($submenu[$item[2]]) ) {
$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
$menu_file = $submenu[$item[2]][0][2];
if ( false !== $pos = strpos($menu_file, '?') )
$menu_file = substr($menu_file, 0, $pos);
if (
(
'index.php' != $submenu[$item[2]][0][2] &&
file_exists( WP_PLUGIN_DIR . "/$menu_file" )
) ||
! empty( $menu_hook )
) {
$admin_is_parent = true;
$wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("admin.php?page={$submenu[$item[2]][0][2]}"), ) );
} else {
$wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("{$submenu[$item[2]][0][2]}"), ) );
}
} else if ( current_user_can($item[1]) ) {
$menu_hook = get_plugin_page_hook($item[2], 'admin.php');
$menu_file = $item[2];
if ( false !== $pos = strpos($menu_file, '?') )
$menu_file = substr($menu_file, 0, $pos);
if (
(
'index.php' != $item[2] &&
file_exists( WP_PLUGIN_DIR . "/$menu_file" )
) ||
! empty($menu_hook)
) {
$admin_is_parent = true;
$wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("admin.php?page={$item[2]}"), ) );
} else {
$wp_admin_bar->add_menu( array( 'parent' => 'snack-menu', 'title' => $item[0], 'href' => admin_url("{$item[2]}"), ) );
}
}
if ( ! empty($submenu[$item[2]]) ) {
$first = true;
$unique_submenu = array();
foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) {
if ( !current_user_can($sub_item[1]) || in_array( $sub_item[0], $unique_submenu ) )
continue;
$unique_submenu[] = $sub_item[0];
if ( $first )
$first = false;
$menu_file = $item[2];
if ( false !== $pos = strpos($menu_file, '?') )
$menu_file = substr($menu_file, 0, $pos);
$menu_hook = get_plugin_page_hook($sub_item[2], $item[2]);
$sub_file = $sub_item[2];
if ( false !== $pos = strpos($sub_file, '?') )
$sub_file = substr($sub_file, 0, $pos);
if (
(
'index.php' != $sub_item[2] &&
file_exists( WP_PLUGIN_DIR . "/$sub_file" )
) ||
! empty($menu_hook)
) {
// If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
if (
(
! $admin_is_parent &&
file_exists(WP_PLUGIN_DIR . "/$menu_file") &&
! is_dir(WP_PLUGIN_DIR . "/{$item[2]}")
) ||
file_exists( $menu_file )
) {
$wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$item[2]}?page={$sub_item[2]}"), ) );
} else {
$wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("admin.php?page={$sub_item[2]}"), ) );
}
} else {
$wp_admin_bar->add_menu( array( 'parent' => sanitize_title( $item[0] ), 'title' => $sub_item[0], 'href' => admin_url("{$sub_item[2]}"), ) );
}
}
}
}
remove_filter( 'wp_count_comments', 'wp_admin_bar_removemodcount' );
}
// Short circuits wp_count_comments() for the front end
function wp_admin_bar_removemodcount( $stats ) {
if ( is_admin() )
return $stats;
$stats = array(
'moderated' => 0,
'approved' => 0,
'spam' => 0,
'trash' => 0,
'post-trashed' => 0,
'total_comments' => 0,
);
return (object) $stats;
}
?> ?>