Making WordPress.org


Ignore:
Timestamp:
09/03/2017 09:43:53 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Plugin Directory: Introduce UI for managing plugin support reps.

Support representatives can mark forum topics as resolved or sticky (same as plugin authors and contributors), but don't have commit access to the plugin.

See #3029, #2699.

File:
1 copied

Legend:

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

    r5864 r5867  
    55
    66/**
    7  * A Widget to display committer information about a plugin.
     7 * A Widget to display support rep information about a plugin.
    88 *
    99 * @package WordPressdotorg\Plugin_Directory\Widgets
    1010 */
    11 class Committers extends \WP_Widget {
     11class Support_Reps extends \WP_Widget {
    1212    /**
    13      * Committers constructor.
     13     * Support Reps constructor.
    1414     */
    1515    public function __construct() {
    16         parent::__construct( 'plugin_committers', __( 'Plugin Committers', 'wporg-plugins' ), array(
    17             'classname'   => 'plugin-committers',
    18             'description' => __( 'Displays committer information.', 'wporg-plugins' ),
     16        parent::__construct( 'plugin_support_reps', __( 'Plugin Support Reps', 'wporg-plugins' ), array(
     17            'classname'   => 'plugin-support-reps',
     18            'description' => __( 'Displays support rep information.', 'wporg-plugins' ),
    1919        ) );
    2020    }
     
    2929        $post = get_post();
    3030
    31         $committers = Tools::get_plugin_committers( $post->post_name );
    32         $committers = array_map( function ( $user_login ) {
    33             return get_user_by( 'login', $user_login );
    34         }, $committers );
     31        $support_reps = Tools::get_plugin_support_reps( $post->post_name );
     32        $support_reps = array_map( function ( $user_login ) {
     33            return get_user_by( 'slug', $user_login );
     34        }, $support_reps );
    3535
    36         if ( current_user_can( 'plugin_add_committer', $post ) || current_user_can( 'plugin_remove_committer', $post ) ) {
    37             wp_enqueue_script( 'wporg-plugins-committers', plugins_url( 'js/committers.js', __FILE__ ), array( 'wp-util' ), true );
    38             wp_localize_script( 'wporg-plugins-committers', 'committersWidget', array(
    39                 'restUrl'            => get_rest_url(),
    40                 'restNonce'          => wp_create_nonce( 'wp_rest' ),
    41                 'pluginSlug'         => $post->post_name,
    42                 'removeCommitterAYS' => __( 'Are you sure you want to remove this committer?', 'wporg-plugins' ),
     36        if ( current_user_can( 'plugin_add_support_rep', $post ) || current_user_can( 'plugin_remove_support_rep', $post ) ) {
     37            wp_enqueue_script( 'wporg-plugins-support-reps', plugins_url( 'js/support-reps.js', __FILE__ ), array( 'wp-util' ), true );
     38            wp_localize_script( 'wporg-plugins-support-reps', 'supportRepsWidget', array(
     39                'restUrl'             => get_rest_url(),
     40                'restNonce'           => wp_create_nonce( 'wp_rest' ),
     41                'pluginSlug'          => $post->post_name,
     42                'removeSupportRepAYS' => __( 'Are you sure you want to remove this support rep?', 'wporg-plugins' ),
    4343            ) );
    4444        }
    4545
    46         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Committers', 'wporg-plugins' ) : $instance['title'], $instance, $this->id_base );
     46        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Support Reps', 'wporg-plugins' ) : $instance['title'], $instance, $this->id_base );
    4747
    4848        echo $args['before_widget'];
     
    5050        ?>
    5151
    52         <ul id="committer-list" class="committer-list">
     52        <ul id="support-rep-list" class="support-rep-list">
    5353
    54             <?php foreach ( $committers as $committer ) : ?>
    55                 <li data-user="<?php echo esc_attr( $committer->user_nicename ); ?>">
    56                     <?php echo get_avatar( $committer->ID, 32 ); ?>
    57                     <a href="<?php echo esc_url( 'https://profiles.wordpress.org/' . $committer->user_nicename ); ?>">
    58                         <?php echo Template::encode( $committer->display_name ); ?>
     54            <?php foreach ( $support_reps as $support_rep ) : ?>
     55                <li data-user="<?php echo esc_attr( $support_rep->user_nicename ); ?>">
     56                    <?php echo get_avatar( $support_rep->ID, 32 ); ?>
     57                    <a href="<?php echo esc_url( 'https://profiles.wordpress.org/' . $support_rep->user_nicename ); ?>">
     58                        <?php echo Template::encode( $support_rep->display_name ); ?>
    5959                    </a><br>
    6060
    61                     <?php if ( current_user_can( 'plugin_remove_committer', $post ) ) : ?>
     61                    <?php if ( current_user_can( 'plugin_remove_support_rep', $post ) ) : ?>
    6262                    <small>
    63                         <?php echo current_user_can( 'plugin_review' ) ? esc_html( $committer->user_email ) . ' ' : ''; ?>
     63                        <?php echo current_user_can( 'plugin_review' ) ? esc_html( $support_rep->user_email ) . ' ' : ''; ?>
    6464                        <button class="button-link remove"><?php _e( 'Remove', 'wporg-plugins' ); ?></button>
    6565                    </small>
     
    6868            <?php endforeach; ?>
    6969
    70             <?php if ( current_user_can( 'plugin_add_committer', $post ) ) : ?>
     70            <?php if ( current_user_can( 'plugin_add_support_rep', $post ) ) : ?>
    7171            <li class="new">
    72                 <form id="add-committer" action="POST">
    73                     <input type="text" name="committer" placeholder="<?php esc_attr_e( 'Login, Slug, or Email.', 'wporg-plugins' ); ?>">
     72                <form id="add-support-rep" action="POST">
     73                    <input type="text" name="support_rep" placeholder="<?php esc_attr_e( 'Login, Slug, or Email.', 'wporg-plugins' ); ?>">
    7474                    <button type="submit" class="button button-secondary"><?php esc_attr_e( 'Add', 'wporg-plugins' ); ?></button>
    7575                </form>
    7676
    77                 <script id="tmpl-new-committer" type="text/template">
     77                <script id="tmpl-new-support-rep" type="text/template">
    7878                    <li data-user="{{ data.nicename }}">
    7979                        <a class="profile" href="{{ data.profile }}">
Note: See TracChangeset for help on using the changeset viewer.