@@ -34,8 +34,25 @@ function press_it() {
3434 if ( !current_user_can ('edit_post ' , $ post_ID ) )
3535 wp_die (__ ('You are not allowed to edit this post. ' ));
3636
37- $ post ['post_category ' ] = isset ($ _POST ['post_category ' ]) ? $ _POST ['post_category ' ] : '' ;
38- $ post ['tax_input ' ] = isset ($ _POST ['tax_input ' ]) ? $ _POST ['tax_input ' ] : '' ;
37+ // Only accept categories if the user actually can assign
38+ $ category_tax = get_taxonomy ( 'category ' );
39+ if ( current_user_can ( $ category_tax ->cap ->assign_terms ) ) {
40+ $ post ['post_category ' ] = ( ! empty ( $ _POST ['post_category ' ] ) ) ? $ _POST ['post_category ' ] : array ();
41+ }
42+
43+ // Only accept taxonomies if the user can actually assign
44+ if ( ! empty ( $ _POST ['tax_input ' ] ) ) {
45+ $ tax_input = $ _POST ['tax_input ' ];
46+ foreach ( $ tax_input as $ tax => $ _ti ) {
47+ $ tax_object = get_taxonomy ( $ tax );
48+ if ( ! $ tax_object || ! current_user_can ( $ tax_object ->cap ->assign_terms ) ) {
49+ unset( $ tax_input [ $ tax ] );
50+ }
51+ }
52+
53+ $ post ['tax_input ' ] = $ tax_input ;
54+ }
55+
3956 $ post ['post_title ' ] = isset ($ _POST ['title ' ]) ? $ _POST ['title ' ] : '' ;
4057 $ content = isset ($ _POST ['content ' ]) ? $ _POST ['content ' ] : '' ;
4158
@@ -490,75 +507,81 @@ function setup_photo_actions() {
490507 </div>
491508 </div>
492509
493- <?php $ tax = get_taxonomy ( 'category ' ); ?>
494- <div id="categorydiv" class="postbox">
495- <div class="handlediv" title="<?php esc_attr_e ( 'Click to toggle ' ); ?> "><br /></div>
496- <h3 class="hndle"><?php _e ('Categories ' ) ?> </h3>
497- <div class="inside">
498- <div id="taxonomy-category" class="categorydiv">
499-
500- <ul id="category-tabs" class="category-tabs">
501- <li class="tabs"><a href="#category-all"><?php echo $ tax ->labels ->all_items ; ?> </a></li>
502- <li class="hide-if-no-js"><a href="#category-pop"><?php _e ( 'Most Used ' ); ?> </a></li>
503- </ul>
510+ <?php
504511
505- <div id="category-pop" class="tabs-panel" style="display: none;">
506- <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
507- <?php $ popular_ids = wp_popular_terms_checklist ( 'category ' ); ?>
512+ $ tax = get_taxonomy ( 'category ' );
513+ if ( current_user_can ( $ tax ->cap ->assign_terms ) ) :
514+ ?>
515+ <div id="categorydiv" class="postbox">
516+ <div class="handlediv" title="<?php esc_attr_e ( 'Click to toggle ' ); ?> "><br /></div>
517+ <h3 class="hndle"><?php _e ('Categories ' ) ?> </h3>
518+ <div class="inside">
519+ <div id="taxonomy-category" class="categorydiv">
520+
521+ <ul id="category-tabs" class="category-tabs">
522+ <li class="tabs"><a href="#category-all"><?php echo $ tax ->labels ->all_items ; ?> </a></li>
523+ <li class="hide-if-no-js"><a href="#category-pop"><?php _e ( 'Most Used ' ); ?> </a></li>
508524 </ul>
509- </div>
510525
511- <div id="category-all " class="tabs-panel">
512- <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
513- <?php wp_terms_checklist ( $ post_ID , array ( 'taxonomy ' => ' category ', ' popular_cats ' => $ popular_ids ) ) ?>
514- </ul>
515- </div>
526+ <div id="category-pop " class="tabs-panel" style="display: none; ">
527+ <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
528+ <?php $ popular_ids = wp_popular_terms_checklist ( 'category ' ); ?>
529+ </ul>
530+ </div>
516531
517- <?php if ( !current_user_can ($ tax ->cap ->assign_terms ) ) : ?>
518- <p><em><?php _e ('You cannot modify this Taxonomy. ' ); ?> </em></p>
519- <?php endif ; ?>
520- <?php if ( current_user_can ($ tax ->cap ->edit_terms ) ) : ?>
521- <div id="category-adder" class="wp-hidden-children">
522- <h4>
523- <a id="category-add-toggle" href="#category-add" class="hide-if-no-js">
524- <?php printf ( __ ( '+ %s ' ), $ tax ->labels ->add_new_item ); ?>
525- </a>
526- </h4>
527- <p id="category-add" class="category-add wp-hidden-child">
528- <label class="screen-reader-text" for="newcategory"><?php echo $ tax ->labels ->add_new_item ; ?> </label>
529- <input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr ( $ tax ->labels ->new_item_name ); ?> " aria-required="true"/>
530- <label class="screen-reader-text" for="newcategory_parent">
531- <?php echo $ tax ->labels ->parent_item_colon ; ?>
532- </label>
533- <?php wp_dropdown_categories ( array ( 'taxonomy ' => 'category ' , 'hide_empty ' => 0 , 'name ' => 'newcategory_parent ' , 'orderby ' => 'name ' , 'hierarchical ' => 1 , 'show_option_none ' => '— ' . $ tax ->labels ->parent_item . ' — ' ) ); ?>
534- <input type="button" id="category-add-submit" data-wp-lists="add:categorychecklist:category-add" class="button category-add-submit" value="<?php echo esc_attr ( $ tax ->labels ->add_new_item ); ?> " />
535- <?php wp_nonce_field ( 'add-category ' , '_ajax_nonce-add-category ' , false ); ?>
536- <span id="category-ajax-response"></span>
537- </p>
532+ <div id="category-all" class="tabs-panel">
533+ <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
534+ <?php wp_terms_checklist ($ post_ID , array ( 'taxonomy ' => 'category ' , 'popular_cats ' => $ popular_ids ) ) ?>
535+ </ul>
538536 </div>
539- <?php endif ; ?>
540- </div>
537+
538+ <?php if ( current_user_can ($ tax ->cap ->edit_terms ) ) : ?>
539+ <div id="category-adder" class="wp-hidden-children">
540+ <h4>
541+ <a id="category-add-toggle" href="#category-add" class="hide-if-no-js">
542+ <?php printf ( __ ( '+ %s ' ), $ tax ->labels ->add_new_item ); ?>
543+ </a>
544+ </h4>
545+ <p id="category-add" class="category-add wp-hidden-child">
546+ <label class="screen-reader-text" for="newcategory"><?php echo $ tax ->labels ->add_new_item ; ?> </label>
547+ <input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr ( $ tax ->labels ->new_item_name ); ?> " aria-required="true"/>
548+ <label class="screen-reader-text" for="newcategory_parent">
549+ <?php echo $ tax ->labels ->parent_item_colon ; ?>
550+ </label>
551+ <?php wp_dropdown_categories ( array ( 'taxonomy ' => 'category ' , 'hide_empty ' => 0 , 'name ' => 'newcategory_parent ' , 'orderby ' => 'name ' , 'hierarchical ' => 1 , 'show_option_none ' => '— ' . $ tax ->labels ->parent_item . ' — ' ) ); ?>
552+ <input type="button" id="category-add-submit" data-wp-lists="add:categorychecklist:category-add" class="button category-add-submit" value="<?php echo esc_attr ( $ tax ->labels ->add_new_item ); ?> " />
553+ <?php wp_nonce_field ( 'add-category ' , '_ajax_nonce-add-category ' , false ); ?>
554+ <span id="category-ajax-response"></span>
555+ </p>
556+ </div>
557+ <?php endif ; ?>
558+ </div>
559+ </div>
541560 </div>
542- </div>
561+ <?php endif ;
543562
544- <div id="tagsdiv-post_tag" class="postbox">
545- <div class="handlediv" title="<?php esc_attr_e ( 'Click to toggle ' ); ?> "><br /></div>
546- <h3><span><?php _e ('Tags ' ); ?> </span></h3>
547- <div class="inside">
548- <div class="tagsdiv" id="post_tag">
549- <div class="jaxtag">
550- <label class="screen-reader-text" for="newtag"><?php _e ('Tags ' ); ?> </label>
551- <input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
552- <div class="ajaxtag">
553- <input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
554- <input type="button" class="button tagadd" value="<?php esc_attr_e ('Add ' ); ?> " />
563+ $ tax = get_taxonomy ( 'post_tag ' );
564+ if ( current_user_can ( $ tax ->cap ->assign_terms ) ) :
565+ ?>
566+ <div id="tagsdiv-post_tag" class="postbox">
567+ <div class="handlediv" title="<?php esc_attr_e ( 'Click to toggle ' ); ?> "><br /></div>
568+ <h3><span><?php _e ('Tags ' ); ?> </span></h3>
569+ <div class="inside">
570+ <div class="tagsdiv" id="post_tag">
571+ <div class="jaxtag">
572+ <label class="screen-reader-text" for="newtag"><?php _e ('Tags ' ); ?> </label>
573+ <input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
574+ <div class="ajaxtag">
575+ <input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
576+ <input type="button" class="button tagadd" value="<?php esc_attr_e ('Add ' ); ?> " />
577+ </div>
555578 </div>
579+ <div class="tagchecklist"></div>
556580 </div>
557- <div class="tagchecklist "></div >
581+ <p class="tagcloud-link "><a href="#titlediv" class="tagcloud-link" id="link-post_tag"> <?php _e ( ' Choose from the most used tags ' ); ?> </a></p >
558582 </div>
559- <p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e ('Choose from the most used tags ' ); ?> </a></p>
560583 </div>
561- </div >
584+ <?php endif ; ? >
562585 </div>
563586 </div>
564587 <div class="posting">
0 commit comments