diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index 5d24c39a62..0dad59b4dd 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -84,21 +84,45 @@ $messages = array(); /** This filter is documented in wp-admin/includes/meta-boxes.php */ $post_preview_url = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $permalink ), $post ); +$preview_link_html = $scheduled_link_html = $view_post_html = ''; + +$viewable = is_post_type_viewable( $post_type_object ); + +if ( $viewable ) { + // Preview link. + $preview_link_html = sprintf( ' %s', + esc_url( $post_preview_url ), + __( 'Preview post' ) + ); + + // Scheduled preview link. + $scheduled_link_html = sprintf( ' %s', + esc_url( $permalink ), + __( 'Preview post' ) + ); + + // View post link. + $view_post_html = sprintf( ' ">%', + esc_url( $permalink ), + __( 'View post' ) + ); +} + +/* translators: Publish box date format, see http://php.net/date */ +$scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) ); $messages['post'] = array( 0 => '', // Unused. Messages start at index 1. - 1 => sprintf( __('Post updated. View post'), esc_url( $permalink ) ), + 1 => __( 'Post updated.' ) . $view_post_html, 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Post updated.'), /* translators: %s: date and time of the revision */ 5 => isset($_GET['revision']) ? sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => sprintf( __('Post published. View post'), esc_url( $permalink ) ), + 6 => __( 'Post published.' ) . $view_post_html, 7 => __('Post saved.'), - 8 => sprintf( __('Post submitted. Preview post'), esc_url( $post_preview_url ) ), - 9 => sprintf( __('Post scheduled for: %1$s. Preview post'), - /* translators: Publish box date format, see http://php.net/date */ - date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ), - 10 => sprintf( __('Post draft updated. Preview post'), esc_url( $post_preview_url ) ), + 8 => __( 'Post submitted.' ) . $preview_link_html, + 9 => sprintf( __( 'Post scheduled for: %1$s' ), $scheduled_date ) . $scheduled_link_html, + 10 => __( 'Post draft updated.' ) . $preview_link_html, ); /** This filter is documented in wp-admin/includes/meta-boxes.php */ @@ -508,6 +532,7 @@ do_action( 'edit_form_before_permalink', $post ); ?>
public ? get_sample_permalink_html($post->ID) : ''; $shortlink = wp_get_shortlink($post->ID, 'post'); @@ -525,6 +550,7 @@ if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !
ID, '', true ) . "'>" . __( 'Delete Permanently' ) . ""; } - if ( $post_type_object->public ) { + if ( is_post_type_viewable( $post_type_object ) ) { $title = _draft_or_post_title(); if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { if ( $can_edit_post ) { diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index a7a895a194..59e9fc3f7a 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -31,12 +31,13 @@ function post_submit_meta_box($post, $args = array() ) {
post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> post_status ) { ?>style="display:none" type="submit" name="save" id="save-post" value="" class="button" /> + post_status && $can_publish ) { ?> - +
-public ) : ?> +
post_status ) { diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index e09e1de876..0cb1169a6c 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -1843,6 +1843,21 @@ function set_post_type( $post_id = 0, $post_type = 'post' ) { return $return; } +/** + * Determines whether a post type is considered "viewable". + * + * For built-in post types such as posts and pages, the 'public' value will be evaluated. + * For all others, the 'publicly_queryable' value will be used. + * + * @since 4.4.0 + * + * @param object $post_type_object Post type object. + * @return bool Whether the post type should be considered viewable. + */ +function is_post_type_viewable( $post_type_object ) { + return $post_type_object->publicly_queryable || ( $post_type_object->_builtin && $post_type_object->public ); +} + /** * Retrieve list of latest posts or posts matching criteria. *