Making WordPress.org

Changeset 5318


Ignore:
Timestamp:
04/11/2017 06:37:04 AM (9 years ago)
Author:
dd32
Message:

Plugin Directory: Introduce the 'new' post_status to replace 'draft', this will allow a better more well-defined statuses for plugins.

See #2716

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
10 edited

Legend:

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

    r5308 r5318  
    131131
    132132                if ( empty( $query->query['post_status'] ) ) {
    133                         $query->query_vars['post_status'] = array( 'publish', 'future', 'draft', 'pending', 'disabled', 'closed', 'rejected', 'approved' );
     133                        $query->query_vars['post_status'] = array( 'publish', 'future', 'new', 'pending', 'disabled', 'closed', 'rejected', 'approved' );
    134134                }
    135135
     
    176176                        'post_type'      => 'plugin',
    177177                        'post__in'       => array_map( 'absint', $_REQUEST['post'] ),
    178                         'post_status'    => array( 'draft', 'pending' ),
     178                        'post_status'    => array( 'new', 'pending' ),
    179179                        'posts_per_page' => count( $_REQUEST['post'] ),
    180180                ) );
     
    238238
    239239                switch ( $post->post_status ) {
    240                         case 'draft':
     240                        case 'new':
    241241                                $message = __( 'This plugin is newly requested and has not yet been reviewed.', 'wporg-plugins' );
    242242                                $type    = 'notice-info';
     
    366366                );
    367367
    368                 if ( 'draft' !== $post->post_status ) {
     368                if ( 'new' !== $post->post_status && 'pending' != $post->post_status ) {
    369369                        add_meta_box(
    370370                                'plugin-committers',
     
    381381
    382382                // Remove slug metabox unless the slug is editable for the current user.
    383                 if ( ! in_array( $post->post_status, array( 'draft', 'pending' ) ) || ! current_user_can( 'plugin_approve', $post ) ) {
     383                if ( ! in_array( $post->post_status, array( 'new', 'pending' ) ) || ! current_user_can( 'plugin_approve', $post ) ) {
    384384                        remove_meta_box( 'slugdiv', 'plugin', 'normal' );
    385385                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php

    r5313 r5318  
    5757
    5858                // ...or it's a white-listed status for plugin reviewers.
    59                 if ( current_user_can( 'plugin_review', $postarr['ID'] ) && in_array( $postarr['post_status'], array( 'draft', 'pending' ) ) ) {
     59                if ( current_user_can( 'plugin_review', $postarr['ID'] ) && in_array( $postarr['post_status'], array( 'new', 'pending' ) ) ) {
    6060                        return $data;
    6161                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php

    r5037 r5318  
    8080                }
    8181
    82                 if ( current_user_can( 'plugin_reject' ) && ( empty( $_REQUEST['post_status'] ) || in_array( $_REQUEST['post_status'], array( 'draft', 'pending' ) ) ) ) {
     82                if ( current_user_can( 'plugin_reject' ) && ( empty( $_REQUEST['post_status'] ) || in_array( $_REQUEST['post_status'], array( 'new', 'pending' ) ) ) ) {
    8383                        $actions['plugin_reject'] = __( 'Reject', 'wporg-plugins' );
    8484                }
     
    407407                        }
    408408
    409                         if ( ! current_user_can( 'plugin_approve' ) && ! in_array( $status_name, array( 'draft', 'pending' ) ) ) {
     409                        if ( ! current_user_can( 'plugin_approve' ) && ! in_array( $status_name, array( 'new', 'pending' ) ) ) {
    410410                                continue;
    411411                        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author-card.php

    r5274 r5318  
    149149
    150150                                        $plugin_slug = $plugin->post_name;
    151                                         if ( in_array( $plugin->post_status, array( 'draft', 'pending' ) ) ) {
     151                                        if ( in_array( $plugin->post_status, array( 'new', 'pending' ) ) ) {
    152152                                                $extra .= ' (requested ' . human_time_diff( strtotime( $last_updated ) ) . ' ago)';
    153153                                                $tooltips[] = 'Requested, remains unapproved.';
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php

    r4212 r5318  
    4141                }
    4242
    43                 $statuses = array( 'draft', 'pending' );
     43                $statuses = array( 'new', 'pending' );
    4444                if ( current_user_can( 'plugin_approve', $post ) ) {
    45                         if ( in_array( $post->post_status, array( 'draft', 'pending', 'rejected', 'approved' ) ) ) {
     45                        if ( in_array( $post->post_status, array( 'new', 'draft', 'pending', 'rejected', 'approved' ) ) ) {
    4646                                $statuses = array_merge( $statuses, array( 'approved', 'rejected' ) );
    4747                        } else {
    48                                 $statuses = array( 'publish', 'disabled', 'closed' );
     48                                $statuses = array( 'publish', 'disabled', 'closed', 'pending' );
    4949                        }
    5050                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php

    r5267 r5318  
    1111                $post = get_post();
    1212
    13                 $zip_url = '';
     13                $zip_files = array();
    1414                foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) {
    15                         $zip_url = wp_get_attachment_url( $zip_file->ID );
    16                         break;
     15                        $zip_files[ $zip_file->post_date ] = wp_get_attachment_url( $zip_file->ID );
    1716                }
    18                 if ( ! $zip_url ) {
    19                         $zip_url = get_post_meta( $post->ID, '_submitted_zip', true );
     17                uksort( $zip_files, function( $a, $b ) {
     18                        return strtotime( $a ) < strtotime( $b );
     19                } );
     20
     21                if ( $zip_url = get_post_meta( $post->ID, '_submitted_zip', true ) ) {
     22                        // Back-compat only.
     23                        $zip_files[ 'User provided URL' ] = $zip_url;
    2024                }
    2125
    22                 if ( $zip_url ) {
     26                foreach ( $zip_files as $zip_date => $zip_url ) {
    2327                        printf( '<p>' . __( '<strong>Zip file:</strong> %s', 'wporg-plugins' ) . '</p>',
    24                                 sprintf( '<a href="%s">%s</a>', esc_url( $zip_url ), esc_html( $zip_url ) )
     28                                sprintf( '%s <a href="%s">%s</a>', esc_html( $zip_date ), esc_url( $zip_url ), esc_html( $zip_url ) )
    2529                        );
    2630                }
    2731
    28                 if ( 'pending' != $post->post_status ) {
     32                if ( 'pending' != $post->post_status && 'new' != $post->post_status ) {
    2933                        echo "<ul>
    3034                                <li><a href='https://plugins.trac.wordpress.org/log/{$post->post_name}/'>" . __( 'Development Log', 'wporg-plugins' ) . "</a></li>
     
    3337                        </ul>';
    3438                }
    35                 if ( $post->post_excerpt && in_array( $post->post_status, array( 'pending', 'approved' ) ) ) {
     39                if ( $post->post_excerpt && in_array( $post->post_status, array( 'new', 'pending', 'approved' ) ) ) {
    3640                        echo '<p>' . strip_tags( $post->post_excerpt ) . '</p>';
    3741                }
     
    4145                       
    4246                        $type   = 'Notice';
    43                         if ( $post->post_status == 'draft' || $post->post_status == 'pending' ) {
     47                        if ( $post->post_status == 'new' || $post->post_status == 'pending' ) {
    4448                                $type = 'Request';
    4549                        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php

    r5312 r5318  
    108108                // # of plugins currently in the queue that are drafts (have not been processed/replied to yet)
    109109                $stats['in_queue_draft'] = $wpdb->get_var(
    110                         "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` = 'draft'"
     110                        "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` = 'new'"
    111111                );
    112112
     
    121121                // # of plugins currently in the queue submitted during the specified time window
    122122                $stats['in_queue_from_time_window'] = $wpdb->get_var( $wpdb->prepare(
    123                         "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` IN ( 'draft','pending' ) AND post_date < %s AND post_date > DATE_SUB( %s, INTERVAL %d DAY )",
     123                        "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` IN ( 'new','pending' ) AND post_date < %s AND post_date > DATE_SUB( %s, INTERVAL %d DAY )",
    124124                        $args['date'],
    125125                        $args['date'],
     
    129129                // # of plugins currently in the queue that are older than "recently"
    130130                $stats['in_queue_old'] = $wpdb->get_var( $wpdb->prepare(
    131                         "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` IN ( 'draft','pending' ) AND post_date < DATE_SUB( %s, INTERVAL %d DAY )",
     131                        "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` IN ( 'new','pending' ) AND post_date < DATE_SUB( %s, INTERVAL %d DAY )",
    132132                        $args['date'],
    133133                        absint( $args['recentdays'] ) + 1
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r5316 r5318  
    284284                ) );
    285285
     286                register_post_status( 'new', array(
     287                        'label'                     => _x( 'Pending Initial Review', 'plugin status', 'wporg-plugins' ),
     288                        'public'                    => false,
     289                        'show_in_admin_status_list' => current_user_can( 'plugin_review' ),
     290                        'label_count'               => _n_noop( 'Pending Initial Review <span class="count">(%s)</span>', 'Pending Initial Review <span class="count">(%s)</span>', 'wporg-plugins' ),
     291                ) );
    286292                register_post_status( 'pending', array(
    287293                        'label'                     => _x( 'Pending', 'plugin status', 'wporg-plugins' ),
     
    793799                if ( $viewing_own_author_archive || ( is_user_logged_in() && !empty( $wp_query->query_vars['name'] ) ) ) {
    794800
    795                         $wp_query->query_vars['post_status'] = array( 'pending', 'approved', 'publish', 'closed', 'disabled' );
     801                        $wp_query->query_vars['post_status'] = array( 'approved', 'publish', 'closed', 'disabled' );
    796802
    797803                        add_filter( 'posts_results', function( $posts, $this_wp_query ) use( $wp_query ) {
     
    11931199                                'post_type'   => 'plugin',
    11941200                                'name'        => $plugin_slug,
    1195                                 'post_status' => array( 'publish', 'pending', 'disabled', 'closed', 'draft', 'approved' ),
     1201                                'post_status' => array( 'publish', 'pending', 'disabled', 'closed', 'new', 'draft', 'approved' ),
    11961202                        ) );
    11971203
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r5264 r5318  
    9797
    9898                // Is there already a plugin by a different author?
    99                 if ( $plugin_post instanceof \WP_Post && $plugin_post->post_author != get_current_user_id() ) {
     99                if ( $plugin_post && $plugin_post->post_author != get_current_user_id() ) {
    100100                        /* translators: %s: plugin slug */
    101101                        return sprintf( __( 'There is already a plugin called %s by a different author. Please change the name of your plugin in the plugin header file and upload it again.', 'wporg-plugins' ),
     102                                '<code>' . $this->plugin_slug . '</code>'
     103                        );
     104                }
     105
     106                // Check the plugin can accept uploads (New submissions, or pending further review).
     107                if ( $plugin_post && ! in_array( $plugin_post->post_status, array( 'new', 'pending' ) ) ) {
     108                        /* translators: %s: plugin slug */
     109                        return sprintf( __( 'There is already a plugin called %s. Please change the name of your plugin in the plugin header file and upload it again.', 'wporg-plugins' ),
    102110                                '<code>' . $this->plugin_slug . '</code>'
    103111                        );
     
    171179                                'post_title'   => $this->plugin['Name'],
    172180                                'post_name'    => $this->plugin_slug,
    173                                 'post_status'  => 'draft',
     181                                'post_status'  => 'new',
    174182                                'post_content' => $content,
    175183                                'post_excerpt' => $this->plugin['Description'],
     
    205213                                        'usage'                    => array(),
    206214                                        '_author_ip'               => preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] ),
     215                                        '_submitted_date'          => time(),
    207216                                ),
    208217                        ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php

    r4817 r5318  
    3232                                        <p>
    3333                                                <?php
    34                                                 printf( _n( 'Currently there is %1$s plugin in the review queue.', 'Currently there are %1$s plugins in the review queue, %2$s of which are awaiting their initial review.', ( $plugins->draft + $plugins->pending ), 'wporg-plugins' ),
    35                                                         '<strong>' . ( $plugins->draft + $plugins->pending ) . '</strong>',
    36                                                         '<strong>' . $plugins->draft . '</strong>'
     34                                                printf( _n( 'Currently there is %1$s plugin in the review queue.', 'Currently there are %1$s plugins in the review queue, %2$s of which are awaiting their initial review.', ( $plugins->new + $plugins->pending ), 'wporg-plugins' ),
     35                                                        '<strong>' . ( $plugins->new + $plugins->pending ) . '</strong>',
     36                                                        '<strong>' . $plugins->new . '</strong>'
    3737                                                );
    3838                                                ?>
    3939                                        </p>
    4040                                </div>
    41                                 <?php
    42                                 if ( '/plugins-wp' === parse_url( home_url(), PHP_URL_PATH ) ) {
    43                                         echo '<div class="notice notice-error notice-alt">
    44                                                 <p>Please submit all new plugin requests through the existing form <a href="https://wordpress.org/plugins/add/">available here</a>, You\'re currently viewing the beta version of the upcoming plugin directory, and this form is only for testing purposes.</p>
    45                                         </div>';
    46                                 }
    47                                 ?>
    4841
    4942                        <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.