Add emoji URL support, and Twemoji fallback for displaying slugs in wp-admin, when the browser doesn't natively support emoji.
Props pento, SergeyBiryukov and boonebgorges. Fixes #31328 Built from https://develop.svn.wordpress.org/trunk@31734 git-svn-id: http://core.svn.wordpress.org/trunk@31715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -785,21 +785,27 @@ function utf8_uri_encode( $utf8_string, $length = 0 ) {
|
||||
$unicode .= chr($value);
|
||||
$unicode_length++;
|
||||
} else {
|
||||
if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
|
||||
if ( count( $values ) == 0 ) {
|
||||
if ( $value < 224 ) {
|
||||
$num_octets = 2;
|
||||
} elseif ( $value < 240 ) {
|
||||
$num_octets = 3;
|
||||
} else {
|
||||
$num_octets = 4;
|
||||
}
|
||||
}
|
||||
|
||||
$values[] = $value;
|
||||
|
||||
if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )
|
||||
break;
|
||||
if ( count( $values ) == $num_octets ) {
|
||||
if ($num_octets == 3) {
|
||||
$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
|
||||
$unicode_length += 9;
|
||||
} else {
|
||||
$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
|
||||
$unicode_length += 6;
|
||||
for ( $j = 0; $j < $num_octets; $j++ ) {
|
||||
$unicode .= '%' . dechex( $values[ $j ] );
|
||||
}
|
||||
|
||||
$unicode_length += $num_octets * 3;
|
||||
|
||||
$values = array();
|
||||
$num_octets = 1;
|
||||
}
|
||||
|
||||
@@ -2879,13 +2879,7 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
||||
|
||||
$slug_provided = ! empty( $args['slug'] );
|
||||
if ( ! $slug_provided ) {
|
||||
$_name = trim( $name );
|
||||
$existing_term = get_term_by( 'name', $_name, $taxonomy );
|
||||
if ( $existing_term ) {
|
||||
$slug = $existing_term->slug;
|
||||
} else {
|
||||
$slug = sanitize_title( $name );
|
||||
}
|
||||
$slug = sanitize_title( $name );
|
||||
} else {
|
||||
$slug = $args['slug'];
|
||||
}
|
||||
@@ -2910,20 +2904,14 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
||||
}
|
||||
|
||||
// Terms with duplicate names are not allowed at the same level of a taxonomy hierarchy.
|
||||
if ( $exists = term_exists( $slug, $taxonomy ) ) {
|
||||
$existing_term = get_term( $exists['term_id'], $taxonomy );
|
||||
|
||||
if ( $name === $existing_term->name ) {
|
||||
|
||||
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
|
||||
$siblings = get_terms( $taxonomy, array( 'fields' => 'names', 'get' => 'all', 'parent' => $parent ) );
|
||||
if ( in_array( $name, $siblings ) ) {
|
||||
return new WP_Error( 'term_exists', __( 'A term with the name and slug already exists with this parent.' ), $exists['term_id'] );
|
||||
}
|
||||
|
||||
} else {
|
||||
return new WP_Error( 'term_exists', __( 'A term with the name and slug already exists in this taxonomy.' ), $exists['term_id'] );
|
||||
if ( $existing_term = get_term_by( 'name', $name, $taxonomy ) ) {
|
||||
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
|
||||
$siblings = get_terms( $taxonomy, array( 'fields' => 'names', 'get' => 'all', 'parent' => $parent ) );
|
||||
if ( in_array( $name, $siblings ) ) {
|
||||
return new WP_Error( 'term_exists', __( 'A term with the name already exists with this parent.' ), $existing_term->term_id );
|
||||
}
|
||||
} else {
|
||||
return new WP_Error( 'term_exists', __( 'A term with the name already exists in this taxonomy.' ), $existing_term->term_id );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31733';
|
||||
$wp_version = '4.2-alpha-31734';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user