Changeset 13034
- Timestamp:
- 12/08/2023 04:07:07 AM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php
r13033 r13034 27 27 add_filter( "manage_{$this->screen->post_type}_posts_columns", [ $this, 'filter_columns' ], 100 ); 28 28 add_filter( "manage_{$this->screen->id}_sortable_columns", [ $this, 'filter_sortable_columns' ], 100 ); 29 add_filter( 'hidden_columns', [ $this, 'filter_hidden_columns' ], 100, 3 ); 29 30 } 30 31 … … 55 56 $columns[ 'zip' ] = [ '_submitted_zip_size', 'asc' ]; 56 57 $columns[ 'loc' ] = [ '_submitted_zip_loc', 'asc' ]; 58 59 return $columns; 60 } 61 62 /** 63 * Hide some fields by default. 64 */ 65 public function filter_hidden_columns( $columns, $screen, $use_defaults ) { 66 if ( $screen->id !== $this->screen->id ) { 67 return $columns; 68 } 69 70 // Hide certain columns on default / published views. 71 if ( 72 in_array( $_REQUEST['post_status'] ?? 'all', [ 'all', 'publish', 'disabled', 'closed' ] ) && 73 empty( $_REQUEST['author'] ) && 74 empty( $_REQUEST['reviewer'] ) 75 ) { 76 $columns[] = 'reviewer'; 77 $columns[] = 'zip'; 78 $columns[] = 'loc'; 79 } 57 80 58 81 return $columns; … … 668 691 ) 669 692 ); 693 } else { 694 echo '-'; 670 695 } 671 696 } 672 697 673 698 public function column_zip( $post ) { 674 if ( ! in_array( $post->post_status, [ 'new', 'pending', 'approved' ] ) ) { 699 $media = get_attached_media( 'application/zip', $post ); 700 701 if ( ! $media || ! in_array( $post->post_status, [ 'new', 'pending', 'approved' ] ) ) { 675 702 echo '-'; 676 703 return; 677 704 } 678 705 679 foreach ( get_attached_media( 'application/zip', $post )as $zip_file ) {706 foreach ( $media as $zip_file ) { 680 707 $zip_size = size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 ); 681 708 … … 694 721 695 722 public function column_loc( $post ) { 696 echo number_format_i18n( $post->_submitted_zip_loc ); 723 if ( ! in_array( $post->post_status, [ 'new', 'pending', 'approved' ] ) ) { 724 echo '-'; 725 return; 726 } 727 728 echo number_format_i18n( (int) $post->_submitted_zip_loc ) ?: '-'; 697 729 } 698 730 }
Note: See TracChangeset
for help on using the changeset viewer.