Ticket #37782: 37782.10.diff
File 37782.10.diff, 9.1 KB (added by , 6 years ago) |
---|
-
src/wp-admin/css/nav-menus.css
diff --git a/src/wp-admin/css/nav-menus.css b/src/wp-admin/css/nav-menus.css index 90c72ec95a..87b5f22f59 100644
a b ul.add-menu-item-tabs li { 413 413 margin-top: -4px; 414 414 } 415 415 416 .menu-item-title .post-state { 417 font-weight: 600; 418 } 419 416 420 /* Nav Menu */ 417 421 #menu-container .inside { 418 422 padding-bottom: 10px; -
src/wp-admin/includes/class-walker-nav-menu-checklist.php
diff --git a/src/wp-admin/includes/class-walker-nav-menu-checklist.php b/src/wp-admin/includes/class-walker-nav-menu-checklist.php index 994cc040f3..08044c6321 100644
a b class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { 94 94 } elseif ( isset( $item->post_type ) ) { 95 95 /** This filter is documented in wp-includes/post-template.php */ 96 96 $title = apply_filters( 'the_title', $item->post_title, $item->ID ); 97 if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) {98 /* translators: %s: front page title */99 $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title );100 }101 97 } 102 98 103 99 $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title ); 100 101 if ( empty( $item->label ) && isset( $item->post_type ) && 'page' === $item->post_type ) { 102 /** Append post states */ 103 $output .= _post_states( $item, false ); 104 } 105 104 106 $output .= '</label>'; 105 107 106 108 // Menu item hidden fields -
src/wp-admin/includes/nav-menu.php
diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index 0539e7f253..e9beb914c9 100644
a b function wp_nav_menu_item_post_type_meta_box( $object, $box ) { 354 354 $args = array_merge( $args, (array) $box['args']->_default_query ); 355 355 } 356 356 357 /* 358 * If we're dealing with pages, let's prioritize the Front Page, 359 * Posts Page and Privacy Policy Page at the top of the list. 360 */ 361 $important_pages = array(); 362 if ( 'page' == $post_type_name ) { 363 $suppress_page_ids = array(); 364 365 $front_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; 366 $posts_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; 367 368 $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); 369 $privacy_policy_page_available = false; 370 371 if ( ! empty( $privacy_policy_page_id ) ) { 372 $privacy_policy_page = get_post( $privacy_policy_page_id ); 373 $privacy_policy_page_available = ( $privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status ); 374 } 375 376 /* 377 * Insert Front Page or custom home link. 378 */ 379 $front_page_obj = null; 380 if ( ! empty( $front_page ) ) { 381 $front_page_obj = get_post( $front_page ); 382 $front_page_obj->front_or_home = true; 383 384 $important_pages[] = $front_page_obj; 385 $suppress_page_ids[] = $front_page_obj->ID; 386 } else { 387 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1; 388 $front_page_obj = (object) array( 389 'front_or_home' => true, 390 'ID' => 0, 391 'object_id' => $_nav_menu_placeholder, 392 'post_content' => '', 393 'post_excerpt' => '', 394 'post_parent' => '', 395 'post_title' => _x( 'Home', 'nav menu home label' ), 396 'post_type' => 'nav_menu_item', 397 'type' => 'custom', 398 'url' => home_url( '/' ), 399 ); 400 401 $important_pages[] = $front_page_obj; 402 } 403 404 /* 405 * Insert Posts Page. 406 */ 407 if ( ! empty( $posts_page ) ) { 408 $posts_page_obj = get_post( $posts_page ); 409 $posts_page_obj->posts_page = true; 410 411 $important_pages[] = $posts_page_obj; 412 $suppress_page_ids[] = $posts_page_obj->ID; 413 } 414 415 /* 416 * Insert Privacy Page. 417 */ 418 if ( $privacy_policy_page_available ) { 419 $privacy_policy_page_obj = get_post( $privacy_policy_page_id ); 420 $privacy_policy_page_obj->privacy_policy_page = true; 421 422 $important_pages[] = $privacy_policy_page_obj; 423 $suppress_page_ids[] = $privacy_policy_page_obj->ID; 424 } 425 426 /* 427 * Add suppression array to arguments for WP_Query 428 */ 429 if ( ! empty( $suppress_page_ids ) ) { 430 $args['post__not_in'] = $suppress_page_ids; 431 } 432 } 433 357 434 // @todo transient caching of these results with proper invalidation on updating of a post of this type 358 435 $get_posts = new WP_Query; 359 436 $posts = $get_posts->query( $args ); 437 438 /** Only suppress and insert when more than just suppression pages available */ 360 439 if ( ! $get_posts->post_count ) { 361 echo '<p>' . __( 'No items.' ) . '</p>'; 362 return; 440 if ( ! empty( $suppress_page_ids ) ) { 441 unset( $args['post__not_in'] ); 442 $get_posts = new WP_Query; 443 $posts = $get_posts->query( $args ); 444 } else { 445 echo '<p>' . __( 'No items.' ) . '</p>'; 446 return; 447 } 448 } else { 449 if ( ! empty( $important_pages ) ) { 450 $posts = array_merge( $important_pages, $posts ); 451 } 363 452 } 364 453 365 454 $num_pages = $get_posts->max_num_pages; … … function wp_nav_menu_item_post_type_meta_box( $object, $box ) { 520 609 <?php 521 610 $args['walker'] = $walker; 522 611 523 /*524 * If we're dealing with pages, let's put a checkbox for the front525 * page at the top of the list.526 */527 if ( 'page' == $post_type_name ) {528 $front_page = 'page' == get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0;529 if ( ! empty( $front_page ) ) {530 $front_page_obj = get_post( $front_page );531 $front_page_obj->front_or_home = true;532 array_unshift( $posts, $front_page_obj );533 } else {534 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;535 array_unshift(536 $posts,537 (object) array(538 'front_or_home' => true,539 'ID' => 0,540 'object_id' => $_nav_menu_placeholder,541 'post_content' => '',542 'post_excerpt' => '',543 'post_parent' => '',544 'post_title' => _x( 'Home', 'nav menu home label' ),545 'post_type' => 'nav_menu_item',546 'type' => 'custom',547 'url' => home_url( '/' ),548 )549 );550 }551 }552 553 612 $post_type = get_post_type_object( $post_type_name ); 554 613 555 614 if ( $post_type->has_archive ) { -
src/wp-admin/includes/template.php
diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index a06f9228aa..b637b90cea 100644
a b function iframe_footer() { 2009 2009 } 2010 2010 2011 2011 /** 2012 * @param WP_Post $post 2012 * @param WP_Post $post The post to retrieve states from 2013 * @param boolean $echo Flag to indicate if post states string should be returned or echo'd. 2014 */ 2015 function _post_states( $post, $echo = true ) { 2016 $post_states = get_post_states( $post ); 2017 $post_states_string = ''; 2018 2019 if ( ! empty( $post_states ) ) { 2020 $state_count = count( $post_states ); 2021 $i = 0; 2022 2023 $post_states_string .= ' — '; 2024 foreach ( $post_states as $state ) { 2025 ++$i; 2026 ( $i == $state_count ) ? $sep = '' : $sep = ', '; 2027 $post_states_string .= "<span class='post-state'>$state$sep</span>"; 2028 } 2029 } 2030 2031 if ( $echo ) { 2032 echo $post_states_string; 2033 } 2034 2035 return $post_states_string; 2036 } 2037 2038 /** 2039 * @param WP_Post $post The post to retrieve states from 2040 * 2041 * @return array $post_states array of translated post states 2042 * 2043 * @since 5.2.0 2013 2044 */ 2014 function _post_states( $post ) {2045 function get_post_states( $post ) { 2015 2046 $post_states = array(); 2016 2047 if ( isset( $_REQUEST['post_status'] ) ) { 2017 2048 $post_status = $_REQUEST['post_status']; … … function _post_states( $post ) { 2022 2053 if ( ! empty( $post->post_password ) ) { 2023 2054 $post_states['protected'] = __( 'Password protected' ); 2024 2055 } 2056 2025 2057 if ( 'private' == $post->post_status && 'private' != $post_status ) { 2026 2058 $post_states['private'] = __( 'Private' ); 2027 2059 } 2060 2028 2061 if ( 'draft' === $post->post_status ) { 2029 2062 if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) { 2030 2063 $post_states[] = __( 'Customization Draft' ); … … function _post_states( $post ) { 2034 2067 } elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) { 2035 2068 $post_states[] = __( 'Customization Draft' ); 2036 2069 } 2070 2037 2071 if ( 'pending' == $post->post_status && 'pending' != $post_status ) { 2038 2072 $post_states['pending'] = _x( 'Pending', 'post status' ); 2039 2073 } 2074 2040 2075 if ( is_sticky( $post->ID ) ) { 2041 2076 $post_states['sticky'] = __( 'Sticky' ); 2042 2077 } … … function _post_states( $post ) { 2068 2103 * @param string[] $post_states An array of post display states. 2069 2104 * @param WP_Post $post The current post object. 2070 2105 */ 2071 $post_states = apply_filters( 'display_post_states', $post_states, $post ); 2072 2073 if ( ! empty( $post_states ) ) { 2074 $state_count = count( $post_states ); 2075 $i = 0; 2076 echo ' — '; 2077 foreach ( $post_states as $state ) { 2078 ++$i; 2079 ( $i == $state_count ) ? $sep = '' : $sep = ', '; 2080 echo "<span class='post-state'>$state$sep</span>"; 2081 } 2082 } 2083 2106 return apply_filters( 'display_post_states', $post_states, $post ); 2084 2107 } 2085 2108 2086 2109 /**