Changeset 13021
- Timestamp:
- 12/07/2023 08:16:08 AM (5 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php
r13017 r13021 14 14 'author', 15 15 'reviewer', 16 'zip', 17 'loc', 16 18 'comments', 17 19 ]; … … 35 37 $columns['reviewer'] = __( 'Assigned Reviewer', 'wporg-plugins' ); 36 38 $columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Internal Notes', 'wporg-plugins' ) . '"><span class="screen-reader-text">' . __( 'Internal Notes', 'wporg-plugins' ) . '</span></span>'; 39 $columns['zip'] = 'Latest Zip'; 40 $columns['loc'] = 'Lines of PHP Code'; 37 41 38 42 // We don't want the stats column. … … 49 53 public function filter_sortable_columns( $columns ) { 50 54 $columns[ 'reviewer' ] = [ 'assigned_reviewer_time', 'asc' ]; 55 $columns[ 'zip' ] = [ '_submitted_zip_size', 'asc' ]; 56 $columns[ 'loc' ] = [ '_submitted_zip_loc', 'asc' ]; 51 57 52 58 return $columns; … … 654 660 } 655 661 } 662 663 public function column_zip( $post ) { 664 if ( ! in_array( $post->post_status, [ 'new', 'pending', 'approved' ] ) ) { 665 echo '-'; 666 return; 667 } 668 669 $attachments = get_posts( [ 670 'post_parent' => $post->ID, 671 'post_type' => 'attachment', 672 'post_mime_type' => 'application/zip', 673 'posts_per_page' => 1, 674 'orderby' => 'post_date', 675 'order' => 'DESC', 676 ] )[0]; 677 678 foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) { 679 $zip_size = size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 ); 680 681 $url = wp_get_attachment_url( $zip_file->ID ); 682 $name = basename( $url ); 683 $name = explode( '_', $name, 3 )[2]; 684 685 printf( 686 '<a href="%1$s">%2$s</a><br>%3$s</li>', 687 esc_url( $url ), 688 esc_html( $name ), 689 esc_html( $zip_size ) 690 ); 691 } 692 } 693 694 public function column_loc( $post ) { 695 echo number_format_i18n( $post->_submitted_zip_loc ); 696 } 656 697 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r12794 r13021 414 414 return $attachment->get_error_message(); 415 415 } 416 417 // Store metadata about the uploaded ZIP. 418 // Count lines of PHP code, this is not 100% accurate but it's a good indicator. 419 $lines_of_code = (int) shell_exec( sprintf( "find %s -type f -name '*.php' -exec cat {} + | wc -l", escapeshellarg( $this->plugin_dir ) ) ); 420 421 update_post_meta( $plugin_post->ID, '_submitted_zip_size', filesize( get_attached_file( $attachment->ID ) ) ); 422 update_post_meta( $plugin_post->ID, '_submitted_zip_loc', $lines_of_code ); 416 423 417 424 // Send plugin author an email for peace of mind.
Note: See TracChangeset
for help on using the changeset viewer.