WordPress.org

Make WordPress Core

Ticket #19292: 19292.diff

File 19292.diff, 1.7 KB (added by nacin, 7 years ago)
  • wp-includes/post.php

     
    24852485        // Create a valid post name.  Drafts and pending posts are allowed to have an empty
    24862486        // post name.
    24872487        if ( empty($post_name) ) {
     2488                $sanitize_context = $update && is_post_type_hierarchical( $post_type ) ? '' : 'save';
    24882489                if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
    2489                         $post_name = sanitize_title($post_title);
     2490                        $post_name = sanitize_title($post_title, '', $sanitize_context );
    24902491                else
    24912492                        $post_name = '';
    24922493        } else {
    2493                 $post_name = sanitize_title($post_name);
     2494                $post_name = sanitize_title( $post_name, '', $sanitize_context );
    24942495        }
    24952496
    24962497        // 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
     
    25942595        }
    25952596
    25962597        if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
    2597                 $data['post_name'] = sanitize_title($data['post_title'], $post_ID);
     2598                $data['post_name'] = sanitize_title($data['post_title'], $post_ID, $update && is_post_type_hierarchical( get_post_type( $post_ID ) ) ? '' : 'save' );
    25982599                $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
    25992600        }
    26002601
     
    31533154        $page_path = str_replace('%20', ' ', $page_path);
    31543155        $parts = explode( '/', trim( $page_path, '/' ) );
    31553156        $parts = array_map( 'esc_sql', $parts );
    3156         $parts = array_map( 'sanitize_title', $parts );
     3157        $parts = array_map( 'sanitize_title_for_query', $parts );
    31573158
    31583159        $in_string = "'". implode( "','", $parts ) . "'";
    31593160        $post_type_sql = $post_type;