Display the list of Terms in a non-hierarchical taxonomy on the Post Edit page even if they cannot modify them. See #12035
git-svn-id: http://svn.automattic.com/wordpress/trunk@13855 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0e4aaa13d3
commit
4422f6d1fd
|
@ -246,29 +246,35 @@ if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0
|
|||
function post_tags_meta_box($post, $box) {
|
||||
$tax_name = esc_attr(substr($box['id'], 8));
|
||||
$taxonomy = get_taxonomy($tax_name);
|
||||
if ( !current_user_can($taxonomy->assign_cap) ) // @todo: Display the terms, do not edit.
|
||||
return;
|
||||
$helps = isset( $taxonomy->helps ) ? esc_attr( $taxonomy->helps ) : esc_attr__('Separate tags with commas.');
|
||||
$help_hint = isset( $taxonomy->help_hint ) ? $taxonomy->help_hint : __('Add new tag');
|
||||
$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 in %s');
|
||||
|
||||
$disabled = !current_user_can($taxonomy->assign_cap) ? '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>
|
||||
<textarea name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]"><?php echo esc_attr(get_terms_to_edit( $post->ID, $tax_name )); ?></textarea></div>
|
||||
|
||||
<textarea name="<?php echo "tax_input[$tax_name]"; ?>" 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->assign_cap) ) : ?>
|
||||
<div class="ajaxtag hide-if-no-js">
|
||||
<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
|
||||
<div class="taghint"><?php echo $help_hint; ?></div>
|
||||
<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" />
|
||||
</div></div>
|
||||
</div>
|
||||
<p class="howto"><?php echo $helps; ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="tagchecklist"></div>
|
||||
</div>
|
||||
<?php if ( current_user_can($taxonomy->assign_cap) ) : ?>
|
||||
<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( $help_cloud, $box['title'] ); ?></a></p>
|
||||
<?php else : ?>
|
||||
<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
@ -307,7 +313,9 @@ function post_categories_meta_box( $post, $box ) {
|
|||
<?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?php if ( !current_user_can($tax->assign_cap) ) : ?>
|
||||
<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
|
||||
<?php endif; ?>
|
||||
<?php if ( current_user_can($tax->edit_cap) ) : ?>
|
||||
<div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
|
||||
<h4><a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3"><?php printf( __( '+ Add New %s' ), $tax->singular_label ); ?></a></h4>
|
||||
|
|
|
@ -41,6 +41,8 @@ tagBox = {
|
|||
if ( !thetags.length )
|
||||
return;
|
||||
|
||||
var disabled = thetags.attr('disabled');
|
||||
|
||||
current_tags = thetags.val().split(',');
|
||||
tagchecklist.empty();
|
||||
|
||||
|
@ -50,9 +52,13 @@ tagBox = {
|
|||
val = $.trim(val);
|
||||
if ( !val.match(/^\s+$/) && '' != val ) {
|
||||
button_id = id + '-check-num-' + key;
|
||||
txt = '<span><a id="' + button_id + '" class="ntdelbutton">X</a> ' + val + '</span> ';
|
||||
if ( disabled )
|
||||
txt = '<span>' + val + '</span> ';
|
||||
else
|
||||
txt = '<span><a id="' + button_id + '" class="ntdelbutton">X</a> ' + val + '</span> ';
|
||||
tagchecklist.append(txt);
|
||||
$( '#' + button_id ).click( function(){ tagBox.parseTags(this); });
|
||||
if ( ! disabled )
|
||||
$( '#' + button_id ).click( function(){ tagBox.parseTags(this); });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue