Press This: Do not show Categories & Tags UI for users who cannot assign terms to posts anyways.
Merge of [39968] to the 4.0 branch. Built from https://develop.svn.wordpress.org/branches/4.0@39978 git-svn-id: http://core.svn.wordpress.org/branches/4.0@39915 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
98590a9c90
commit
6c9f0e2e0f
|
@ -32,8 +32,25 @@ function press_it() {
|
|||
if ( !current_user_can('edit_post', $post_ID) )
|
||||
wp_die(__('You are not allowed to edit this post.'));
|
||||
|
||||
$post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : '';
|
||||
$post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : '';
|
||||
// Only accept categories if the user actually can assign
|
||||
$category_tax = get_taxonomy( 'category' );
|
||||
if ( current_user_can( $category_tax->cap->assign_terms ) ) {
|
||||
$post['post_category'] = ( ! empty( $_POST['post_category'] ) ) ? $_POST['post_category'] : array();
|
||||
}
|
||||
|
||||
// Only accept taxonomies if the user can actually assign
|
||||
if ( ! empty( $_POST['tax_input'] ) ) {
|
||||
$tax_input = $_POST['tax_input'];
|
||||
foreach ( $tax_input as $tax => $_ti ) {
|
||||
$tax_object = get_taxonomy( $tax );
|
||||
if ( ! $tax_object || ! current_user_can( $tax_object->cap->assign_terms ) ) {
|
||||
unset( $tax_input[ $tax ] );
|
||||
}
|
||||
}
|
||||
|
||||
$post['tax_input'] = $tax_input;
|
||||
}
|
||||
|
||||
$post['post_title'] = isset($_POST['title']) ? $_POST['title'] : '';
|
||||
$content = isset($_POST['content']) ? $_POST['content'] : '';
|
||||
|
||||
|
@ -523,7 +540,11 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<?php $tax = get_taxonomy( 'category' ); ?>
|
||||
<?php
|
||||
|
||||
$tax = get_taxonomy( 'category' );
|
||||
if ( current_user_can( $tax->cap->assign_terms ) ) :
|
||||
?>
|
||||
<div id="categorydiv" class="postbox">
|
||||
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
|
||||
<h3 class="hndle"><?php _e('Categories') ?></h3>
|
||||
|
@ -547,9 +568,6 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
<?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
|
||||
<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
|
||||
<?php endif; ?>
|
||||
<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
|
||||
<div id="category-adder" class="wp-hidden-children">
|
||||
<h4>
|
||||
|
@ -573,7 +591,11 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
$tax = get_taxonomy( 'post_tag' );
|
||||
if ( current_user_can( $tax->cap->assign_terms ) ) :
|
||||
?>
|
||||
<div id="tagsdiv-post_tag" class="postbox">
|
||||
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
|
||||
<h3><span><?php _e('Tags'); ?></span></h3>
|
||||
|
@ -592,6 +614,7 @@ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace(
|
|||
<p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags'); ?></a></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="posting">
|
||||
|
|
Loading…
Reference in New Issue