WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/25/2019 09:51:00 PM (8 weeks ago)
Author:
whyisjake
Message:

Menus: Duplicate Page Entry in View All Pages when generating a Menu

Simplifies the interface in menu creation.

Fixes [37782]
Props garrett-eclipse, mdgl, birgire, xkon, audrasjb, pento, girlieworks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/template.php

    r46137 r46309  
    20632063
    20642064/**
    2065  * @param WP_Post $post
    2066  */
    2067 function _post_states( $post ) {
     2065 * Function to echo or return the Post States as HTML.
     2066 *
     2067 * @since 2.7.0
     2068 * @since 5.3.0 Adopted use of get_post_states
     2069 *
     2070 * @param WP_Post $post The post to retrieve states for.
     2071 * @param boolean $echo Optional. Whether to echo or return the Post States as an HTML string. Default true for echo.
     2072 *
     2073 * @return string|void Post States string when echo is false.
     2074 */
     2075function _post_states( $post, $echo = true ) {
     2076    $post_states        = get_post_states( $post );
     2077    $post_states_string = '';
     2078
     2079    if ( ! empty( $post_states ) ) {
     2080        $state_count = count( $post_states );
     2081        $i           = 0;
     2082
     2083        $post_states_string .= ' — ';
     2084        foreach ( $post_states as $state ) {
     2085            ++$i;
     2086            ( $i == $state_count ) ? $sep = '' : $sep = ', ';
     2087            $post_states_string          .= "<span class='post-state'>$state$sep</span>";
     2088        }
     2089    }
     2090
     2091    if ( $echo ) {
     2092        echo $post_states_string;
     2093    }
     2094
     2095    return $post_states_string;
     2096}
     2097
     2098/**
     2099 * Function to retrieve an array of Post States from a Post.
     2100 *
     2101 * @since 5.3.0
     2102 *
     2103 * @param WP_Post $post The post to retrieve states for.
     2104 *
     2105 * @return array $post_states The array of translated post states.
     2106 *
     2107 */
     2108function get_post_states( $post ) {
    20682109    $post_states = array();
    20692110    if ( isset( $_REQUEST['post_status'] ) ) {
     
    20742115
    20752116    if ( ! empty( $post->post_password ) ) {
    2076         $post_states['protected'] = __( 'Password protected' );
    2077     }
     2117        $post_states['protected'] = _x( 'Password protected', 'post status' );
     2118    }
     2119
    20782120    if ( 'private' == $post->post_status && 'private' != $post_status ) {
    2079         $post_states['private'] = __( 'Private' );
    2080     }
     2121        $post_states['private'] = _x( 'Private', 'post status' );
     2122    }
     2123
    20812124    if ( 'draft' === $post->post_status ) {
    20822125        if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
    20832126            $post_states[] = __( 'Customization Draft' );
    20842127        } elseif ( 'draft' !== $post_status ) {
    2085             $post_states['draft'] = __( 'Draft' );
     2128            $post_states['draft'] = _x( 'Draft', 'post status' );
    20862129        }
    20872130    } elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
    2088         $post_states[] = __( 'Customization Draft' );
    2089     }
     2131        $post_states[] = _x( 'Customization Draft', 'post status' );
     2132    }
     2133
    20902134    if ( 'pending' == $post->post_status && 'pending' != $post_status ) {
    20912135        $post_states['pending'] = _x( 'Pending', 'post status' );
    20922136    }
     2137
    20932138    if ( is_sticky( $post->ID ) ) {
    2094         $post_states['sticky'] = __( 'Sticky' );
     2139        $post_states['sticky'] = _x( 'Sticky', 'post status' );
    20952140    }
    20962141
    20972142    if ( 'future' === $post->post_status ) {
    2098         $post_states['scheduled'] = __( 'Scheduled' );
     2143        $post_states['scheduled'] = _x( 'Scheduled', 'post status' );
    20992144    }
    21002145
    21012146    if ( 'page' === get_option( 'show_on_front' ) ) {
    21022147        if ( intval( get_option( 'page_on_front' ) ) === $post->ID ) {
    2103             $post_states['page_on_front'] = __( 'Front Page' );
     2148            $post_states['page_on_front'] = _x( 'Front Page', 'page label' );
    21042149        }
    21052150
    21062151        if ( intval( get_option( 'page_for_posts' ) ) === $post->ID ) {
    2107             $post_states['page_for_posts'] = __( 'Posts Page' );
     2152            $post_states['page_for_posts'] = _x( 'Posts Page', 'page label' );
    21082153        }
    21092154    }
    21102155
    21112156    if ( intval( get_option( 'wp_page_for_privacy_policy' ) ) === $post->ID ) {
    2112         $post_states['page_for_privacy_policy'] = __( 'Privacy Policy Page' );
     2157        $post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' );
    21132158    }
    21142159
     
    21222167     * @param WP_Post  $post        The current post object.
    21232168     */
    2124     $post_states = apply_filters( 'display_post_states', $post_states, $post );
    2125 
    2126     if ( ! empty( $post_states ) ) {
    2127         $state_count = count( $post_states );
    2128         $i           = 0;
    2129         echo ' &mdash; ';
    2130         foreach ( $post_states as $state ) {
    2131             ++$i;
    2132             ( $i == $state_count ) ? $sep = '' : $sep = ', ';
    2133             echo "<span class='post-state'>$state$sep</span>";
    2134         }
    2135     }
    2136 
     2169    return apply_filters( 'display_post_states', $post_states, $post );
    21372170}
    21382171
Note: See TracChangeset for help on using the changeset viewer.