Make WordPress Core

Changeset 11202


Ignore:
Timestamp:
05/05/2009 04:39:36 PM (15 years ago)
Author:
ryan
Message:

Use wp_unique_slug() in wp_insert_attachment(). Props Denis-de-Bernardy. fixes #9726

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r11197 r11202  
    17181718            $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID, $post_parent));
    17191719        }
    1720 
     1720       
    17211721        if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) {
    17221722            $suffix = 2;
     
    24162416        $post_name = sanitize_title($post_name);
    24172417
    2418     // expected_slashed ($post_name)
    2419     $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_name, $post_ID));
    2420 
    2421     if ($post_name_check) {
    2422         $suffix = 2;
    2423         while ($post_name_check) {
    2424             $alt_post_name = $post_name . "-$suffix";
    2425             // expected_slashed ($alt_post_name, $post_name)
    2426             $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_status = 'inherit' AND ID != %d LIMIT 1", $alt_post_name, $post_ID, $post_parent));
    2427             $suffix++;
    2428         }
    2429         $post_name = $alt_post_name;
    2430     }
     2418    $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
    24312419
    24322420    if ( empty($post_date) )
Note: See TracChangeset for help on using the changeset viewer.