WordPress.org

Make WordPress Core

Ticket #15597: 15597.patch

File 15597.patch, 2.7 KB (added by ocean90, 8 years ago)
  • wp-includes/admin-bar.php

     
    135135                if ( ! isset( $blog->visible ) || $blog->visible === true ) {
    136136                        $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname,  'href' => get_admin_url($blog->userblog_id), ) );
    137137                        $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => get_admin_url($blog->userblog_id), ) );
    138                         $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => get_admin_url($blog->userblog_id, 'post-new.php'), ) );
     138                        if ( current_user_can_for_blog( $blog->userblog_id, 'edit_posts' ) )
     139                                $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => get_admin_url($blog->userblog_id, 'edit-comments.php'), ) );
    139140
    140                         $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => get_admin_url($blog->userblog_id, 'edit-comments.php'), ) );
    141                         $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Visit Site' ), 'href' => get_home_url($blog->userblog_id), ) );
     141                       
     142                        $actions = array();
     143                        foreach ( (array) get_post_types( array( 'show_ui' => true ), 'objects' ) as $ptype_obj ) {
     144                                if ( true !== $ptype_obj->show_in_menu || ! current_user_can_for_blog( $blog->userblog_id, $ptype_obj->cap->edit_posts ) )
     145                                        continue;
     146
     147                                $actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->singular_name, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name );
     148                        }
     149
     150                        if ( ! empty( $actions ) ) {
     151                                $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => _x( 'Add New', 'admin bar menu group label' ), 'href' => '', ) );
     152
     153                                foreach ( $actions as $link => $action )
     154                                        $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id . '-n', 'id' => 'blog-' . $blog->userblog_id . '-' . $action[2], 'title' => $action[0], 'href' => admin_url($link) ) );
     155                        }
     156
     157                $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Visit Site' ), 'href' => get_home_url($blog->userblog_id), ) );
    142158                }
    143159        }
    144160}