Making WordPress.org


Ignore:
Timestamp:
05/02/2024 07:05:00 AM (12 months ago)
Author:
dd32
Message:

Plugin Directory: Centralise the Helpscout email table query code.

See #7385.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-helpscout.php

    r13202 r13650  
    1515class HelpScout {
    1616    public static function display() {
    17         global $wpdb;
    1817        $post = get_post();
    1918
    20         // Trim off the rejected prefix/suffix.
    21         $slug   = preg_replace( '/(^rejected-|-rejected(-\d)?$)/i', '', $post->post_name );
    22 
    2319        // If the slug is not set, we can't query HelpScout.
    24         if ( ! $post->post_name || ! $slug ) {
     20        if ( ! $post->post_name ) {
    2521            echo 'Invalid Slug, cannot query emails.';
    2622            return;
    2723        }
    2824
    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 );
    4026
    4127        echo '<table class="widefat striped helpscout-emails">';
     
    6551                sprintf(
    6652                    '<a href="%s" title="%s">%s</a>',
    67                     esc_url( 'https://secure.helpscout.net/conversation/' . $email->id . '/' . $email->number ),
     53                    esc_url( $email->url ),
    6854                    esc_attr( $email->preview ),
    6955                    esc_html( $subject )
Note: See TracChangeset for help on using the changeset viewer.