Make WordPress Core

Ticket #16843: 16843.4.diff

File 16843.4.diff, 3.2 KB (added by wonderboymusic, 11 years ago)
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index 1854459..d115385 100644
    function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p 
    30333033        if ( 'attachment' == $post_type ) {
    30343034                // Attachment slugs must be unique across all types.
    30353035                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
    3036                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
     3036                $post_name_check = in_array( $slug, $feeds )
     3037                        || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug )
     3038                        || $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
    30373039
    3038                 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
     3040                if ( $post_name_check ) {
    30393041                        $suffix = 2;
    30403042                        do {
    30413043                                $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p 
    30503052                // Page slugs must be unique within their own trees. Pages are in a separate
    30513053                // namespace than posts so page slugs are allowed to overlap post slugs.
    30523054                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
    3053                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
     3055                $post_name_check = in_array( $slug, $feeds )
     3056                        || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug )
     3057                        || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent )
     3058                        || $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
    30543059
    3055                 if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug )  || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) {
     3060                if ( $post_name_check ) {
    30563061                        $suffix = 2;
    30573062                        do {
    30583063                                $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
    function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p 
    30643069        } else {
    30653070                // Post slugs must be unique across all posts.
    30663071                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
    3067                 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
     3072                $post_type_obj = get_post_type_object( $post_type );
    30683073
    3069                 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
     3074                $post_name_check = in_array( $slug, $feeds )
     3075                        || ( $post_type_obj->has_archive && $wp_rewrite->pagination_base == $slug )
     3076                        || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type )
     3077                        || $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
     3078
     3079                if ( $post_name_check ) {
    30703080                        $suffix = 2;
    30713081                        do {
    30723082                                $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";