Introduce Custom Taxonomies Translation strings, Correctly identifies the taxonomy in the Strings of the edit pages. See #11838

git-svn-id: http://svn.automattic.com/wordpress/trunk@13077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-02-13 03:08:16 +00:00
parent 53ac3d960e
commit 8a5c11e08c
2 changed files with 53 additions and 40 deletions

View File

@ -10,11 +10,8 @@
if ( !defined('ABSPATH') ) if ( !defined('ABSPATH') )
die('-1'); die('-1');
if ( !current_user_can('manage_categories') )
wp_die(__('You do not have sufficient permissions to edit tags for this blog.'));
if ( empty($tag_ID) ) { ?> if ( empty($tag_ID) ) { ?>
<div id="message" class="updated"><p><strong><?php _e('A tag was not selected for editing.'); ?></strong></p></div> <div id="message" class="updated"><p><strong><?php _e('A item was not selected for editing.'); ?></strong></p></div>
<?php <?php
return; return;
} }
@ -27,7 +24,7 @@ do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?>
<div class="wrap"> <div class="wrap">
<?php screen_icon(); ?> <?php screen_icon(); ?>
<h2><?php _e('Edit Tag'); ?></h2> <h2><?php printf(_x('Edit %s', '%s: singular taxonomy name'), $tax->singular_label); ?></h2>
<div id="ajax-response"></div> <div id="ajax-response"></div>
<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"> <form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate">
<input type="hidden" name="action" value="editedtag" /> <input type="hidden" name="action" value="editedtag" />
@ -36,27 +33,30 @@ do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?>
<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?> <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?>
<table class="form-table"> <table class="form-table">
<tr class="form-field form-required"> <tr class="form-field form-required">
<th scope="row" valign="top"><label for="name"><?php _e('Tag name') ?></label></th> <th scope="row" valign="top"><label for="name"><?php echo _x('Name', 'Taxonomy Name'); ?></label></th>
<td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" /></td> <td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" />
<p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
</tr> </tr>
<?php if ( !is_multisite() ) { ?> <?php if ( !is_multisite() ) { ?>
<tr class="form-field"> <tr class="form-field">
<th scope="row" valign="top"><label for="slug"><?php _e('Tag slug') ?></label></th> <th scope="row" valign="top"><label for="slug"><?php echo _x('Slug', 'Taxonomy Slug'); ?></label></th>
<td><input name="slug" id="slug" type="text" value="<?php if ( isset( $tag->slug ) ) echo esc_attr(apply_filters('editable_slug', $tag->slug)); ?>" size="40" /> <td><input name="slug" id="slug" type="text" value="<?php if ( isset( $tag->slug ) ) echo esc_attr(apply_filters('editable_slug', $tag->slug)); ?>" size="40" />
<p class="description"><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td> <p class="description"><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td>
</tr> </tr>
<?php } ?> <?php } ?>
<?php if ( is_taxonomy_hierarchical($taxonomy) ) { ?> <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
<tr class="form-field"> <tr class="form-field">
<th scope="row" valign="top"><label for="parent"><?php _e('Category Parent') ?></label></th> <th scope="row" valign="top"><label for="parent"><?php echo _x('Parent', 'Taxonomy Parent'); ?></label></th>
<td> <td>
<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None'))); ?><br /> <?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None'))); ?><br />
<?php if ( 'category' == $taxonomy ) : ?>
<span class="description"><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></span> <span class="description"><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></span>
<?php endif; ?>
</td> </td>
</tr> </tr>
<?php } ?> <?php endif; // is_taxonomy_hierarchical() ?>
<tr class="form-field"> <tr class="form-field">
<th scope="row" valign="top"><label for="description"><?php _e('Description') ?></label></th> <th scope="row" valign="top"><label for="description"><?php echo _x('Description', 'Taxonomy Description'); ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo esc_html($tag->description); ?></textarea><br /> <td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo esc_html($tag->description); ?></textarea><br />
<span class="description"><?php _e('The description is not prominent by default, however some themes may show it.'); ?></span></td> <span class="description"><?php _e('The description is not prominent by default, however some themes may show it.'); ?></span></td>
</tr> </tr>
@ -68,7 +68,7 @@ do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?>
do_action($taxonomy . '_edit_form_fields', $tag, $taxonomy); do_action($taxonomy . '_edit_form_fields', $tag, $taxonomy);
?> ?>
</table> </table>
<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php esc_attr_e('Update Tag'); ?>" /></p> <p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php echo esc_attr( sprintf(_x('Update %s', '%s: singular taxonomy name'), $tax->singular_label)); ?>" /></p>
<?php <?php
if ( 'category' == $taxonomy ) if ( 'category' == $taxonomy )
do_action('edit_category_form', $tag); do_action('edit_category_form', $tag);

