Revert page on front changes. Reverts [22127] [22129] [22135] [22136]. see #16379.
git-svn-id: http://core.svn.wordpress.org/trunk@22653 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e3d01cddd0
commit
97032e08aa
|
@ -971,7 +971,8 @@ table.diff td, table.diff th {
|
|||
border-bottom-right-radius: 3px;
|
||||
}
|
||||
|
||||
#front-static-pages .sub-option,
|
||||
#front-page-warning,
|
||||
#front-static-pages ul,
|
||||
ul.export-filters,
|
||||
.inline-editor ul.cat-checklist ul,
|
||||
.categorydiv ul.categorychecklist ul,
|
||||
|
|
|
@ -716,6 +716,10 @@ select {
|
|||
color: #000;
|
||||
}
|
||||
|
||||
select[disabled] {
|
||||
color: #7f7f7f;
|
||||
}
|
||||
|
||||
select:focus {
|
||||
border-color: #aaa;
|
||||
}
|
||||
|
@ -3020,10 +3024,6 @@ input#link_url {
|
|||
font-size: 11px;
|
||||
}
|
||||
|
||||
#front-static-pages #edit-slug-box {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#editable-post-name-full {
|
||||
display: none;
|
||||
}
|
||||
|
@ -3510,7 +3510,8 @@ div.tabs-panel-inactive {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
#front-static-pages .sub-option,
|
||||
#front-page-warning,
|
||||
#front-static-pages ul,
|
||||
ul.export-filters,
|
||||
.inline-editor ul.cat-checklist ul,
|
||||
.categorydiv ul.categorychecklist ul,
|
||||
|
@ -5066,19 +5067,6 @@ h2 .nav-tab {
|
|||
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
|
||||
------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -1298,8 +1298,7 @@ function wp_ajax_sample_permalink() {
|
|||
$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
|
||||
$title = isset($_POST['new_title'])? $_POST['new_title'] : '';
|
||||
$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
|
||||
$screen = isset( $_POST['screen'] ) ? $_POST['screen'] : 'post';
|
||||
wp_die( get_sample_permalink_html( $post_id, $title, $slug, $screen ) );
|
||||
wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
|
||||
}
|
||||
|
||||
function wp_ajax_inline_save() {
|
||||
|
|
|
@ -1055,20 +1055,14 @@ function get_sample_permalink($id, $title = null, $name = null) {
|
|||
* @param int|object $id Post ID or post object.
|
||||
* @param string $new_title Optional. New title.
|
||||
* @param string $new_slug Optional. New slug.
|
||||
* @param string|WP_Screen $screen Optional. Screen where the editor is being shown.
|
||||
* @return string The HTML of the sample permalink slug editor.
|
||||
*/
|
||||
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null, $screen = null ) {
|
||||
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||
global $wpdb;
|
||||
$post = get_post($id);
|
||||
|
||||
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
|
||||
|
||||
if ( isset( $screen ) )
|
||||
$screen = convert_to_screen( $screen );
|
||||
else
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( 'publish' == get_post_status( $post ) ) {
|
||||
$ptype = get_post_type_object($post->post_type);
|
||||
$view_post = $ptype->labels->view_item;
|
||||
|
@ -1078,12 +1072,10 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null, $s
|
|||
}
|
||||
|
||||
if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
|
||||
if ( 'options-reading' == $screen->id )
|
||||
return '';
|
||||
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
|
||||
if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) )
|
||||
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
|
||||
if ( isset($view_post) )
|
||||
if ( isset( $view_post ) )
|
||||
$return .= "<span id='view-post-btn'><a href='$permalink' class='button button-small'>$view_post</a></span>\n";
|
||||
|
||||
$return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
|
||||
|
@ -1108,12 +1100,12 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null, $s
|
|||
$post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
|
||||
$display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
|
||||
$view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
|
||||
$return = ( 'options-reading' == $screen->id ) ? __( 'Located at' ) . "\n" : '<strong>' . __( 'Permalink:' ) . "</strong>\n";
|
||||
$return = '<strong>' . __('Permalink:') . "</strong>\n";
|
||||
$return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
|
||||
$return .= '‎'; // Fix bi-directional text display defect in RTL languages.
|
||||
$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
|
||||
$return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
|
||||
if ( isset( $view_post ) && 'options-reading' != $screen->id )
|
||||
if ( isset($view_post) )
|
||||
$return .= "<span id='view-post-btn'><a href='$view_link' class='button button-small'>$view_post</a></span>\n";
|
||||
|
||||
$return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
|
||||
|
@ -1329,118 +1321,3 @@ function post_preview() {
|
|||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @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 ( 'posts' == $show_on_front_value ) {
|
||||
update_option( 'page_on_front', 0 );
|
||||
update_option( 'page_for_posts', 0 );
|
||||
return $show_on_front_value;
|
||||
}
|
||||
|
||||
// If a new front page was meant to be created, go forth and create it.
|
||||
if ( 'new' == $_POST['page_on_front'] ) {
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
$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.
|
||||
) );
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
} 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 );
|
||||
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;
|
||||
}
|
||||
|
||||
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' );
|
||||
|
|
|
@ -572,6 +572,71 @@ jQuery(document).ready( function($) {
|
|||
});
|
||||
} // 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('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
|
||||
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('<input type="text" id="new-post-slug" value="'+slug_value+'" />').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() ]);
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
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'),
|
||||
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('<a href="#" class="save button button-small">'+samplePermalinkL10n.ok+'</a> <a class="cancel" href="#">'+samplePermalinkL10n.cancel+'</a>');
|
||||
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(),
|
||||
screen: 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('<input type="text" id="new-post-slug" value="'+slug_value+'" />').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);
|
|
@ -1 +0,0 @@
|
|||
var editPermalink,makeSlugeditClickable;(function(a){if(!a("#edit-slug-box").length){return}editPermalink=function(d){var f,j=0,h=a("#editable-post-name"),k=h.html(),n=a("#post_name"),o=n.val(),l=a("#edit-slug-buttons"),m=l.html(),g=a("#editable-post-name-full").html();a("#view-post-btn").hide();l.html('<a href="#" class="save button button-small">'+samplePermalinkL10n.ok+'</a> <a class="cancel" href="#">'+samplePermalinkL10n.cancel+"</a>");l.children(".save").click(function(){var b=h.children("input").val();if(b==a("#editable-post-name-full").text()){return a(".cancel","#edit-slug-buttons").click()}a.post(ajaxurl,{action:"sample-permalink",post_id:d,new_slug:b,new_title:a("#title").val(),screen:pagenow,samplepermalinknonce:a("#samplepermalinknonce").val()},function(c){a("#edit-slug-box").html(c);l.html(m);n.val(b);makeSlugeditClickable();a("#view-post-btn").show()});return false});a(".cancel","#edit-slug-buttons").click(function(){a("#view-post-btn").show();h.html(k);l.html(m);n.val(o);return false});for(f=0;f<g.length;++f){if("%"==g.charAt(f)){j++}}slug_value=(j>g.length/4)?"":g;h.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(c){var b=c.keyCode||0;if(13==b){l.children(".save").click();return false}if(27==b){l.children(".cancel").click();return false}n.val(this.value)}).focus()};makeSlugeditClickable=function(){a("#editable-post-name").click(function(){a("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()})(jQuery);
|
|
@ -15,8 +15,6 @@ if ( ! current_user_can( 'manage_options' ) )
|
|||
$title = __( 'Reading Settings' );
|
||||
$parent_file = 'options-general.php';
|
||||
|
||||
wp_enqueue_script( 'sample-permalink' );
|
||||
|
||||
/**
|
||||
* Display JavaScript on the page.
|
||||
*
|
||||
|
@ -24,28 +22,23 @@ wp_enqueue_script( 'sample-permalink' );
|
|||
*/
|
||||
function options_reading_add_js() {
|
||||
?>
|
||||
<script>
|
||||
jQuery(document).ready( function($) {
|
||||
var section = $('#front-static-pages');
|
||||
$('#show_on_front').change( function() {
|
||||
var checked = $(this).prop('checked');
|
||||
section.toggleClass('page-on-front', checked);
|
||||
if ( checked )
|
||||
$('#page_for_posts').prop('checked', true).change();
|
||||
else
|
||||
section.removeClass('page-for-posts');
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(document).ready(function($){
|
||||
var section = $('#front-static-pages'),
|
||||
staticPage = section.find('input:radio[value="page"]'),
|
||||
selects = section.find('select'),
|
||||
check_disabled = function(){
|
||||
selects.prop( 'disabled', ! staticPage.prop('checked') );
|
||||
};
|
||||
check_disabled();
|
||||
section.find('input:radio').change(check_disabled);
|
||||
});
|
||||
$('#page_for_posts').change( function() {
|
||||
section.toggleClass('page-for-posts', $(this).prop('checked'));
|
||||
});
|
||||
$('#page_on_front').change( function() {
|
||||
section.toggleClass('new-front-page', 'new' === $(this).val());
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'admin_head', 'options_reading_add_js' );
|
||||
add_action('admin_head', 'options_reading_add_js');
|
||||
|
||||
/**
|
||||
* Render the blog charset setting.
|
||||
|
@ -89,101 +82,47 @@ include( './admin-header.php' );
|
|||
<form method="post" action="options.php">
|
||||
<?php
|
||||
settings_fields( 'reading' );
|
||||
wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
|
||||
?>
|
||||
<table class="form-table">
|
||||
<?php
|
||||
|
||||
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) )
|
||||
add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
|
||||
?>
|
||||
|
||||
$classes = '';
|
||||
if ( 'page' == get_option( 'show_on_front' ) ) {
|
||||
if ( ! get_pages() || ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {
|
||||
<?php if ( ! get_pages() ) : ?>
|
||||
<input name="show_on_front" type="hidden" value="posts" />
|
||||
<table class="form-table">
|
||||
<?php
|
||||
if ( 'posts' != get_option( 'show_on_front' ) ) :
|
||||
update_option( 'show_on_front', 'posts' );
|
||||
} else {
|
||||
$classes = 'page-on-front';
|
||||
if ( get_option( 'page_for_posts' ) )
|
||||
$classes .= ' page-for-posts';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
$all_pages = get_pages();
|
||||
$new_front_page_only = ! get_option( 'page_on_front' ) && ( ! $all_pages || ( 1 == count( $all_pages ) && __( 'sample-page' ) == $all_pages[0]->post_name ) );
|
||||
|
||||
if ( current_user_can( 'create_posts', 'page' ) && ! ( get_option( 'page_for_posts' ) && $page_for_posts = get_post( get_option( 'page_for_posts' ) ) ) ) {
|
||||
$title = _x( 'Blog', 'default page for posts title' );
|
||||
// @todo What if the found page is post_type = attachment or post_status != publish?
|
||||
// We could go ahead and create a new one, but we would not be able to take over
|
||||
// the slug from another page. (We could for an attachment.)
|
||||
// We must also check that the user can edit this page and publish a page.
|
||||
// Otherwise, we must assume they cannot create pages (throughout), and thus
|
||||
// should fall back to the dropdown.
|
||||
$page_for_posts = get_page_by_path( sanitize_title( $title ) );
|
||||
if ( ! $page_for_posts || $page_for_posts->ID == get_option( 'page_on_front' ) ) {
|
||||
$page_for_posts = get_default_post_to_edit( 'page', true );
|
||||
$page_for_posts->post_title = $title;
|
||||
$page_for_posts->post_name = sanitize_title( $title );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $new_front_page_only || current_user_can( 'create_posts', 'page' ) ) : ?>
|
||||
else :
|
||||
if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) )
|
||||
update_option( 'show_on_front', 'posts' );
|
||||
?>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e( 'Enable a static front page' ); ?></th>
|
||||
<td id="front-static-pages" class="<?php echo $classes; ?>">
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e( 'Enable a static front page' ); ?></span></legend>
|
||||
<p><label for="show_on_front">
|
||||
<input id="show_on_front" name="show_on_front" type="checkbox" value="page" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
|
||||
<?php printf( __( 'Show a <a href="%s">page</a> instead of your latest posts' ), 'edit.php?post_type=page' ); ?>
|
||||
</label></p>
|
||||
<p class="if-page-on-front sub-option">
|
||||
<?php if ( $new_front_page_only ) : // If no pages, or only sample page, only allow a new page to be added ?>
|
||||
<label for="page_on_front_title"><?php _e( 'Add new page titled:' ); ?>
|
||||
<?php else : ?>
|
||||
<label for="page_on_front">
|
||||
<select name="page_on_front" id="page_on_front">
|
||||
<option value="0"><?php _e( '— Select —' ); ?></option>
|
||||
<?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
|
||||
<option value="new" id="new-page"><?php _e( '— Add new page —' ); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php echo walk_page_dropdown_tree( $all_pages, 0, array( 'selected' => get_option( 'page_on_front' ) ) ); ?>
|
||||
</select>
|
||||
</label>
|
||||
<?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
|
||||
<label for="page_on_front_title" class="if-new-front-page"><?php _e( 'titled:' ); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
|
||||
<input name="page_on_front_title" type="text" id="page_on_front_title" value="<?php echo esc_attr_x( 'Home', 'default page on front title' ); ?>" />
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<th scope="row"><?php _e( 'Front page displays' ); ?></th>
|
||||
<td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Front page displays' ); ?></span></legend>
|
||||
<p><label>
|
||||
<input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
|
||||
<?php _e( 'Your latest posts' ); ?>
|
||||
</label>
|
||||
</p>
|
||||
<p class="if-page-on-front"><label for="page_for_posts">
|
||||
<input id="page_for_posts" name="page_for_posts" type="checkbox" value="<?php echo $page_for_posts->ID; ?>" <?php checked( (bool) get_option( 'page_for_posts' ) ); ?> />
|
||||
<?php _e( 'Show latest posts on a separate page' ); ?>
|
||||
</label></p>
|
||||
<?php if ( current_user_can( 'create_posts', 'page' ) ) : ?>
|
||||
<p class="if-page-for-posts sub-option"><label for="page_for_posts_title"><?php _e( 'Page title:' ); ?>
|
||||
<input name="page_for_posts_title" type="text" id="page_for_posts_title" value="<?php echo esc_attr( htmlspecialchars( $page_for_posts->post_title ) ); ?>" />
|
||||
</label></p>
|
||||
<p class="if-page-for-posts sub-option" id="edit-slug-box">
|
||||
<?php echo get_sample_permalink_html( $page_for_posts->ID, $page_for_posts->post_title, $page_for_posts->post_name ); ?>
|
||||
<p><label>
|
||||
<input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
|
||||
<?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?>
|
||||
</label>
|
||||
</p>
|
||||
<input name="post_name" type="hidden" id="post_name" value="<?php echo esc_attr( apply_filters( 'editable_slug', $page_for_posts->post_name ) ); ?>" />
|
||||
<?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
|
||||
<div class="error inline"><p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'These pages should not be the same!' ); ?></p></div>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
<?php else : // cannot create pages, so fall back to a selector of existing pages ?>
|
||||
<p class="if-page-for-posts sub-option"><label for="page_for_posts">
|
||||
<?php wp_dropdown_pages( array(
|
||||
'name' => 'page_for_posts', 'show_option_none' => __( '— Select —' ),
|
||||
'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' )
|
||||
) ); ?>
|
||||
<?php endif; // create pages ?>
|
||||
</td>
|
||||
<ul>
|
||||
<li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li>
|
||||
<li><label for="page_for_posts"><?php printf( __( 'Posts page: %s' ), wp_dropdown_pages( array( 'name' => 'page_for_posts', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) ) ) ); ?></label></li>
|
||||
</ul>
|
||||
<?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
|
||||
<div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
|
||||
<?php endif; ?>
|
||||
</fieldset></td>
|
||||
</tr>
|
||||
<?php endif; // if no pages to choose from and can't create pages ?>
|
||||
|
||||
<?php endif; ?>
|
||||
<tr valign="top">
|
||||
<th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
|
||||
<td>
|
||||
|
|
|
@ -62,7 +62,7 @@ $whitelist_options = array(
|
|||
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
|
||||
'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
|
||||
'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
|
||||
'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'blog_public' ),
|
||||
'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
|
||||
'writing' => array( 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' )
|
||||
);
|
||||
$whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array();
|
||||
|
|
|
@ -2786,11 +2786,6 @@ function sanitize_option($option, $value) {
|
|||
$value = absint( $value );
|
||||
break;
|
||||
|
||||
case 'show_on_front' :
|
||||
if ( ! $value )
|
||||
$value = 'posts';
|
||||
break;
|
||||
|
||||
case 'posts_per_page':
|
||||
case 'posts_per_rss':
|
||||
$value = (int) $value;
|
||||
|
|
|
@ -357,14 +357,10 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
|
||||
|
||||
$scripts->add( 'sample-permalink', "/wp-admin/js/sample-permalink$suffix.js", array(), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize( 'sample-permalink', 'samplePermalinkL10n', array(
|
||||
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array(
|
||||
'ok' => __('OK'),
|
||||
'cancel' => __('Cancel'),
|
||||
) );
|
||||
|
||||
$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(
|
||||
'publishOn' => __('Publish on:'),
|
||||
'publishOnFuture' => __('Schedule for:'),
|
||||
'publishOnPast' => __('Published on:'),
|
||||
|
|
Loading…
Reference in New Issue