Changeset 39972
- Timestamp:
- 01/26/2017 02:09:27 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.5/src/wp-admin/includes/class-wp-press-this.php
r36970 r39972 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' ) ) { … … 455 473 * 456 474 * @param string $src Embed source URL. 457 * @return string If not from a supported provider, an empty string. Otherwise, a reformatt d embed URL.475 * @return string If not from a supported provider, an empty string. Otherwise, a reformatted embed URL. 458 476 */ 459 477 private function _limit_embed( $src ) { … … 885 903 $taxonomy = get_taxonomy( 'category' ); 886 904 905 // Bail if user cannot assign terms 906 if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { 907 return; 908 } 909 910 // Only show "add" if user can edit terms 887 911 if ( current_user_can( $taxonomy->cap->edit_terms ) ) { 888 912 ?> … … 1303 1327 wp_enqueue_script( 'editor' ); 1304 1328 1329 $categories_tax = get_taxonomy( 'category' ); 1330 $show_categories = current_user_can( $categories_tax->cap->assign_terms ) || current_user_can( $categories_tax->cap->edit_terms ); 1331 1332 $tag_tax = get_taxonomy( 'post_tag' ); 1333 $show_tags = current_user_can( $tag_tax->cap->assign_terms ); 1334 1305 1335 $supports_formats = false; 1306 1336 $post_format = 0; … … 1454 1484 <?php endif; ?> 1455 1485 1456 <button type="button" class="button-link post-option"> 1457 <span class="dashicons dashicons-category"></span> 1458 <span class="post-option-title"><?php _e( 'Categories' ); ?></span> 1459 <span class="dashicons post-option-forward"></span> 1460 </button> 1461 1462 <button type="button" class="button-link post-option"> 1463 <span class="dashicons dashicons-tag"></span> 1464 <span class="post-option-title"><?php _e( 'Tags' ); ?></span> 1465 <span class="dashicons post-option-forward"></span> 1466 </button> 1486 <?php if ( $show_categories ) : ?> 1487 <button type="button" class="button-link post-option"> 1488 <span class="dashicons dashicons-category"></span> 1489 <span class="post-option-title"><?php _e( 'Categories' ); ?></span> 1490 <span class="dashicons post-option-forward"></span> 1491 </button> 1492 <?php endif; ?> 1493 1494 <?php if ( $show_tags ) : ?> 1495 <button type="button" class="button-link post-option"> 1496 <span class="dashicons dashicons-tag"></span> 1497 <span class="post-option-title"><?php _e( 'Tags' ); ?></span> 1498 <span class="dashicons post-option-forward"></span> 1499 </button> 1500 <?php endif; ?> 1467 1501 </div> 1468 1502 … … 1478 1512 <?php endif; ?> 1479 1513 1480 <div class="setting-modal is-off-screen is-hidden"> 1481 <button type="button" class="button-link modal-close"> 1482 <span class="dashicons post-option-back"></span> 1483 <span class="setting-title" aria-hidden="true"><?php _e( 'Categories' ); ?></span> 1484 <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> 1485 </button> 1486 <?php $this->categories_html( $post ); ?> 1487 </div> 1488 1489 <div class="setting-modal tags is-off-screen is-hidden"> 1490 <button type="button" class="button-link modal-close"> 1491 <span class="dashicons post-option-back"></span> 1492 <span class="setting-title" aria-hidden="true"><?php _e( 'Tags' ); ?></span> 1493 <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> 1494 </button> 1495 <?php $this->tags_html( $post ); ?> 1496 </div> 1514 <?php if ( $show_categories ) : ?> 1515 <div class="setting-modal is-off-screen is-hidden"> 1516 <button type="button" class="button-link modal-close"> 1517 <span class="dashicons post-option-back"></span> 1518 <span class="setting-title" aria-hidden="true"><?php _e( 'Categories' ); ?></span> 1519 <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> 1520 </button> 1521 <?php $this->categories_html( $post ); ?> 1522 </div> 1523 <?php endif; ?> 1524 1525 <?php if ( $show_tags ) : ?> 1526 <div class="setting-modal tags is-off-screen is-hidden"> 1527 <button type="button" class="button-link modal-close"> 1528 <span class="dashicons post-option-back"></span> 1529 <span class="setting-title" aria-hidden="true"><?php _e( 'Tags' ); ?></span> 1530 <span class="screen-reader-text"><?php _e( 'Back to post options' ) ?></span> 1531 </button> 1532 <?php $this->tags_html( $post ); ?> 1533 </div> 1534 <?php endif; ?> 1497 1535 </div><!-- .options-panel --> 1498 1536 </div><!-- .wrapper -->
Note: See TracChangeset
for help on using the changeset viewer.