Changeset 23420 for trunk/wp-includes/post.php
- Timestamp:
- 02/15/2013 02:35:41 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r23416 r23420 3151 3151 $suffix = 2; 3152 3152 do { 3153 $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";3154 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) );3153 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 3154 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) ); 3155 3155 $suffix++; 3156 3156 } while ( $post_name_check ); … … 3168 3168 $suffix = 2; 3169 3169 do { 3170 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";3170 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 3171 3171 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID, $post_parent ) ); 3172 3172 $suffix++; … … 3182 3182 $suffix = 2; 3183 3183 do { 3184 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";3184 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 3185 3185 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) ); 3186 3186 $suffix++; … … 3191 3191 3192 3192 return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ); 3193 } 3194 3195 /** 3196 * Truncates a post slug. 3197 * 3198 * @since 3.6.0 3199 * @access private 3200 * @uses utf8_uri_encode() Makes sure UTF-8 characters are properly cut and encoded. 3201 * 3202 * @param string $slug The slug to truncate. 3203 * @param int $length Max length of the slug. 3204 * @return string The truncated slug. 3205 */ 3206 function _truncate_post_slug( $slug, $length = 200 ) { 3207 if ( strlen( $slug ) > $length ) { 3208 $decoded_slug = urldecode( $slug ); 3209 if ( $decoded_slug === $slug ) 3210 $slug = substr( $slug, 0, $length ); 3211 else 3212 $slug = utf8_uri_encode( $decoded_slug, $length ); 3213 } 3214 3215 return rtrim( $slug, '-' ); 3193 3216 } 3194 3217
Note: See TracChangeset
for help on using the changeset viewer.