From f11e86fb83bcaeb72c6c030b09139a91022d68d6 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 26 Feb 2015 02:46:40 +0000 Subject: [PATCH] Hide irrelevant UI and display a message when editing the page for posts. Users are frequently confused as to why the content they've entered or the page template they've selected doesn't apply for this one page. Showing and saving items that don't do anything hurts trust. Developers can elect to turn on the editor should they be using it for something. If the content isn't empty, the editor will show so that users still have access to their content. props alexkingorg for the initial, long-suffering patch. fixes #17470. git-svn-id: https://develop.svn.wordpress.org/trunk@31550 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-form-advanced.php | 5 +++++ src/wp-admin/includes/meta-boxes.php | 2 +- src/wp-admin/includes/template.php | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index 912432fbaa..295b96a8f3 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -45,6 +45,11 @@ $post_ID = isset($post_ID) ? (int) $post_ID : 0; $user_ID = isset($user_ID) ? (int) $user_ID : 0; $action = isset($action) ? $action : ''; +if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) { + add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); + remove_post_type_support( $post_type, 'editor' ); +} + $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { if ( 0 === strpos( $post->post_mime_type, 'audio/' ) ) { diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index b99f30cc8f..acd84c30c1 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -739,7 +739,7 @@ function page_attributes_meta_box($post) { post_type && 0 != count( get_page_templates( $post ) ) ) { + if ( 'page' == $post->post_type && 0 != count( get_page_templates( $post ) ) && get_option( 'page_for_posts' ) != $post->ID ) { $template = !empty($post->page_template) ? $post->page_template : false; ?>

diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index c1e362b5a3..8975e03110 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -2169,3 +2169,12 @@ function wp_star_rating( $args = array() ) { echo str_repeat( '
', $empty_stars); echo ''; } + +/** + * Output a notice when editing the page for posts. + * + * @since 4.2.0 + */ +function _wp_posts_page_notice() { + echo '

' . __( 'You are currently editing the page that shows your latest posts.' ) . '

'; +}