Switch to sanitize_title_for_query() for Query sanitization (allows for pre-3.3 page slugs to be viewable), Don't update page slugs to new slug-types when the slug is not being changed, Don't issue a XHR if the page slug hasn't changed. Group effort props xknown, markjaquith, nacin. See #19292

git-svn-id: http://svn.automattic.com/wordpress/trunk@19444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2011-11-24 00:20:21 +00:00
parent 1611327f11
commit c85525aece
5 changed files with 14 additions and 6 deletions

View File

@ -547,6 +547,9 @@ jQuery(document).ready( function($) {
b.html('<a href="#" class="save button">'+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,

File diff suppressed because one or more lines are too long

View File

@ -2490,7 +2490,12 @@ function wp_insert_post($postarr, $wp_error = false) {
else
$post_name = '';
} else {
$post_name = sanitize_title($post_name);
// On updates, we need to check to see if it's using the old, fixed sanitization context.
$check_name = sanitize_title( $post_name, '', 'old-save' );
if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $ID ) == $check_name )
$post_name = $check_name;
else // new post, or slug has changed.
$post_name = sanitize_title($post_name);
}
// If the post date is empty (due to having been new or a draft) and status is not 'draft' or 'pending', set date to now
@ -3153,7 +3158,7 @@ function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
$page_path = str_replace('%20', ' ', $page_path);
$parts = explode( '/', trim( $page_path, '/' ) );
$parts = array_map( 'esc_sql', $parts );
$parts = array_map( 'sanitize_title', $parts );
$parts = array_map( 'sanitize_title_for_query', $parts );
$in_string = "'". implode( "','", $parts ) . "'";
$post_type_sql = $post_type;

View File

@ -1838,7 +1838,7 @@ class WP_Query {
}
if ( !empty($q['tag_slug__in']) ) {
$q['tag_slug__in'] = array_map('sanitize_title', array_unique( (array) $q['tag_slug__in'] ) );
$q['tag_slug__in'] = array_map('sanitize_title_for_query', array_unique( (array) $q['tag_slug__in'] ) );
$tax_query[] = array(
'taxonomy' => 'post_tag',
'terms' => $q['tag_slug__in'],
@ -1847,7 +1847,7 @@ class WP_Query {
}
if ( !empty($q['tag_slug__and']) ) {
$q['tag_slug__and'] = array_map('sanitize_title', array_unique( (array) $q['tag_slug__and'] ) );
$q['tag_slug__and'] = array_map('sanitize_title_for_query', array_unique( (array) $q['tag_slug__and'] ) );
$tax_query[] = array(
'taxonomy' => 'post_tag',
'terms' => $q['tag_slug__and'],

View File

@ -311,7 +311,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20111009a', 1 );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110524', 1 );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20111124', 1 );
$scripts->localize( 'post', 'postL10n', array(
'ok' => __('OK'),
'cancel' => __('Cancel'),