- Timestamp:
- 01/26/2017 02:10:15 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.4/src/wp-admin/includes/class-wp-press-this.php
r35636 r39973 120 120 'post_status' => 'draft', 121 121 'post_format' => ( ! empty( $_POST['post_format'] ) ) ? sanitize_text_field( $_POST['post_format'] ) : '', 122 'tax_input' => ( ! empty( $_POST['tax_input'] ) ) ? $_POST['tax_input'] : array(),123 'post_category' => ( ! empty( $_POST['post_category'] ) ) ? $_POST['post_category'] : array(),124 122 ); 125 123 124 // Only accept categories if the user actually can assign 125 $category_tax = get_taxonomy( 'category' ); 126 if ( current_user_can( $category_tax->cap->assign_terms ) ) { 127 $post_data['post_category'] = ( ! empty( $_POST['post_category'] ) ) ? $_POST['post_category'] : array(); 128 } 129 130 // Only accept taxonomies if the user can actually assign 131 if ( ! empty( $_POST['tax_input'] ) ) { 132 $tax_input = $_POST['tax_input']; 133 foreach ( $tax_input as $tax => $_ti ) { 134 $tax_object = get_taxonomy( $tax ); 135 if ( ! $tax_object || ! current_user_can( $tax_object->cap->assign_terms ) ) { 136 unset( $tax_input[ $tax ] ); 137 } 138 } 139 140 $post_data['tax_input'] = $tax_input; 141 } 142 143 // Toggle status to pending if user cannot actually publish 126 144 if ( ! empty( $_POST['post_status'] ) && 'publish' === $_POST['post_status'] ) { 127 145 if ( current_user_can( 'publish_posts' ) ) { … … 445 463 * 446 464 * @param string $src Embed source URL. 447 * @return string If not from a supported provider, an empty string. Otherwise, a reformatt d embed URL.465 * @return string If not from a supported provider, an empty string. Otherwise, a reformatted embed URL. 448 466 */ 449 467 private function _limit_embed( $src ) { … … 875 893 $taxonomy = get_taxonomy( 'category' ); 876 894 895 // Bail if user cannot assign terms 896 if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { 897 return; 898 } 899 900 // Only show "add" if user can edit terms 877 901 if ( current_user_can( $taxonomy->cap->edit_terms ) ) { 878 902 ?> … … 1288 1312 wp_enqueue_script( 'editor' ); 1289 1313 1314 $categories_tax = get_taxonomy( 'category' ); 1315 $show_categories = current_user_can( $categories_tax->cap->assign_terms ) || current_user_can( $categories_tax->cap->edit_terms ); 1316 1317 $tag_tax = get_taxonomy( 'post_tag' ); 1318 $show_tags = current_user_can( $tag_tax->cap->assign_terms ); 1319 1290 1320 $supports_formats = false; 1291 1321 $post_format = 0; … … 1439 1469 <?php endif; ?> 1440 1470 1441 <button type="button" class="button-link post-option"> 1442 <span class="dashicons dashicons-category"></span> 1443 <span class="post-option-title"><?php _e( 'Categories' ); ?></span> 1444 <span class="dashicons post-option-forward"></span> 1445 </button> 1446 1447 <button type="button" class="button-link post-option"> 1448 <span class="dashicons dashicons-tag"></span> 1449 <span class="post-option-title"><?php _e( 'Tags' ); ?></span> 1450 <span class="dashicons post-option-forward"></span> 1451 </button> 1471 <?php if ( $show_categories ) : ?> 1472 <button type="button" class="button-link post-option"> 1473 <span class="dashicons dashicons-category"></span> 1474 <span class="post-option-title"><?php _e( 'Categories' ); ?></span> 1475 <span class="dashicons post-option-forward"></span> 1476 </button> 1477 <?php endif; ?> 1478 1479 <?php if ( $show_tags ) : ?> 1480 <button type="button" class="button-link post-option"> 1481 <span class="dashicons dashicons-tag"></span> 1482 <span class="post-option-title"><?php _e( 'Tags' ); ?></span> 1483 <span class="dashicons post-option-forward"></span> 1484 </button> 1485 <?php endif; ?> 1452 1486 </div> 1453 1487 … … 1463 1497 <?php endif; ?> 1464 1498 1465 <div class="setting-modal is-off-screen is-hidden"> 1466 <button type="button" class="button-link modal-close"> 1467 <span class="dashicons post-option-back"></span> 1468 <span class="setting-title" aria-hidden="true"><?php _e( 'Categories' ); ?></span> 1469 <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> 1470 </button> 1471 <?php $this->categories_html( $post ); ?> 1472 </div> 1473 1474 <div class="setting-modal tags is-off-screen is-hidden"> 1475 <button type="button" class="button-link modal-close"> 1476 <span class="dashicons post-option-back"></span> 1477 <span class="setting-title" aria-hidden="true"><?php _e( 'Tags' ); ?></span> 1478 <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> 1479 </button> 1480 <?php $this->tags_html( $post ); ?> 1481 </div> 1499 <?php if ( $show_categories ) : ?> 1500 <div class="setting-modal is-off-screen is-hidden"> 1501 <button type="button" class="button-link modal-close"> 1502 <span class="dashicons post-option-back"></span> 1503 <span class="setting-title" aria-hidden="true"><?php _e( 'Categories' ); ?></span> 1504 <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> 1505 </button> 1506 <?php $this->categories_html( $post ); ?> 1507 </div> 1508 <?php endif; ?> 1509 1510 <?php if ( $show_tags ) : ?> 1511 <div class="setting-modal tags is-off-screen is-hidden"> 1512 <button type="button" class="button-link modal-close"> 1513 <span class="dashicons post-option-back"></span> 1514 <span class="setting-title" aria-hidden="true"><?php _e( 'Tags' ); ?></span> 1515 <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> 1516 </button> 1517 <?php $this->tags_html( $post ); ?> 1518 </div> 1519 <?php endif; ?> 1482 1520 </div><!-- .options-panel --> 1483 1521 </div><!-- .wrapper -->
Note: See TracChangeset
for help on using the changeset viewer.