Changeset 13650
- Timestamp:
- 05/02/2024 07:05:00 AM (7 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-helpscout.php
r13202 r13650 15 15 class HelpScout { 16 16 public static function display() { 17 global $wpdb;18 17 $post = get_post(); 19 18 20 // Trim off the rejected prefix/suffix.21 $slug = preg_replace( '/(^rejected-|-rejected(-\d)?$)/i', '', $post->post_name );22 23 19 // If the slug is not set, we can't query HelpScout. 24 if ( ! $post->post_name || ! $slug) {20 if ( ! $post->post_name ) { 25 21 echo 'Invalid Slug, cannot query emails.'; 26 22 return; 27 23 } 28 24 29 $emails = $wpdb->get_results( $wpdb->prepare( 30 "SELECT emails.* 31 FROM %i emails 32 JOIN %i meta ON emails.id = meta.helpscout_id 33 WHERE meta.meta_key = 'plugins' AND meta.meta_value IN( %s, %s ) 34 ORDER BY `created` DESC", 35 "{$wpdb->base_prefix}helpscout", 36 "{$wpdb->base_prefix}helpscout_meta", 37 $slug, 38 $post->post_name 39 ) ); 25 $emails = Tools::get_helpscout_emails( $post ); 40 26 41 27 echo '<table class="widefat striped helpscout-emails">'; … … 65 51 sprintf( 66 52 '<a href="%s" title="%s">%s</a>', 67 esc_url( 'https://secure.helpscout.net/conversation/' . $email->id . '/' . $email->number),53 esc_url( $email->url ), 68 54 esc_attr( $email->preview ), 69 55 esc_html( $subject ) -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-review.php
r13649 r13650 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 use WordPressdotorg\Plugin_Directory\Shortcodes\Upload_Handler;4 3 use WordPressdotorg\Plugin_Directory\API\Base; 5 4 use WordPressdotorg\Plugin_Directory\Template; 5 use WordPressdotorg\Plugin_Directory\Tools; 6 6 use WP_Error; 7 7 use WP_REST_Server; … … 91 91 'post_status' => $post->post_status, 92 92 'edit_url' => add_query_arg( [ 'action' => 'edit', 'post' => $post->ID ], admin_url( 'post.php' ) ), 93 'helpscout' => null, // Link to Review email (or most recent open email)93 'helpscout' => null, // Most recent email details. 94 94 'submitter' => [ 95 95 'user_login' => $submitter->user_login, … … 106 106 $details['download_link'] = null; 107 107 $details['preview_link'] = null; 108 $details['helpscout'] = Tools::get_helpscout_emails( $post, [ 'subject' => 'Review in Progress:', 'limit' => 1 ] ); 109 } else { 110 $details['helpscout'] = Tools::get_helpscout_emails( $post, [ 'limit' => 1 ] ); 108 111 } 109 112 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
r13577 r13650 678 678 return 200 === wp_remote_retrieve_response_code( $request ); 679 679 } 680 681 /** 682 * Fetch the list of known Helpscout emails for a given post. 683 * 684 * @param \WP_Post $post The post to fetch emails for. 685 * @return array 686 */ 687 public static function get_helpscout_emails( $post, $filters = [] ) { 688 global $wpdb; 689 690 $limit = 999; 691 if ( isset( $filters['limit'] ) ) { 692 $limit = absint( $filters['limit'] ); 693 unset( $filters['limit'] ); 694 } 695 696 // Trim off the rejected prefix/suffix. 697 $slug = preg_replace( '/(^rejected-|-rejected(-\d)?$)/i', '', $post->post_name ); 698 $wheres = ''; 699 700 foreach ( $filters as $key => $value ) { 701 $wheres .= $wpdb->prepare( 'AND emails.%i LIKE %s ', $key, '%' . $value . '%' ); 702 } 703 704 $emails = $wpdb->get_results( $wpdb->prepare( 705 "SELECT emails.* 706 FROM %i emails 707 JOIN %i meta ON emails.id = meta.helpscout_id 708 WHERE meta.meta_key = 'plugins' AND meta.meta_value IN( %s, %s ) 709 $wheres 710 ORDER BY `created` DESC 711 LIMIT %d", 712 "{$wpdb->base_prefix}helpscout", 713 "{$wpdb->base_prefix}helpscout_meta", 714 $slug, 715 $post->post_name, 716 $limit 717 ) ); 718 719 foreach ( $emails as &$email ) { 720 $email->url = 'https://secure.helpscout.net/conversation/' . $email->id . '/' . $email->number; 721 } 722 723 if ( 1 === $limit ) { 724 return reset( $emails ); 725 } 726 727 return $emails; 728 } 680 729 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r13649 r13650 738 738 */ 739 739 public static function find_review_email( $post ) { 740 global $wpdb;741 742 740 if ( ! in_array( $post->post_status, [ 'new', 'pending' ] ) || ! $post->post_name ) { 743 741 return false; 744 742 } 745 743 746 // Find the latest email for this plugin that looks like a review email. 747 return $wpdb->get_row( $wpdb->prepare( 748 "SELECT emails.* 749 FROM %i emails 750 JOIN %i meta ON emails.id = meta.helpscout_id 751 WHERE meta.meta_key = 'plugins' AND meta.meta_value = %s 752 AND emails.subject LIKE %s 753 ORDER BY `created` DESC 754 LIMIT 1", 755 "{$wpdb->base_prefix}helpscout", 756 "{$wpdb->base_prefix}helpscout_meta", 757 $post->post_name, 758 '%Review in Progress:%' // The subject line of the review email. 759 ) ); 744 return Tools::get_helpscout_emails( $post, [ 'subject' => 'Review in Progress:', 'limit' => 1 ] ); 760 745 } 761 746
Note: See TracChangeset
for help on using the changeset viewer.