Allow localized commas to be used as tag separators. see #7897.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19853 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
86596214bd
commit
72c995441a
|
@ -66,6 +66,9 @@ function wp_ajax_ajax_tag_search() {
|
||||||
|
|
||||||
$s = stripslashes( $_GET['q'] );
|
$s = stripslashes( $_GET['q'] );
|
||||||
|
|
||||||
|
$comma = _x( ',', 'tag delimiter' );
|
||||||
|
if ( ',' !== $comma )
|
||||||
|
$s = str_replace( $comma, ',', $s );
|
||||||
if ( false !== strpos( $s, ',' ) ) {
|
if ( false !== strpos( $s, ',' ) ) {
|
||||||
$s = explode( ',', $s );
|
$s = explode( ',', $s );
|
||||||
$s = $s[count( $s ) - 1];
|
$s = $s[count( $s ) - 1];
|
||||||
|
|
|
@ -609,7 +609,8 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||||
esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) )
|
esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
echo join( ', ', $out );
|
/* translators: used between list items, there is a space after the comma */
|
||||||
|
echo join( __( ', ' ), $out );
|
||||||
} else {
|
} else {
|
||||||
_e( 'Uncategorized' );
|
_e( 'Uncategorized' );
|
||||||
}
|
}
|
||||||
|
@ -629,7 +630,8 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||||
esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) )
|
esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
echo join( ', ', $out );
|
/* translators: used between list items, there is a space after the comma */
|
||||||
|
echo join( __( ', ' ), $out );
|
||||||
} else {
|
} else {
|
||||||
_e( 'No Tags' );
|
_e( 'No Tags' );
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,12 +276,13 @@ function post_tags_meta_box($post, $box) {
|
||||||
$tax_name = esc_attr($taxonomy);
|
$tax_name = esc_attr($taxonomy);
|
||||||
$taxonomy = get_taxonomy($taxonomy);
|
$taxonomy = get_taxonomy($taxonomy);
|
||||||
$disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';
|
$disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';
|
||||||
|
$comma = _x( ',', 'tag delimiter' );
|
||||||
?>
|
?>
|
||||||
<div class="tagsdiv" id="<?php echo $tax_name; ?>">
|
<div class="tagsdiv" id="<?php echo $tax_name; ?>">
|
||||||
<div class="jaxtag">
|
<div class="jaxtag">
|
||||||
<div class="nojs-tags hide-if-js">
|
<div class="nojs-tags hide-if-js">
|
||||||
<p><?php echo $taxonomy->labels->add_or_remove_items; ?></p>
|
<p><?php echo $taxonomy->labels->add_or_remove_items; ?></p>
|
||||||
<textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo get_terms_to_edit( $post->ID, $tax_name ); // textarea_escaped by esc_attr() ?></textarea></div>
|
<textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo str_replace( ',', $comma . ' ', get_terms_to_edit( $post->ID, $tax_name ) ); // textarea_escaped by esc_attr() ?></textarea></div>
|
||||||
<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
|
<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
|
||||||
<div class="ajaxtag hide-if-no-js">
|
<div class="ajaxtag hide-if-no-js">
|
||||||
<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
|
<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
|
||||||
|
|
|
@ -304,8 +304,10 @@ function bulk_edit_posts( $post_data = null ) {
|
||||||
if ( is_taxonomy_hierarchical( $tax_name ) ) {
|
if ( is_taxonomy_hierarchical( $tax_name ) ) {
|
||||||
$tax_input[ $tax_name ] = array_map( 'absint', $terms );
|
$tax_input[ $tax_name ] = array_map( 'absint', $terms );
|
||||||
} else {
|
} else {
|
||||||
$tax_input[$tax_name] = preg_replace( '/\s*,\s*/', ',', rtrim( trim($terms), ' ,' ) );
|
$comma = _x( ',', 'tag delimiter' );
|
||||||
$tax_input[$tax_name] = explode(',', $tax_input[$tax_name]);
|
if ( ',' !== $comma )
|
||||||
|
$terms = str_replace( $comma, ',', $terms );
|
||||||
|
$tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,10 +264,13 @@ function get_inline_data($post) {
|
||||||
foreach ( $taxonomy_names as $taxonomy_name) {
|
foreach ( $taxonomy_names as $taxonomy_name) {
|
||||||
$taxonomy = get_taxonomy( $taxonomy_name );
|
$taxonomy = get_taxonomy( $taxonomy_name );
|
||||||
|
|
||||||
if ( $taxonomy->hierarchical && $taxonomy->show_ui )
|
if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
|
||||||
echo '<div class="post_category" id="'.$taxonomy_name.'_'.$post->ID.'">' . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array('fields'=>'ids')) ) . '</div>';
|
echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">'
|
||||||
elseif ( $taxonomy->show_ui )
|
. implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array( 'fields' => 'ids' ) ) ) . '</div>';
|
||||||
echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' . esc_html( str_replace( ',', ', ', get_terms_to_edit($post->ID, $taxonomy_name) ) ) . '</div>';
|
} elseif ( $taxonomy->show_ui ) {
|
||||||
|
echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
|
||||||
|
. esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$post_type_object->hierarchical )
|
if ( !$post_type_object->hierarchical )
|
||||||
|
|
|
@ -117,7 +117,7 @@ inlineEditPost = {
|
||||||
if ( 'post' == type ) {
|
if ( 'post' == type ) {
|
||||||
// support multi taxonomies?
|
// support multi taxonomies?
|
||||||
tax = 'post_tag';
|
tax = 'post_tag';
|
||||||
$('tr.inline-editor textarea[name="tax_input['+tax+']"]').suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
|
$('tr.inline-editor textarea[name="tax_input['+tax+']"]').suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: inlineEditL10n.comma + ' ' } );
|
||||||
}
|
}
|
||||||
$('html, body').animate( { scrollTop: 0 }, 'fast' );
|
$('html, body').animate( { scrollTop: 0 }, 'fast' );
|
||||||
},
|
},
|
||||||
|
@ -184,12 +184,16 @@ inlineEditPost = {
|
||||||
$('.tags_input', rowData).each(function(){
|
$('.tags_input', rowData).each(function(){
|
||||||
var terms = $(this).text(),
|
var terms = $(this).text(),
|
||||||
taxname = $(this).attr('id').replace('_' + id, ''),
|
taxname = $(this).attr('id').replace('_' + id, ''),
|
||||||
textarea = $('textarea.tax_input_' + taxname, editRow);
|
textarea = $('textarea.tax_input_' + taxname, editRow),
|
||||||
|
comma = inlineEditL10n.comma;
|
||||||
|
|
||||||
if ( terms )
|
if ( terms ) {
|
||||||
|
if ( ',' !== comma )
|
||||||
|
terms = terms.replace(/,/g, comma);
|
||||||
textarea.val(terms);
|
textarea.val(terms);
|
||||||
|
}
|
||||||
|
|
||||||
textarea.suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
|
textarea.suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: inlineEditL10n.comma + ' ' } );
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle the post status
|
// handle the post status
|
||||||
|
|
|
@ -15,11 +15,19 @@ function array_unique_noempty(a) {
|
||||||
|
|
||||||
tagBox = {
|
tagBox = {
|
||||||
clean : function(tags) {
|
clean : function(tags) {
|
||||||
return tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
|
var comma = postL10n.comma;
|
||||||
|
if ( ',' !== comma )
|
||||||
|
tags = tags.replace(new RegExp(comma, 'g'), ',');
|
||||||
|
tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
|
||||||
|
if ( ',' !== comma )
|
||||||
|
tags = tags.replace(/,/g, comma);
|
||||||
|
return tags;
|
||||||
},
|
},
|
||||||
|
|
||||||
parseTags : function(el) {
|
parseTags : function(el) {
|
||||||
var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.tagsdiv'), thetags = taxbox.find('.the-tags'), current_tags = thetags.val().split(','), new_tags = [];
|
var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.tagsdiv'),
|
||||||
|
thetags = taxbox.find('.the-tags'), comma = postL10n.comma,
|
||||||
|
current_tags = thetags.val().split(comma), new_tags = [];
|
||||||
delete current_tags[num];
|
delete current_tags[num];
|
||||||
|
|
||||||
$.each( current_tags, function(key, val) {
|
$.each( current_tags, function(key, val) {
|
||||||
|
@ -29,7 +37,7 @@ tagBox = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
thetags.val( this.clean( new_tags.join(',') ) );
|
thetags.val( this.clean( new_tags.join(comma) ) );
|
||||||
|
|
||||||
this.quickClicks(taxbox);
|
this.quickClicks(taxbox);
|
||||||
return false;
|
return false;
|
||||||
|
@ -46,7 +54,7 @@ tagBox = {
|
||||||
|
|
||||||
disabled = thetags.prop('disabled');
|
disabled = thetags.prop('disabled');
|
||||||
|
|
||||||
current_tags = thetags.val().split(',');
|
current_tags = thetags.val().split(postL10n.comma);
|
||||||
tagchecklist.empty();
|
tagchecklist.empty();
|
||||||
|
|
||||||
$.each( current_tags, function( key, val ) {
|
$.each( current_tags, function( key, val ) {
|
||||||
|
@ -74,14 +82,17 @@ tagBox = {
|
||||||
|
|
||||||
flushTags : function(el, a, f) {
|
flushTags : function(el, a, f) {
|
||||||
a = a || false;
|
a = a || false;
|
||||||
var text, tags = $('.the-tags', el), newtag = $('input.newtag', el), newtags;
|
var tags = $('.the-tags', el),
|
||||||
|
newtag = $('input.newtag', el),
|
||||||
|
comma = postL10n.comma,
|
||||||
|
newtags, text;
|
||||||
|
|
||||||
text = a ? $(a).text() : newtag.val();
|
text = a ? $(a).text() : newtag.val();
|
||||||
tagsval = tags.val();
|
tagsval = tags.val();
|
||||||
newtags = tagsval ? tagsval + ',' + text : text;
|
newtags = tagsval ? tagsval + comma + text : text;
|
||||||
|
|
||||||
newtags = this.clean( newtags );
|
newtags = this.clean( newtags );
|
||||||
newtags = array_unique_noempty( newtags.split(',') ).join(',');
|
newtags = array_unique_noempty( newtags.split(comma) ).join(comma);
|
||||||
tags.val(newtags);
|
tags.val(newtags);
|
||||||
this.quickClicks(el);
|
this.quickClicks(el);
|
||||||
|
|
||||||
|
@ -142,7 +153,7 @@ tagBox = {
|
||||||
}
|
}
|
||||||
}).each(function(){
|
}).each(function(){
|
||||||
var tax = $(this).closest('div.tagsdiv').attr('id');
|
var tax = $(this).closest('div.tagsdiv').attr('id');
|
||||||
$(this).suggest( ajaxurl + '?action=ajax-tag-search&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: "," } );
|
$(this).suggest( ajaxurl + '?action=ajax-tag-search&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: postL10n.comma + ' ' } );
|
||||||
});
|
});
|
||||||
|
|
||||||
// save tags on post save/publish
|
// save tags on post save/publish
|
||||||
|
|
|
@ -2907,7 +2907,12 @@ function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $a
|
||||||
if ( empty($tags) )
|
if ( empty($tags) )
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
|
||||||
$tags = is_array($tags) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") );
|
if ( ! is_array( $tags ) ) {
|
||||||
|
$comma = _x( ',', 'tag delimiter' );
|
||||||
|
if ( ',' !== $comma )
|
||||||
|
$tags = str_replace( $comma, ',', $tags );
|
||||||
|
$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Hierarchical taxonomies must always pass IDs rather than names so that children with the same
|
// Hierarchical taxonomies must always pass IDs rather than names so that children with the same
|
||||||
// names but different parents aren't confused.
|
// names but different parents aren't confused.
|
||||||
|
|
|
@ -330,7 +330,8 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'publicSticky' => __('Public, Sticky'),
|
'publicSticky' => __('Public, Sticky'),
|
||||||
'password' => __('Password Protected'),
|
'password' => __('Password Protected'),
|
||||||
'privatelyPublished' => __('Privately Published'),
|
'privatelyPublished' => __('Privately Published'),
|
||||||
'published' => __('Published')
|
'published' => __('Published'),
|
||||||
|
'comma' => _x( ',', 'tag delimiter' ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), false, 1 );
|
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), false, 1 );
|
||||||
|
@ -353,7 +354,8 @@ function wp_default_scripts( &$scripts ) {
|
||||||
$scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
|
$scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
|
||||||
'error' => __('Error while saving the changes.'),
|
'error' => __('Error while saving the changes.'),
|
||||||
'ntdeltitle' => __('Remove From Bulk Edit'),
|
'ntdeltitle' => __('Remove From Bulk Edit'),
|
||||||
'notitle' => __('(no title)')
|
'notitle' => __('(no title)'),
|
||||||
|
'comma' => _x( ',', 'tag delimiter' ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), false, 1 );
|
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), false, 1 );
|
||||||
|
|
Loading…
Reference in New Issue