Ticket #45035: 45035_patch.diff
File 45035_patch.diff, 3.2 KB (added by , 5 years ago) |
---|
-
wp-admin/includes/dashboard.php
264 264 <div class="main"> 265 265 <ul> 266 266 <?php 267 // Posts and Pages268 foreach ( array( 'post', 'page') as $post_type ) {267 // At a Glance Post Types 268 foreach ( get_post_types( array( 'at_a_glance' => true ) ) as $post_type ) { 269 269 $num_posts = wp_count_posts( $post_type ); 270 270 if ( $num_posts && $num_posts->publish ) { 271 if ( 'post' == $post_type ) { 272 $text = _n( '%s Post', '%s Posts', $num_posts->publish ); 273 } else { 274 $text = _n( '%s Page', '%s Pages', $num_posts->publish ); 271 $post_type_object = get_post_type_object( $post_type ); 272 if ( ! $post_type_object ) { 273 continue; 275 274 } 276 $ text = sprintf( $text, number_format_i18n( $num_posts->publish ) );277 $ post_type_object = get_post_type_object( $post_type);275 $post_label = 1 === intval( $num_posts->publish ) ? $post_type_object->labels->singular_name : $post_type_object->labels->name; 276 $text = sprintf( '%s %s', number_format_i18n( $num_posts->publish ), $post_label ); 278 277 if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { 279 278 printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text ); 280 279 } else { -
wp-includes/class-wp-post-type.php
128 128 public $show_in_menu = null; 129 129 130 130 /** 131 * Makes this post type visible in the At a Glance dashboard widget. 132 * 133 * Default is the value of $show_in_menu. 134 * 135 * @var bool $at_a_glance 136 */ 137 public $at_a_glance = null; 138 139 /** 131 140 * Makes this post type available for selection in navigation menus. 132 141 * 133 142 * Default is the value $public. … … 405 414 'show_in_rest' => false, 406 415 'rest_base' => false, 407 416 'rest_controller_class' => false, 417 'at_a_glance' => null, 408 418 '_builtin' => false, 409 419 '_edit_link' => 'post.php?post=%d', 410 420 ); … … 428 438 $args['show_in_menu'] = $args['show_ui']; 429 439 } 430 440 441 // If not set, default to the setting for show_in_menu 442 if ( null === $args['at_a_glance'] ) { 443 $args['at_a_glance'] = (bool) $args['show_in_menu']; 444 } 445 431 446 // If not set, default to the whether the full UI is shown. 432 447 if ( null === $args['show_in_admin_bar'] ) { 433 448 $args['show_in_admin_bar'] = (bool) $args['show_in_menu']; -
wp-includes/post.php
78 78 ), 79 79 'public' => true, 80 80 'show_ui' => true, 81 'at_a_glance' => false, 81 82 '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ 82 83 '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 83 84 'capability_type' => 'post',