Ticket #17689: 17689.3.diff
File 17689.3.diff, 2.4 KB (added by , 8 years ago) |
---|
-
src/wp-includes/taxonomy.php
2099 2099 $name = wp_unslash($name); 2100 2100 $description = wp_unslash($description); 2101 2101 2102 if ( empty( $slug) )2103 $ slug = sanitize_title($name);2102 if ( empty( $slug ) ) { 2103 $name = trim( $name ); 2104 2104 2105 // check for a term like "$$$" so it isn't repeatedly added 2106 if ( preg_match_all( '#[^a-zA-Z0-9]#', $name, $matches ) && count( $matches[0] ) === strlen( $name ) ) { 2107 $exists = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, slug FROM $wpdb->terms WHERE name = %s", $name ) ); 2108 if ( ! empty( $exists ) ) { 2109 if ( term_exists( $exists->term_id, $taxonomy ) ) 2110 return new WP_Error( 'term_exists', __( 'A term with the name provided already exists.' ) ); 2111 2112 // use the existing slug or the term will never match in term_exists 2113 $slug = $exists->slug; 2114 } 2115 2116 } else { 2117 $slug = sanitize_title( $name ); 2118 } 2119 } 2120 2105 2121 $term_group = 0; 2106 2122 if ( $alias_of ) { 2107 2123 $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) ); -
src/wp-includes/formatting.php
1006 1006 $title = utf8_uri_encode($title, 200); 1007 1007 } 1008 1008 1009 $title = wp_humanize_plus_minus( $title ); 1009 1010 $title = strtolower($title); 1010 1011 $title = preg_replace('/&.+?;/', '', $title); // kill entities 1011 1012 $title = str_replace('.', '-', $title); … … 3426 3427 3427 3428 return false; 3428 3429 } 3430 3431 /** 3432 * Convert +/- to plus/minus 3433 * 3434 * @param string $str Input string. 3435 * @return string Formatted string. 3436 */ 3437 function wp_humanize_plus_minus( $str ) { 3438 $replacements = array( 3439 '--' => '-minus-minus', 3440 '++' => '-plus-plus' 3441 ); 3442 3443 $new_str = str_replace( array_keys( $replacements ), array_values( $replacements ), $str ); 3444 3445 $patterns = array( 3446 '#([^-])-\s#' => '$1-minus ', 3447 '#([^-])-$#' => '$1-minus', 3448 '#([^+]+)\+\s#' => '$1-plus ', 3449 '#([^+]+)\+$#' => '$1-plus', 3450 ); 3451 3452 $new_str = preg_replace( array_keys( $patterns ), array_values( $patterns ), $new_str ); 3453 if ( $new_str !== $str ) 3454 $new_str = wp_humanize_plus_minus( $new_str ); 3455 3456 return $new_str; 3457 } 3458 No newline at end of file