Changeset 13650 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
- Timestamp:
- 05/02/2024 07:05:00 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.