Index: wp-admin/includes/post.php
===================================================================
--- wp-admin/includes/post.php (revision 22362)
+++ wp-admin/includes/post.php (working copy)
@@ -1330,6 +1330,27 @@
}
/**
+ * Checks if page on front is set, else shows latests posts
+ *
+ * @since 3.5.0
+ * @access private
+ */
+
+function _show_on_front_cant_create_pages () {
+
+ // If an existing page is set, keep things as is, rather than reverting to showing posts.
+ if ( get_option( 'page_on_front' ) ) {
+ $show_on_front_value = 'page';
+ } else {
+ $show_on_front_value = 'posts';
+ update_option( 'page_on_front', 0 );
+ update_option( 'page_for_posts', 0 );
+ }
+ add_settings_error( 'page_on_front', 'create_pages', __( 'You are not allowed to create pages on this site.' ) );
+ return $show_on_front_value;
+}
+
+/**
* Creates new pages to be set as a front page or a page for posts in Reading Settings.
*
* @todo Make sure we are doing adequate sanitization on success, and cleanup/reset on failure.
@@ -1338,108 +1359,99 @@
* @access private
*/
function _show_on_front_reading_settings( $show_on_front_value ) {
+
// If we're not saving the Reading Settings screen, don't intercept.
if ( ! $_POST || ! strpos( wp_get_referer(), 'options-reading.php' ) )
return $show_on_front_value;
-
+
+ // If 'latest posts' is set, stop here
if ( 'posts' == $show_on_front_value ) {
update_option( 'page_on_front', 0 );
update_option( 'page_for_posts', 0 );
+
return $show_on_front_value;
}
+
+ // They didn't select a page at all. Sad face.
+ if ( ! $_POST['page_on_front_title'] ) {
+ $show_on_front_value = 'posts';
+ update_option( 'page_on_front', 0 );
+ update_option( 'page_for_posts', 0 );
+ add_settings_error( 'page_on_front', 'no_page_selected', __( 'You must select a page to set a static front page.' ) );
+ return $show_on_front_value;
+ }
+
+ // PAGE_ON_FRONT
+ $existing_page_on_front = get_page_by_title( stripslashes( $_POST['page_on_front_title'] ) );
- // If a new front page was meant to be created, go forth and create it.
- if ( 'new' == $_POST['page_on_front'] ) {
-
+ if ( $existing_page_on_front && $existing_page_on_front->ID && 'publish' == $existing_page_on_front->post_status && 'page' == $existing_page_on_front->post_type ) {
+
+ // If a page exists with this same title, use it
+ update_option( 'page_on_front', (int) $existing_page_on_front->ID );
+ } else {
+
// If the user can't create pages, revert.
if ( ! current_user_can( 'create_posts', 'page' ) ) {
- // If an existing page is set, keep things as is, rather than reverting to showing posts.
- if ( get_option( 'page_on_front' ) ) {
- $show_on_front_value = 'page';
- } else {
- $show_on_front_value = 'posts';
- update_option( 'page_on_front', 0 );
- update_option( 'page_for_posts', 0 );
- }
- add_settings_error( 'page_on_front', 'create_pages', __( 'You are not allowed to create pages on this site.' ) );
- return $show_on_front_value;
+ return _show_on_front_cant_create_pages();
}
-
- $existing_page = get_page_by_title( stripslashes( $_POST['page_on_front_title'] ) );
-
- // If page already exists and it's public, there's no need to create a new page.
- if ( $existing_page && 'publish' == $existing_page->post_status ) {
- $page_id = $existing_page->ID;
- } else {
- $page_id = wp_insert_post( array(
- 'post_title' => $_POST['page_on_front_title'],
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'comment_status' => 'closed',
- 'ping_status' => 'closed',
- // @todo Create some sort of a 'context' in postmeta so we know we created a page through these means.
- // Consider then showing that context in the list table as a good-first-step.
- ) );
- }
-
+
+ // Create new page
+ $page_id = wp_insert_post( array(
+ 'post_title' => wp_strip_all_tags( $_POST['page_on_front_title'] ),
+ 'post_type' => 'page',
+ 'post_status' => 'publish',
+ 'comment_status' => 'closed',
+ 'ping_status' => 'closed'
+ // @todo Create some sort of a 'context' in postmeta so we know we created a page through these means.
+ // Consider then showing that context in the list table as a good-first-step.
+ ) );
+
if ( $page_id ) {
update_option( 'page_on_front', $page_id );
- // If we can't save it, revert.
- } elseif ( get_option( 'page_on_front' ) ) {
- // If an existing page is set, keep things as is, rather than reverting to showing posts.
- $show_on_front_value = 'page';
} else {
- $show_on_front_value = 'posts';
- update_option( 'page_on_front', 0 );
- update_option( 'page_for_posts', 0 );
- return $show_on_front_value;
+
+ // If we can't save it, revert.
+ return _show_on_front_cant_create_pages();
}
- } elseif ( $_POST['page_on_front'] ) {
- update_option( 'page_on_front', $_POST['page_on_front'] );
- } else {
- // They didn't select a page at all. Sad face.
- $show_on_front_value = 'posts';
- update_option( 'page_on_front', 0 );
- update_option( 'page_for_posts', 0 );
- add_settings_error( 'page_on_front', 'no_page_selected', __( 'You must select a page to set a static front page.' ) );
- return $show_on_front_value;
}
-
- // If a page for posts was meant to be specified, update/create it.
- if ( ! isset( $_POST['page_for_posts'] ) ) {
- update_option( 'page_for_posts', 0 );
+
+ // PAGE_FOR_POSTS
+ if ( ! isset( $_POST['page_for_posts_name'] ) ) {
return $show_on_front_value;
}
-
- $page_for_posts = (int) $_POST['page_for_posts'];
-
- if ( ! $page_for_posts || ! $page = get_post( $page_for_posts, ARRAY_A ) ) {
- update_option( 'page_for_posts', 0 );
- return $show_on_front_value;
+
+ $existing_page_for_posts = get_page_by_path( stripslashes( $_POST['page_for_posts_name'] ) );
+
+ if ( $existing_page_for_posts && $existing_page_for_posts->ID && 'publish' == $existing_page_for_posts->post_status && 'page' == $existing_page_for_posts->post_type ) {
+
+ // If a page exists with this same name, use it
+ update_option( 'page_for_posts', (int) $existing_page_for_posts->ID );
+ } else {
+
+ // If the user can't create pages, revert.
+ if ( ! current_user_can( 'create_posts', 'page' ) ) {
+ return _show_on_front_cant_create_pages();
+ }
+
+ // Create new page
+ $page_id = wp_insert_post( array(
+ 'post_title' => 'Latest posts',
+ 'post_name' => wp_strip_all_tags( $_POST['page_for_posts_name'] ),
+ 'post_type' => 'page',
+ 'post_status' => 'publish',
+ 'comment_status' => 'closed',
+ 'ping_status' => 'closed'
+ ) );
+
+ if ( $page_id ) {
+ update_option( 'page_for_posts', $page_id );
+ } else {
+
+ // If we can't save it, revert.
+ return _show_on_front_cant_create_pages();
+ }
}
- if ( 'page' != $page['post_type'] || ! current_user_can( 'edit_post', $page_for_posts ) ) {
- update_option( 'page_for_posts', 0 );
- return $show_on_front_value;
- }
-
- if ( 'publish' != $page['post_status'] && ! current_user_can( 'publish_post', $page_for_posts ) ) {
- update_option( 'page_for_posts', 0 );
- return $show_on_front_value;
- }
-
- $args = add_magic_quotes( $page );
- $args['post_title'] = $_POST['page_for_posts_title'];
- $args['post_name'] = $_POST['post_name'];
- $args['post_status'] = 'publish';
- if ( 'auto-draft' == $page['post_status'] ) {
- $args['comment_status'] = 'closed';
- $args['ping_status'] = 'closed';
- }
-
- $page_id = wp_insert_post( $args );
- update_option( 'page_for_posts', $page_id );
-
return $show_on_front_value;
}
-add_filter( 'sanitize_option_show_on_front', '_show_on_front_reading_settings' );
+add_filter( 'sanitize_option_show_on_front', '_show_on_front_reading_settings' );
\ No newline at end of file
Index: wp-admin/edit-form-advanced.php
===================================================================
--- wp-admin/edit-form-advanced.php (revision 22362)
+++ wp-admin/edit-form-advanced.php (working copy)
@@ -306,8 +306,20 @@
wp_nonce_field( 'autosave', 'autosavenonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
+
+$latest_posts_page = '';
+
+if ( $post->ID == get_option( 'page_for_posts' ) ) {
+
+$latest_posts_page = ' style="display: none;"';
?>
+
+
latest posts. As a result, you can't edit the body of this page. Visit reading settings to change your 'front page displays' option."), 'options-reading.php', 'options-reading.php'); ?>
+
+
+
+
@@ -347,7 +359,7 @@
if ( post_type_supports($post_type, 'editor') ) {
?>
-
+
>
post_content, 'content', array('dfw' => true, 'tabfocus_elements' => 'sample-permalink,post-preview', 'editor_height' => 360) ); ?>
Index: wp-admin/css/ie.css
===================================================================
--- wp-admin/css/ie.css (revision 22362)
+++ wp-admin/css/ie.css (working copy)
@@ -601,4 +601,4 @@
* html #adminmenu div.wp-menu-image {
height: 29px;
-}
+}
\ No newline at end of file
Index: wp-admin/css/wp-admin.css
===================================================================
--- wp-admin/css/wp-admin.css (revision 22362)
+++ wp-admin/css/wp-admin.css (working copy)
@@ -4343,12 +4343,6 @@
margin-top: 12px;
}
-.form-table input.tog {
- margin-top: 2px;
- margin-right: 2px;
- float: left;
-}
-
.form-table td p {
margin-top: 4px;
}
@@ -5040,18 +5034,45 @@
margin: -3px 3px;
}
-.js.options-reading-php .if-page-on-front,
-.js.options-reading-php .if-page-for-posts,
-.options-reading-php .if-new-front-page {
+#front-static-pages .pfp-wrapper {
+ display: inline-block;
+ position: relative;
+}
+
+#front-static-pages .pfp-wrapper .description {
+ white-space: nowrap;
+}
+
+#front-static-pages .pfp-slash {
+ left: 6px;
+ position: absolute;
+ top: 1px;
+}
+
+#page_for_posts_name {
+ margin: 0;
+ padding-left: 8px;
+ width: 170px;
+}
+
+#page_on_front_title {
+ margin: 0;
+ width: 170px;
+}
+
+#front-static-pages .page-options {
display: none;
+ margin-top: 8px;
}
-.options-reading-php .page-on-front .if-page-on-front,
-.options-reading-php .page-for-posts .if-page-for-posts {
+
+.page-options .sample-url {
+ color: #888;
+ font-size: 11px;
+}
+
+.static-front-page #front-static-pages .page-options {
display: block;
}
-.options-reading-php .new-front-page .if-new-front-page {
- display: inline;
-}
/*------------------------------------------------------------------------------
21.0 - Admin Footer
Index: wp-admin/options-reading.php
===================================================================
--- wp-admin/options-reading.php (revision 22362)
+++ wp-admin/options-reading.php (working copy)
@@ -16,6 +16,8 @@
$parent_file = 'options-general.php';
wp_enqueue_script( 'sample-permalink' );
+wp_enqueue_script( 'jquery-ui-core' );
+wp_enqueue_script( 'jquery-ui-autocomplete' );
/**
* Display JavaScript on the page.
@@ -23,25 +25,107 @@
* @since 3.5.0
*/
function options_reading_add_js() {
+
+$all_pages = get_pages();
+
+// Populate autocomplete options
+$page_titles_json = $page_names_json = array();
+
+foreach ( $all_pages as $page ) {
+ array_push( $page_titles_json, array(
+ 'id' => $page->ID,
+ 'label' => $page->post_title,
+ 'post_name' => $page->post_name
+ ) );
+
+ array_push( $page_names_json, array(
+ 'id' => $page->ID,
+ 'label' => $page->post_name,
+ 'post_title' => $page->post_title
+ ) );
+}
?>
-