| 1490 | | if ($post_name_check || in_array($post_name, $wp_rewrite->feeds) ) { |
| 1491 | | $suffix = 2; |
| 1492 | | do { |
| 1493 | | $alt_post_name = substr($post_name, 0, 200-(strlen($suffix)+1)). "-$suffix"; |
| 1494 | | $post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1", $alt_post_name, $post_type, $post_ID, $post_parent)); |
| 1495 | | $suffix++; |
| 1496 | | } while ($post_name_check); |
| 1497 | | $post_name = $alt_post_name; |
| 1498 | | } |
| 1499 | | } |
| 1500 | | |
| 1501 | 1491 | // expected_slashed (everything!) |
| 1502 | 1492 | $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) ); |
| 1503 | 1493 | $data = apply_filters('wp_insert_post_data', $data, $postarr); |
| | 1700 | * Given the desired slug and some post details computes a unique slug for the post. |
| | 1701 | * |
| | 1702 | * @param integer $post_ID |
| | 1703 | * @param string $post_status no uniqueness checks are made if the post is still draft or pending |
| | 1704 | * @param string $post_name the desired slug |
| | 1705 | * @param string $post_type |
| | 1706 | * @param integer $post_parent |
| | 1707 | * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix) |
| | 1708 | */ |
| | 1709 | function wp_unique_slug($post_ID, $post_status, $post_name, $post_type, $post_parent) { |
| | 1710 | global $wpdb, $wp_rewrite; |
| | 1711 | if ( !in_array( $post_status, array( 'draft', 'pending' ) ) ) { |
| | 1712 | $post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1", $post_name, $post_type, $post_ID, $post_parent)); |
| | 1713 | |
| | 1714 | if ($post_name_check || in_array($post_name, $wp_rewrite->feeds) ) { |
| | 1715 | $suffix = 2; |
| | 1716 | do { |
| | 1717 | $alt_post_name = substr($post_name, 0, 200-(strlen($suffix)+1)). "-$suffix"; |
| | 1718 | $post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1", $alt_post_name, $post_type, $post_ID, $post_parent)); |
| | 1719 | $suffix++; |
| | 1720 | } while ($post_name_check); |
| | 1721 | $post_name = $alt_post_name; |
| | 1722 | } |
| | 1723 | } |
| | 1724 | return $post_name; |
| | 1725 | } |
| | 1726 | |
| | 1727 | /** |