Ticket #21013: 21013.9.patch
| File 21013.9.patch, 2.6 KB (added by , 14 years ago) |
|---|
-
wp-includes/post.php
2867 2867 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { 2868 2868 $suffix = 2; 2869 2869 do { 2870 $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";2871 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) );2870 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 2871 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) ); 2872 2872 $suffix++; 2873 2873 } while ( $post_name_check ); 2874 2874 $slug = $alt_post_name; … … 2882 2882 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 ) ) { 2883 2883 $suffix = 2; 2884 2884 do { 2885 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";2885 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 2886 2886 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID, $post_parent ) ); 2887 2887 $suffix++; 2888 2888 } while ( $post_name_check ); … … 2896 2896 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 2897 2897 $suffix = 2; 2898 2898 do { 2899 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";2899 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 2900 2900 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) ); 2901 2901 $suffix++; 2902 2902 } while ( $post_name_check ); … … 2908 2908 } 2909 2909 2910 2910 /** 2911 * Truncate a post slug with UTF-8 characters. 2912 * 2913 * @since 3.5.0 2914 * @access private 2915 * 2916 * @param string $slug The slug to truncate. 2917 * @param int $length Max length of the slug. 2918 * @return string The truncated slug. 2919 */ 2920 function _truncate_post_slug( $slug, $length = 200 ) { 2921 if ( urldecode( $slug ) === $slug ) 2922 return substr( $slug, 0, $length ); 2923 2924 while ( strlen( $slug ) > $length ) { 2925 $slug = mb_substr( urldecode( $slug ), 0, -1 ); 2926 $slug = utf8_uri_encode( rtrim( $slug, '-' ) ); 2927 } 2928 2929 return $slug; 2930 } 2931 2932 /** 2911 2933 * Adds tags to a post. 2912 2934 * 2913 2935 * @uses wp_set_post_tags() Same first two parameters, but the last parameter is always set to true.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)