- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-media-list-table.php
r41161 r42343 43 43 $this->modes = array( 44 44 'list' => __( 'List View' ), 45 'grid' => __( 'Grid View' ) 45 'grid' => __( 'Grid View' ), 46 46 ); 47 47 48 parent::__construct( array( 49 'plural' => 'media', 50 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 51 ) ); 52 } 53 54 /** 55 * 48 parent::__construct( 49 array( 50 'plural' => 'media', 51 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 52 ) 53 ); 54 } 55 56 /** 56 57 * @return bool 57 58 */ 58 59 public function ajax_user_can() { 59 return current_user_can('upload_files'); 60 } 61 62 /** 63 * 60 return current_user_can( 'upload_files' ); 61 } 62 63 /** 64 64 * @global WP_Query $wp_query 65 65 * @global array $post_mime_types … … 72 72 list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); 73 73 74 $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; 75 76 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; 77 78 $this->set_pagination_args( array( 79 'total_items' => $wp_query->found_posts, 80 'total_pages' => $wp_query->max_num_pages, 81 'per_page' => $wp_query->query_vars['posts_per_page'], 82 ) ); 74 $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; 75 76 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; 77 78 $this->set_pagination_args( 79 array( 80 'total_items' => $wp_query->found_posts, 81 'total_pages' => $wp_query->max_num_pages, 82 'per_page' => $wp_query->query_vars['posts_per_page'], 83 ) 84 ); 83 85 } 84 86 … … 113 115 ); 114 116 115 $type_links[ $mime_type] = sprintf(117 $type_links[ $mime_type ] = sprintf( 116 118 '<option value="post_mime_type:%s"%s>%s</option>', 117 119 esc_attr( $mime_type ), … … 122 124 $type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . __( 'Unattached' ) . '</option>'; 123 125 124 if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) {126 if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) { 125 127 $type_links['trash'] = sprintf( 126 128 '<option value="trash"%s>%s</option>', … … 133 135 134 136 /** 135 *136 137 * @return array 137 138 */ … … 141 142 if ( $this->is_trash ) { 142 143 $actions['untrash'] = __( 'Restore' ); 143 $actions['delete'] = __( 'Delete Permanently' );144 $actions['delete'] = __( 'Delete Permanently' ); 144 145 } else { 145 146 $actions['trash'] = _x( 'Trash', 'verb' ); … … 149 150 } 150 151 151 if ( $this->detached ) 152 if ( $this->detached ) { 152 153 $actions['attach'] = __( 'Attach' ); 154 } 153 155 154 156 return $actions; … … 165 167 <div class="actions"> 166 168 <?php 167 if ( ! is_singular() ) { 168 if ( ! $this->is_trash ) { 169 $this->months_dropdown( 'attachment' ); 170 } 171 172 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ 173 do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); 174 175 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); 176 } 177 178 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { 179 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); 180 } ?> 169 if ( ! is_singular() ) { 170 if ( ! $this->is_trash ) { 171 $this->months_dropdown( 'attachment' ); 172 } 173 174 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ 175 do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); 176 177 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); 178 } 179 180 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { 181 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); 182 } 183 ?> 181 184 </div> 182 185 <?php … … 184 187 185 188 /** 186 *187 189 * @return string 188 190 */ 189 191 public function current_action() { 190 if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) 192 if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) { 191 193 return 'attach'; 192 193 if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) 194 } 195 196 if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) { 194 197 return 'detach'; 195 196 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) 198 } 199 200 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { 197 201 return 'delete_all'; 202 } 198 203 199 204 return parent::current_action(); … … 201 206 202 207 /** 203 *204 208 * @return bool 205 209 */ … … 248 252 249 253 // Back compat for pre-4.0 view links. 250 if ( ! empty( $views ) ) {251 echo '<ul class="filter-links">';252 foreach ( $views as $class => $view ) {253 echo "<li class='$class'>$view</li>";254 }255 echo '</ul>';256 }254 if ( ! empty( $views ) ) { 255 echo '<ul class="filter-links">'; 256 foreach ( $views as $class => $view ) { 257 echo "<li class='$class'>$view</li>"; 258 } 259 echo '</ul>'; 260 } 257 261 ?> 258 262 </div> … … 260 264 <div class="search-form"> 261 265 <label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label> 262 <input type="search" placeholder="<?php esc_attr_e( 'Search media items...' ) ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div>266 <input type="search" placeholder="<?php esc_attr_e( 'Search media items...' ); ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div> 263 267 </div> 264 268 <?php … … 266 270 267 271 /** 268 *269 272 * @return array 270 273 */ 271 274 public function get_columns() { 272 $posts_columns = array();275 $posts_columns = array(); 273 276 $posts_columns['cb'] = '<input type="checkbox" />'; 274 277 /* translators: column name */ 275 $posts_columns['title'] = _x( 'File', 'column name' );278 $posts_columns['title'] = _x( 'File', 'column name' ); 276 279 $posts_columns['author'] = __( 'Author' ); 277 280 … … 302 305 303 306 /* translators: column name */ 304 if ( ! $this->detached ) {307 if ( ! $this->detached ) { 305 308 $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); 306 if ( post_type_supports( 'attachment', 'comments' ) ) 309 if ( post_type_supports( 'attachment', 'comments' ) ) { 307 310 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; 311 } 308 312 } 309 313 /* translators: column name */ … … 322 326 323 327 /** 324 *325 328 * @return array 326 329 */ … … 343 346 */ 344 347 public function column_cb( $post ) { 345 if ( current_user_can( 'edit_post', $post->ID ) ) { ?> 346 <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"><?php 347 echo sprintf( __( 'Select %s' ), _draft_or_post_title() ); 348 ?></label> 348 if ( current_user_can( 'edit_post', $post->ID ) ) { 349 ?> 350 <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"> 351 <?php 352 echo sprintf( __( 'Select %s' ), _draft_or_post_title() ); 353 ?> 354 </label> 349 355 <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" /> 350 <?php } 356 <?php 357 } 351 358 } 352 359 … … 361 368 list( $mime ) = explode( '/', $post->post_mime_type ); 362 369 363 $title = _draft_or_post_title();364 $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );370 $title = _draft_or_post_title(); 371 $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); 365 372 $link_start = $link_end = ''; 366 373 … … 380 387 <?php 381 388 echo $link_start; 382 if ( $thumb ) : ?> 389 if ( $thumb ) : 390 ?> 383 391 <span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span> 384 <?php endif; 392 <?php 393 endif; 385 394 echo $title . $link_end; 386 395 _media_states( $post ); … … 405 414 */ 406 415 public function column_author( $post ) { 407 printf( '<a href="%s">%s</a>', 408 esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ), 416 printf( 417 '<a href="%s">%s</a>', 418 esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ), 409 419 get_the_author() 410 420 ); … … 434 444 } else { 435 445 $m_time = $post->post_date; 436 $time = get_post_time( 'G', true, $post, false );446 $time = get_post_time( 'G', true, $post, false ); 437 447 if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) { 438 448 if ( $t_diff < 0 ) { … … 466 476 467 477 if ( $parent ) { 468 $title = _draft_or_post_title( $post->post_parent );478 $title = _draft_or_post_title( $post->post_parent ); 469 479 $parent_type = get_post_type_object( $parent->post_type ); 470 480 … … 472 482 ?> 473 483 <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"> 474 <?php echo $title ?></a></strong><?php 484 <?php echo $title; ?></a></strong> 485 <?php 475 486 } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { 476 487 ?> 477 <strong><?php echo $title ?></strong><?php 488 <strong><?php echo $title; ?></strong> 489 <?php 478 490 } else { 479 491 _e( '(Private post)' ); 480 492 } 481 493 482 if ( $user_can_edit ): 483 $detach_url = add_query_arg( array( 484 'parent_post_id' => $post->post_parent, 485 'media[]' => $post->ID, 486 '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ) 487 ), 'upload.php' ); 494 if ( $user_can_edit ) : 495 $detach_url = add_query_arg( 496 array( 497 'parent_post_id' => $post->post_parent, 498 'media[]' => $post->ID, 499 '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ), 500 ), 'upload.php' 501 ); 488 502 printf( 489 503 '<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>', … … 495 509 endif; 496 510 } else { 497 _e( '(Unattached)' ); ?> 498 <?php if ( $user_can_edit ) { 511 _e( '(Unattached)' ); 512 ?> 513 <?php 514 if ( $user_can_edit ) { 499 515 $title = _draft_or_post_title( $post->post_parent ); 500 516 printf( … … 554 570 $out = array(); 555 571 foreach ( $terms as $t ) { 556 $posts_in_term_qv = array();572 $posts_in_term_qv = array(); 557 573 $posts_in_term_qv['taxonomy'] = $taxonomy; 558 $posts_in_term_qv['term'] = $t->slug; 559 560 $out[] = sprintf( '<a href="%s">%s</a>', 574 $posts_in_term_qv['term'] = $t->slug; 575 576 $out[] = sprintf( 577 '<a href="%s">%s</a>', 561 578 esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), 562 579 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) … … 586 603 587 604 /** 588 *589 605 * @global WP_Post $post 590 606 */ … … 597 613 $this->comment_pending_count = get_pending_comments_num( $post_ids ); 598 614 599 add_filter( 'the_title','esc_html' ); 600 601 while ( have_posts() ) : the_post(); 615 add_filter( 'the_title', 'esc_html' ); 616 617 while ( have_posts() ) : 618 the_post(); 602 619 if ( 603 620 ( $this->is_trash && $post->post_status != 'trash' ) … … 655 672 ); 656 673 } else { 657 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';674 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; 658 675 $actions['delete'] = sprintf( 659 676 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', … … 683 700 ); 684 701 } 685 } 686 else { 687 if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) { 702 } else { 703 if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { 688 704 $actions['edit'] = sprintf( 689 705 '<a href="%s" aria-label="%s">%s</a>', … … 713 729 } 714 730 if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { 715 $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';731 $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; 716 732 $actions['delete'] = sprintf( 717 733 '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>',
Note: See TracChangeset
for help on using the changeset viewer.