Ticket #15406: 15406.diff
File 15406.diff, 2.9 KB (added by , 9 years ago) |
---|
-
menu.php
46 46 47 47 $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); 48 48 49 $menu[5] = array( __('Posts') , 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'dashicons-admin-post' );49 $menu[5] = array( __('Posts') . pending_posts_bubble( 'post' ), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'dashicons-admin-post' ); 50 50 $submenu['edit.php'][5] = array( __('All Posts'), 'edit_posts', 'edit.php' ); 51 51 /* translators: add new post */ 52 52 $submenu['edit.php'][10] = array( _x('Add New', 'post'), get_post_type_object( 'post' )->cap->create_posts, 'post-new.php' ); … … 129 129 while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) ) 130 130 $ptype_menu_position++; 131 131 132 $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ) , $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-posts-' . $ptype_for_id, $menu_icon );132 $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ) . pending_posts_bubble( $ptype ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-posts-' . $ptype_for_id, $menu_icon ); 133 133 $submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype"); 134 134 $submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, "post-new.php?post_type=$ptype" ); 135 135 -
includes/post.php
1659 1659 return wp_create_post_autosave( wp_slash( $post_data ) ); 1660 1660 } 1661 1661 } 1662 1663 /** 1664 * Generates a bubble with the number of "pending" posts from a given post type. 1665 * 1666 * @param string $post_type The post type slug for which we're displaying the bubble 1667 * 1668 * @return mixed NULL on non-existing post type, false if user can't publish posts, 1669 * empty string if there are no pending posts, HTML with count otherwise. 1670 */ 1671 function pending_posts_bubble( $post_type ) { 1672 $post_type_object = get_post_type_object( $post_type ); 1673 1674 if ( ! $post_type_object ) { 1675 return null; 1676 } 1677 1678 if ( ! current_user_can( $post_type_object->cap->publish_posts ) ) { 1679 return false; 1680 } 1681 1682 $counts = wp_count_posts( $post_type, 'readable' ); 1683 1684 $bubble = ''; 1685 1686 // Make sure there are pending posts 1687 if ( isset( $counts->pending ) ) { 1688 $bubble = " <span class='update-plugins count-{$counts->pending}'><span class='update-count'>" . number_format_i18n( $counts->pending ) . "</span></span>"; 1689 } 1690 1691 return $bubble; 1692 }