Changeset 13575 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
- Timestamp:
- 04/19/2024 02:56:22 AM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r13574 r13575 79 79 80 80 $zip_file = $_FILES['zip_file']['tmp_name']; 81 $upload_comment = trim( wp_unslash( $_POST['comment'] ) ); 81 82 $has_upload_token = $this->has_valid_upload_token(); 82 83 $this->plugin_dir = Filesystem::unzip( $zip_file ); … … 492 493 } 493 494 494 $attachment = $this->save_zip_file( $plugin_post->ID );495 $attachment = $this->save_zip_file( $plugin_post->ID, $upload_comment ); 495 496 if ( is_wp_error( $attachment ) ) { 496 497 return $attachment; 498 } 499 500 // Store the uploaded comment as a plugin audit log. 501 if ( $upload_comment ) { 502 Tools::audit_log( 503 sprintf( 504 "Upload Comment for <a href='%s'>%s</a>\n%s", 505 wp_get_attachment_url( $attachment->ID ), 506 esc_html( $attachment->submitted_name ), 507 esc_html( $upload_comment ) 508 ), 509 $plugin_post->ID, 510 ); 497 511 } 498 512 … … 655 669 * @return WP_Post|WP_Error Attachment post or upload error. 656 670 */ 657 public function save_zip_file( $post_id ) {671 public function save_zip_file( $post_id, $upload_comment ) { 658 672 $zip_hash = sha1_file( $_FILES['zip_file']['tmp_name'] ); 659 673 if ( in_array( $zip_hash, get_post_meta( $post_id, 'uploaded_zip_hash' ) ?: [], true ) ) { … … 669 683 670 684 // Store the plugin details against the media as well. 671 $post_details 685 $post_details = array( 672 686 'post_title' => sprintf( '%s Version %s', $this->plugin['Name'], $this->plugin['Version'] ), 673 687 'post_excerpt' => $this->plugin['Description'], 688 'post_content' => esc_html( $upload_comment ) 674 689 ); 675 690 $attachment = media_handle_upload( 'zip_file', $post_id, $post_details ); … … 765 780 766 781 $text = sprintf( 767 "New ZIP uploaded by %s, version %s.\n %s\n%s",782 "New ZIP uploaded by %s, version %s.\nComment: %s\n%s", 768 783 wp_get_current_user()->user_login, 769 784 $attachment->version, 770 get_edit_post_link( $post ),785 $attachment->post_content, 771 786 wp_get_attachment_url( $attachment->ID ) 772 787 );
Note: See TracChangeset
for help on using the changeset viewer.