Making WordPress.org

Changeset 4213


Ignore:
Timestamp:
10/11/2016 06:42:46 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: Allow non-published plugins to be viewed on the front-end by reviewers and contributors/commiters/submitters of the plugin.

This also adds a notice on the top of plugin pages with the status of the plugin.

See #2111.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
2 edited

Legend:

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

    r4212 r4213  
    531531        }
    532532
     533        // For singular requests, or self-author profile requests allow restricted post_status items to show on the front-end.
     534        if ( is_user_logged_in() && (
     535            !empty( $wp_query->query_vars['name'] ) ||
     536            (
     537                !empty( $wp_query->query_vars['plugin_contributor'] ) &&
     538                (
     539                    current_user_can( 'plugin_review' ) ||
     540                    0 === strcasecmp( $wp_query->query_vars['plugin_contributor'], wp_get_current_user()->user_nicename )
     541                )
     542            ) )
     543        ) {
     544            $wp_query->query_vars['post_status'] = array( 'pending', 'approved', 'publish', 'closed', 'disabled' );
     545
     546            add_filter( 'posts_results', function( $posts, $this_wp_query ) use( $wp_query ) {
     547                if ( $this_wp_query != $wp_query ) {
     548                    return $posts;
     549                }
     550
     551                $restricted_access_statii = array_diff( $wp_query->query_vars['post_status'], array( 'publish' ) );
     552                foreach ( $posts as $i => $post ) {
     553                    // If the plugin is not in the restricted statuses list, show it
     554                    if ( 'plugin' != $post->post_type || ! in_array( $post->post_status, $restricted_access_statii, true ) ) {
     555                        continue;
     556                    }
     557
     558                    // Plugin Reviewers can see all sorts of plugins
     559                    if ( current_user_can( 'plugin_review' ) ) {
     560                        continue;
     561                    }
     562
     563                    // Original submitter can always see
     564                    if ( $post->post_author == get_current_user_id() ) {
     565                        continue;
     566                    }
     567
     568                    // Committers (user_login) can always see
     569                    if ( in_array( wp_get_current_user()->user_login, (array) Tools::get_plugin_committers( $post->post_name ), true ) ) {
     570                        continue;
     571                    }
     572
     573                    // Contributors (user_nicename) can always see
     574                    if ( in_array( wp_get_current_user()->user_nicename, (array) wp_list_pluck( get_the_terms( $post, 'plugin_contributors' ), 'slug' ), true ) ) {
     575                        continue;
     576                    }
     577
     578                    // everyone else can't.
     579                    unset( $posts[ $i ] );
     580                }
     581
     582                return $posts;
     583            }, 10, 2 );
     584        }
     585
     586        // By default, all archives are sorted by active installs
    533587        if ( $wp_query->is_archive() && empty( $wp_query->query_vars['orderby'] ) ) {
    534588            $wp_query->query_vars['orderby']  = 'meta_value_num';
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php

    r4200 r4213  
    2828            <div class="plugin-notice notice notice-warning notice-alt">
    2929                <p><?php _e( 'This plugin <strong>hasn&#146;t been updated in over 2 years</strong>. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.', 'wporg-plugins' ); ?></p>
     30            </div><!-- .plugin-notice -->
     31        <?php endif; ?>
     32        <?php if ( 'publish' != get_post()->post_status ) :
     33                $notice_type = 'notice-error';
     34                switch ( get_post()->post_status ) {
     35                    case 'draft':
     36                    case 'pending':
     37                        $message = __( 'This plugin is requested and not visible to the public yet. Please be patient as your plugin gets reviewed.', 'wporg-plugins' );
     38                        $notice_type = 'notice-info';
     39                        break;
     40
     41                    case 'approved':
     42                        $message = __( 'This plugin is approved and awaiting data upload but not visible to the public yet. Once you make your first commit, the plugin will become public.', 'wporg-plugins' );
     43                        $notice_type = 'notice-info';
     44                        break;
     45
     46                    case 'rejected':
     47                        $message = __( 'This plugin is rejected and is not visible to the public.', 'wporg-plugins' );
     48                        break;
     49
     50                    case 'disabled':
     51                        if ( current_user_can( 'plugin_approve' ) ) {
     52                            $message = __( 'This plugin is disabled (closed, but actively serving updates) and is not visible to the public.', 'wporg-plugins' );
     53                            break;
     54                        }
     55                        // fall through
     56                    default:
     57                    case 'closed':
     58                        $message = __( 'This plugin is closed and is not visible to the public.', 'wporg-plugins' );
     59                        break;
     60                }
     61            ?>
     62            <div class="plugin-notice notice <?php echo esc_attr( $notice_type ); ?> notice-alt">
     63                <p><?php echo $message; ?></p>
    3064            </div><!-- .plugin-notice -->
    3165        <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.