Changeset 32647 for trunk/src/wp-includes/post.php
- Timestamp:
- 05/29/2015 12:52:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r32621 r32647 3791 3791 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 3792 3792 3793 // Prevent post slugs that could result in URLs that conflict with date archives. 3794 $conflicts_with_date_archive = false; 3795 if ( 'post' === $post_type && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) { 3796 $permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) ); 3797 $postname_index = array_search( '%postname%', $permastructs ); 3798 3799 /* 3800 * Potential date clashes are as follows: 3801 * 3802 * - Any integer in the first permastruct position could be a year. 3803 * - An integer between 1 and 12 that follows 'year' conflicts with 'monthnum'. 3804 * - An integer between 1 and 31 that follows 'monthnum' conflicts with 'day'. 3805 */ 3806 if ( 0 === $postname_index || 3807 ( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) || 3808 ( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num ) 3809 ) { 3810 $conflicts_with_date_archive = true; 3811 } 3812 } 3813 3793 3814 /** 3794 3815 * Filter whether the post slug would be bad as a flat slug. … … 3800 3821 * @param string $post_type Post type. 3801 3822 */ 3802 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {3823 if ( $post_name_check || in_array( $slug, $feeds ) || $conflicts_with_date_archive || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 3803 3824 $suffix = 2; 3804 3825 do {
Note: See TracChangeset
for help on using the changeset viewer.