Index: wp-includes/script-loader.php =================================================================== --- wp-includes/script-loader.php (revision 22121) +++ wp-includes/script-loader.php (working copy) @@ -369,7 +369,9 @@ $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 ); - $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), false, 1 ); + $scripts->add( 'sample-permalink', "wp-admin/js/sample-permalink.js", array(), false, 1 ); + + $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox', 'sample-permalink' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array( 'ok' => __('OK'), 'cancel' => __('Cancel'), Index: wp-admin/includes/post.php =================================================================== --- wp-admin/includes/post.php (revision 22121) +++ wp-admin/includes/post.php (working copy) @@ -1059,9 +1059,15 @@ * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor. */ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { - global $wpdb; + global $wpdb, $current_screen; + $post = get_post($id); + if ( isset( $current_screen ) ) + $context = $current_screen->id; + else + $context = isset( $_POST['context'] ) ? $_POST['context'] : ''; + list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); if ( 'publish' == get_post_status( $post ) ) { @@ -1072,11 +1078,12 @@ $title = __('Temporary permalink. Click to edit this part.'); } - if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { - $return = '' . __('Permalink:') . "\n" . '' . $permalink . "\n"; + if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { + $return = ( 'options-reading' == $context ) ? __( 'Located at' ) . "\n" : '' . __( 'Permalink:' ) . "\n"; + $return .= '' . $permalink . "\n"; if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) $return .= '' . __('Change Permalinks') . "\n"; - if ( isset($view_post) ) + if ( isset( $view_post ) && 'options-reading' == $context ) $return .= "$view_post\n"; $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); @@ -1099,14 +1106,14 @@ } $post_name_html = '' . $post_name_abridged . ''; - $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); - $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink); - $return = '' . __('Permalink:') . "\n"; + $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, $permalink ); + $view_link = str_replace( array( '%pagename%', '%postname%' ), $post_name, $permalink ); + $return = ( 'options-reading' == $context ) ? __( 'Located at' ) . "\n" : '' . __( 'Permalink:' ) . "\n"; $return .= '' . $display_link . "\n"; $return .= ''; // Fix bi-directional text display defect in RTL languages. $return .= ' \n"; $return .= '' . $post_name . "\n"; - if ( isset($view_post) ) + if ( isset( $view_post ) && 'options-reading' != $context ) $return .= "$view_post\n"; $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); @@ -1322,3 +1329,50 @@ return $url; } + +/** + * Creates new pages to be set as a front page or a page for posts in Reading Settings. + * + * @since 3.5.0 + * @access private + */ +function _create_pages_for_reading_settings() { + if ( ! isset( $_POST['show_on_front'] ) ) + return; + + $post_type = get_post_type_object( 'page' ); + if ( ! current_user_can( $post_type->cap->edit_posts ) ) + wp_die( __( 'You are not allowed to create pages on this site.' ) ); + + if ( isset( $_POST['page_on_front'] ) && 'new' == $_POST['page_on_front'] ) { + + $title = esc_html( stripslashes( $_POST['page_on_front_title'] ) ); + $existing_page = get_page_by_title( $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' => $title, + 'post_type' => 'page', + 'post_status' => 'publish' + ) ); + } + + if ( $page_id && ! is_wp_error( $page_id ) ) + $_POST['page_on_front'] = $page_id; + } + + if ( isset( $_POST['page_for_posts'] ) ) { + if ( ! $page = get_post( (int) $_POST['page_for_posts'] ) ) + return; + + $page->post_title = esc_html( stripslashes( $_POST['page_for_posts_title'] ) ); + $page->post_name = esc_html( stripslashes( $_POST['post_name'] ) ); + $page->post_status = 'publish'; + + wp_update_post( $page ); + } +} +add_action( 'admin_init', '_create_pages_for_reading_settings' ); Index: wp-admin/js/sample-permalink.js =================================================================== --- wp-admin/js/sample-permalink.js (revision 0) +++ wp-admin/js/sample-permalink.js (revision 0) @@ -0,0 +1,75 @@ +var editPermalink, makeSlugeditClickable; + +(function($){ + if ( ! $('#edit-slug-box').length ) + return; + editPermalink = function(post_id) { + var i, c = 0, + e = $('#editable-post-name'), + revert_e = e.html(), + real_slug = $('#post_name'), + evert_slug = real_slug.val(), + b = $('#edit-slug-buttons'), + revert_b = b.html(), + full = $('#editable-post-name-full').html(); + + $('#view-post-btn').hide(); + b.html(''+postL10n.ok+' '+postL10n.cancel+''); + b.children('.save').click(function() { + var new_slug = e.children('input').val(); + if ( new_slug == $('#editable-post-name-full').text() ) { + return $('.cancel', '#edit-slug-buttons').click(); + } + $.post(ajaxurl, { + action: 'sample-permalink', + post_id: post_id, + new_slug: new_slug, + new_title: $('#title').val(), + context: pagenow, + samplepermalinknonce: $('#samplepermalinknonce').val() + }, function(data) { + $('#edit-slug-box').html(data); + b.html(revert_b); + real_slug.val(new_slug); + makeSlugeditClickable(); + $('#view-post-btn').show(); + }); + return false; + }); + + $('.cancel', '#edit-slug-buttons').click(function() { + $('#view-post-btn').show(); + e.html(revert_e); + b.html(revert_b); + real_slug.val(revert_slug); + return false; + }); + + for ( i = 0; i < full.length; ++i ) { + if ( '%' == full.charAt(i) ) + c++; + } + + slug_value = ( c > full.length / 4 ) ? '' : full; + e.html('').children('input').keypress(function(e){ + var key = e.keyCode || 0; + // on enter, just save the new slug, don't save the post + if ( 13 == key ) { + b.children('.save').click(); + return false; + } + if ( 27 == key ) { + b.children('.cancel').click(); + return false; + } + real_slug.val(this.value); + }).focus(); + } + + makeSlugeditClickable = function() { + $('#editable-post-name').click(function() { + $('#edit-slug-buttons').children('.edit-slug').click(); + }); + } + makeSlugeditClickable(); +})(jQuery); \ No newline at end of file Index: wp-admin/js/post.js =================================================================== --- wp-admin/js/post.js (revision 22121) +++ wp-admin/js/post.js (working copy) @@ -559,71 +559,6 @@ }); } // end submitdiv - // permalink - if ( $('#edit-slug-box').length ) { - editPermalink = function(post_id) { - var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'), revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(), full = $('#editable-post-name-full').html(); - - $('#view-post-btn').hide(); - b.html(''+postL10n.ok+' '+postL10n.cancel+''); - b.children('.save').click(function() { - var new_slug = e.children('input').val(); - if ( new_slug == $('#editable-post-name-full').text() ) { - return $('.cancel', '#edit-slug-buttons').click(); - } - $.post(ajaxurl, { - action: 'sample-permalink', - post_id: post_id, - new_slug: new_slug, - new_title: $('#title').val(), - samplepermalinknonce: $('#samplepermalinknonce').val() - }, function(data) { - $('#edit-slug-box').html(data); - b.html(revert_b); - real_slug.val(new_slug); - makeSlugeditClickable(); - $('#view-post-btn').show(); - }); - return false; - }); - - $('.cancel', '#edit-slug-buttons').click(function() { - $('#view-post-btn').show(); - e.html(revert_e); - b.html(revert_b); - real_slug.val(revert_slug); - return false; - }); - - for ( i = 0; i < full.length; ++i ) { - if ( '%' == full.charAt(i) ) - c++; - } - - slug_value = ( c > full.length / 4 ) ? '' : full; - e.html('').children('input').keypress(function(e){ - var key = e.keyCode || 0; - // on enter, just save the new slug, don't save the post - if ( 13 == key ) { - b.children('.save').click(); - return false; - } - if ( 27 == key ) { - b.children('.cancel').click(); - return false; - } - real_slug.val(this.value); - }).focus(); - } - - makeSlugeditClickable = function() { - $('#editable-post-name').click(function() { - $('#edit-slug-buttons').children('.edit-slug').click(); - }); - } - makeSlugeditClickable(); - } - // word count if ( typeof(wpWordCount) != 'undefined' ) { $(document).triggerHandler('wpcountwords', [ co.val() ]); Index: wp-admin/css/wp-admin-rtl.css =================================================================== --- wp-admin/css/wp-admin-rtl.css (revision 22121) +++ wp-admin/css/wp-admin-rtl.css (working copy) @@ -915,8 +915,7 @@ border-bottom-right-radius: 3px; } -#front-page-warning, -#front-static-pages ul, +#front-static-pages .sub-option, ul.export-filters, .inline-editor ul.cat-checklist ul, .categorydiv ul.categorychecklist ul, Index: wp-admin/css/wp-admin.css =================================================================== --- wp-admin/css/wp-admin.css (revision 22121) +++ wp-admin/css/wp-admin.css (working copy) @@ -2929,6 +2929,10 @@ font-size: 11px; } +#front-static-pages #edit-slug-box { + padding: 0; +} + #editable-post-name-full { display: none; } @@ -3414,8 +3418,7 @@ margin: 0; } -#front-page-warning, -#front-static-pages ul, +#front-static-pages .sub-option, ul.export-filters, .inline-editor ul.cat-checklist ul, .categorydiv ul.categorychecklist ul, @@ -4988,6 +4991,19 @@ 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 { + display: none; +} +.options-reading-php .page-on-front .if-page-on-front, +.options-reading-php .page-for-posts .if-page-for-posts { + 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 22121) +++ wp-admin/options-reading.php (working copy) @@ -15,6 +15,8 @@ $title = __( 'Reading Settings' ); $parent_file = 'options-general.php'; +wp_enqueue_script( 'sample-permalink' ); + /** * Display JavaScript on the page. * @@ -22,23 +24,23 @@ */ function options_reading_add_js() { ?> - +
- | + + |
---|---|