Making WordPress.org

Changeset 11871


Ignore:
Timestamp:
05/24/2022 11:56:46 PM (22 months ago)
Author:
dd32
Message:

HelpScout: Plugins/Themes widget: Include the post status in the widget view, and sort the items according to their current status.

Props Ipstenu, dd32.
Fixes #6323.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/plugins-themes.php

    r11825 r11871  
    4141
    4242    $counts = $wpdb->get_results( $wpdb->prepare(
    43         "SELECT post_status, COUNT(*) as count, group_concat( ID ) as ids, group_concat( post_title SEPARATOR ', ' ) as titles
     43        "SELECT post_status, COUNT(*) as count, group_concat( ID ORDER BY post_title ) as ids, group_concat( post_title ORDER BY post_title SEPARATOR ', ' ) as titles
    4444        FROM $wpdb->posts
    4545        WHERE post_type = %s AND ( post_author = %s {$or_slugs} )
    46         GROUP BY post_status",
     46        GROUP BY post_status
     47        ORDER BY FIELD( post_status, 'new', 'pending', 'publish', 'disabled', 'delisted', 'closed', 'approved', 'suspended', 'rejected', 'draft' )",
    4748        $post_type,
    4849        $user->ID
     
    7374            $html .= '<ul>';
    7475            foreach ( $ids as $post_id ) {
    75                 $post = get_post( $post_id );
     76                $post        = get_post( $post_id );
     77                $post_status = '';
     78
     79                switch ( $post->post_status ) {
     80                    // Plugins
     81                    case 'rejected':
     82                        $post_status = '(Rejected)';
     83                        break;
     84                    case 'closed':
     85                    case 'disabled':
     86                        $post_status = '(Closed)';
     87                        break;
     88                    case 'pending':
     89                    case 'new':
     90                        $post_status = '(In Review)';
     91                        break;
     92                    case 'approved':
     93                        $post_status = '(Approved)';
     94                        break;
     95
     96                    // Themes
     97                    case 'draft':
     98                        $post_status = '(In Review or Rejected)';
     99                        break;
     100                    case 'suspended':
     101                        $post_status = '(Suspended)';
     102                        break;
     103                    case 'delisted':
     104                        $post_status = '(Delisted)';
     105                        break;
     106                }
     107
    76108                $html .= sprintf(
    77                     '<li><a href="%s">%s</a> <a href="%s">#</a></li>',
     109                    '<li><a href="%s">%s</a> <a href="%s">#</a> %s</li>',
    78110                    /* get_edit_post_link( $post ), // Won't work as post type not registered */
    79111                    esc_url( add_query_arg( [ 'action' => 'edit', 'post' => $post_id ], admin_url( 'post.php' ) ) ),
    80112                    esc_html( $post->post_title ),
    81                     get_permalink( $post )
     113                    get_permalink( $post ),
     114                    esc_html( $post_status )
    82115                );
    83116            }
Note: See TracChangeset for help on using the changeset viewer.