View File

@ -150,12 +150,14 @@ if ( current_user_can($tax->edit_cap) )
require_once ('admin-header.php'); require_once ('admin-header.php');
$messages[1] = __('Tag added.'); $messages[1] = __('Item added.');
$messages[2] = __('Tag deleted.'); $messages[2] = __('Item deleted.');
$messages[3] = __('Tag updated.'); $messages[3] = __('Item updated.');
$messages[4] = __('Tag not added.'); $messages[4] = __('Item not added.');
$messages[5] = __('Tag not updated.'); $messages[5] = __('Item not updated.');
$messages[6] = __('Tags deleted.'); ?> $messages[6] = __('Items deleted.');
?>
<div class="wrap nosubsub"> <div class="wrap nosubsub">
<?php screen_icon(); ?> <?php screen_icon(); ?>
@ -174,9 +176,9 @@ endif; ?>
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
<p class="search-box"> <p class="search-box">
<label class="screen-reader-text" for="tag-search-input"><?php _e( 'Search Tags' ); ?>:</label> <label class="screen-reader-text" for="tag-search-input"><?php printf(_x('Search %s', '%s: plural taxonomy name'), $tax->label); ?>:</label>
<input type="text" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" /> <input type="text" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" />
<input type="submit" value="<?php esc_attr_e( 'Search Tags' ); ?>" class="button" /> <input type="submit" value="<?php echo esc_attr( sprintf(_x('Search %s', '%s: plural taxonomy name'), $tax->label) ); ?>" class="button" />
</p> </p>
</form> </form>
<br class="clear" /> <br class="clear" />
@ -234,17 +236,17 @@ if ( $page_links )
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<?php $table_type = ('category' == $taxonomy ? 'categories' : 'edit-tags'); ?>
<table class="widefat tag fixed" cellspacing="0"> <table class="widefat tag fixed" cellspacing="0">
<thead> <thead>
<tr> <tr>
<?php print_column_headers('edit-tags'); ?> <?php print_column_headers($table_type); ?>
</tr> </tr>
</thead> </thead>
<tfoot> <tfoot>
<tr> <tr>
<?php print_column_headers('edit-tags', false); ?> <?php print_column_headers($table_type, false); ?>
</tr> </tr>
</tfoot> </tfoot>
@ -272,6 +274,15 @@ if ( $page_links )
<br class="clear" /> <br class="clear" />
</form> </form>
<?php if ( 'category' == $taxonomy ) : ?>
<div class="form-wrap">
<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_cat_name(get_option('default_category')))) ?></p>
<p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'admin.php?import=wp-cat2tag') ?></p>
</div>
<?php endif; ?>
</div> </div>
</div><!-- /col-right --> </div><!-- /col-right -->
@ -279,7 +290,7 @@ if ( $page_links )
<div class="col-wrap"> <div class="col-wrap">
<div class="tagcloud"> <div class="tagcloud">
<h3><?php _e('Popular Tags'); ?></h3> <h3><?php printf(_x('Popular %s', '%s: plural taxonomy name'), $tax->label); ?></h3>
<?php <?php
if ( current_user_can($tax->edit_cap) ) if ( current_user_can($tax->edit_cap) )
wp_tag_cloud(array('taxonomy' => $taxonomy, 'link' => 'edit')); wp_tag_cloud(array('taxonomy' => $taxonomy, 'link' => 'edit'));
@ -288,7 +299,8 @@ else
?> ?>
</div> </div>
<?php if ( current_user_can($tax->edit_cap) ) { <?php
if ( current_user_can($tax->edit_cap) ) {
if ( 'category' == $taxonomy ) if ( 'category' == $taxonomy )
do_action('add_category_form_pre', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_pre_add_form do_action('add_category_form_pre', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_pre_add_form
else else
@ -297,33 +309,35 @@ else
?> ?>
<div class="form-wrap"> <div class="form-wrap">
<h3><?php _e('Add a New Tag'); ?></h3> <h3><?php printf(_x('Add a New %s', '%s: singular taxonomy name'), $tax->singular_label); ?></h3>
<form id="addtag" method="post" action="edit-tags.php" class="validate"> <form id="addtag" method="post" action="edit-tags.php" class="validate">
<input type="hidden" name="action" value="add-tag" /> <input type="hidden" name="action" value="add-tag" />
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
<?php wp_nonce_field('add-tag'); ?> <?php wp_nonce_field('add-tag'); ?>
<div class="form-field form-required"> <div class="form-field form-required">
<label for="tag-name"><?php _e('Tag name') ?></label> <label for="tag-name"><?php echo _x('Name', 'Taxonomy Name'); ?></label>
<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" /> <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
<p><?php _e('The name is how the tag appears on your site.'); ?></p> <p><?php _e('The name is how it appears on your site.'); ?></p>
</div> </div>
<?php if ( !is_multisite() ) { ?> <?php if ( !is_multisite() ) : ?>
<div class="form-field"> <div class="form-field">
<label for="slug"><?php _e('Tag slug') ?></label> <label for="slug"><?php echo _x('Slug', 'Taxonomy Slug'); ?></label>
<input name="slug" id="slug" type="text" value="" size="40" /> <input name="slug" id="slug" type="text" value="" size="40" />
<p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p> <p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
</div> </div>
<?php } ?> <?php endif; // is_multisite() ?>
<?php if ( is_taxonomy_hierarchical($taxonomy) ) { ?> <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
<div class="form-field"> <div class="form-field">
<label for="category_parent"><?php _e('Category Parent') ?></label> <label for="parent"><?php echo _x('Parent', 'Taxonomy Parent'); ?></label>
<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?> <?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
<?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?>
<p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p> <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p>
<?php endif; ?>
</div> </div>
<?php } ?> <?php endif; // is_taxonomy_hierarchical() ?>
<div class="form-field"> <div class="form-field">
<label for="description"><?php _e('Description') ?></label> <label for="description"><?php echo _x('Description', 'Taxonomy Description'); ?></label>
<textarea name="description" id="description" rows="5" cols="40"></textarea> <textarea name="description" id="description" rows="5" cols="40"></textarea>
<p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p> <p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p>
</div> </div>
@ -333,8 +347,7 @@ if ( ! is_taxonomy_hierarchical($taxonomy) )
do_action('add_tag_form_fields', $taxonomy); do_action('add_tag_form_fields', $taxonomy);
do_action($taxonomy . '_add_form_fields', $taxonomy); do_action($taxonomy . '_add_form_fields', $taxonomy);
?> ?>
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php echo esc_attr(sprintf(_x('Add %s', '%s: singular taxonomy name'), $tax->singular_label)); ?>" /></p>
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php esc_attr_e('Add Tag'); ?>" /></p>
<?php <?php
if ( 'category' == $taxonomy ) if ( 'category' == $taxonomy )
do_action('edit_category_form', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_add_form do_action('edit_category_form', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_add_form