Move 'helps' argument to the taxonomy labels object. Also move over help_nojs and help_cloud, both introduced in 3.0. This adds three new core labels for non-hierarchical taxonomies, for tweaking the meta box strings. fixes #13805.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15190 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-06-10 16:07:33 +00:00
parent 5f4f0112a8
commit af612805e8
3 changed files with 14 additions and 12 deletions

View File

@ -250,17 +250,12 @@ function post_tags_meta_box($post, $box) {
extract( wp_parse_args($args, $defaults), EXTR_SKIP );
$tax_name = esc_attr($taxonomy);
$taxonomy = get_taxonomy($taxonomy);
$helps = isset( $taxonomy->helps ) ? esc_attr( $taxonomy->helps ) : esc_attr__('Separate tags with commas.');
$help_nojs = isset( $taxonomy->help_nojs ) ? $taxonomy->help_nojs : __('Add or remove tags');
$help_cloud = isset( $taxonomy->help_cloud ) ? $taxonomy->help_cloud : __('Choose from the most used tags');
$disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';
?>
<div class="tagsdiv" id="<?php echo $tax_name; ?>">
<div class="jaxtag">
<div class="nojs-tags hide-if-js">
<p><?php echo $help_nojs; ?></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 esc_attr(get_terms_to_edit( $post->ID, $tax_name )); ?></textarea></div>
<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
<div class="ajaxtag hide-if-no-js">
@ -269,13 +264,13 @@ function post_tags_meta_box($post, $box) {
<p><input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /></p>
</div>
<p class="howto"><?php echo $helps; ?></p>
<p class="howto"><?php echo esc_attr( $taxonomy->labels->separate_items_with_commas ); ?></p>
<?php endif; ?>
</div>
<div class="tagchecklist"></div>
</div>
<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $help_cloud; ?></a></p>
<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?></a></p>
<?php else : ?>
<p><em><?php _e('You cannot modify this taxonomy.'); ?></em></p>
<?php endif; ?>

View File

@ -966,13 +966,11 @@ function get_post_type_labels( $post_type_object ) {
*/
function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
if ( isset( $object->label ) ) {
if ( isset( $object->label ) && empty( $object->labels['name'] ) )
$object->labels['name'] = $object->label;
}
if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) {
if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) )
$object->labels['singular_name'] = $object->labels['name'];
}
$defaults = array_map( create_function( '$x', $object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
$labels = array_merge( $defaults, $object->labels );

View File

@ -334,6 +334,9 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
* - update_item - Default is Update Tag/Update Category
* - add_new_item - Default is Add New Tag/Add New Category
* - new_item_name - Default is New Tag Name/New Category Name
* - separate_items_with_commas - This string isn't used on hierarchical taxonomies. Default is "Separate tags with commas," used in the meta box.
* - add_or_remove_items - This string isn't used on hierarchical taxonomies. Default is "Add or remove tags," used in the meta box when JavaScript is disabled.
* - choose_from_most_used - This string isn't used on hierarchical taxonomies. Default is "Choose from the most used tags," used in the meta box.
*
* Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories.)
*
@ -343,6 +346,9 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
*/
function get_taxonomy_labels( $tax ) {
if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) )
$tax->labels['separate_items_with_commas'] = $tax->helps;
$nohier_vs_hier_defaults = array(
'name' => array( _x( 'Post Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
'singular_name' => array( _x( 'Post Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
@ -355,6 +361,9 @@ function get_taxonomy_labels( $tax ) {
'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ),
'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
'separate_items_with_commas' => array( __( 'Separate tags with commas' ), null ),
'add_or_remove_items' => array( __( 'Add or remove tags' ), null ),
'choose_from_most_used' => array( __( 'Choose from the most used tags' ), null ),
);
return _get_custom_object_labels( $tax, $nohier_vs_hier_defaults );