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/admin/list-table/class-support-reps.php

    r5864 r5867  
    1010 * @package WordPressdotorg\Plugin_Directory\Admin\List_Table
    1111 */
    12 class Committers extends \WP_List_Table {
     12class Support_Reps extends \WP_List_Table {
    1313
    1414    /**
     
    2121    public function __construct( $args = array() ) {
    2222        parent::__construct( array(
    23             'singular' => 'committer',
    24             'plural'   => 'committers',
    25             'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
     23            'singular' => 'support_rep',
     24            'plural'   => 'support_reps',
     25            'screen'   => isset( $args['screen'] ) ? $args['screen'] : 'plugin',
    2626        ) );
    2727    }
     
    3333     */
    3434    public function ajax_user_can() {
    35         return current_user_can( 'plugin_remove_committer' );
     35        return current_user_can( 'plugin_remove_support_rep' );
    3636    }
    3737
     
    4949            return;
    5050        }
    51         $existing_committers = Tools::get_plugin_committers( $plugin_slug );
    52         $this->items         = array_map( function ( $user ) {
     51        $existing_support_reps = Tools::get_plugin_support_reps( $plugin_slug );
     52        $this->items           = array_map( function ( $user ) {
    5353            return new \WP_User( $user );
    54         }, $existing_committers );
     54        }, $existing_support_reps );
    5555    }
    5656
     
    6161     */
    6262    public function no_items() {
    63         _e( 'No committers found.', 'wporg-plugins' );
     63        _e( 'No support reps found.', 'wporg-plugins' );
    6464    }
    6565
     
    102102                <col />
    103103            </colgroup>
    104             <tbody id="the-committer-list" data-wp-lists="list:committer">
     104            <tbody id="the-support-rep-list" data-wp-lists="list:support-rep">
    105105                <?php $this->display_rows_or_placeholder(); ?>
    106106            </tbody>
     
    119119        }
    120120        ?>
    121         <tr id="add-committer" class="add-committer wp-hidden-children">
     121        <tr id="add-support-rep" class="add-support-rep wp-hidden-children">
    122122            <td colspan="2">
    123                 <button type="button" id="add-committer-toggle" class="button-link"><?php _e( '+ Add New Committer', 'wporg-plugins' ); ?></button>
     123                <button type="button" id="add-support-rep-toggle" class="button-link"><?php _e( '+ Add New Support Rep', 'wporg-plugins' ); ?></button>
    124124                <p class="wp-hidden-child">
    125                     <?php wp_nonce_field( 'add-committer', '_ajax_nonce', false ); ?>
    126                     <span id="committer-error" class="notice notice-alt notice-error" style="display:none;"></span>
     125                    <?php wp_nonce_field( 'add-support-rep', '_ajax_nonce', false ); ?>
     126                    <span id="support-rep-error" class="notice notice-alt notice-error" style="display:none;"></span>
    127127                    <label>
    128                         <input type="text" name="add_committer" class="form-required" value="" aria-required="true" placeholder="<?php esc_attr_e( 'WordPress.org username', 'wporg-plugins' ); ?>">
    129                         <span class="screen-reader-text"><?php _e( 'Add a new committer', 'wporg-plugins' ); ?></span>
     128                        <input type="text" name="add_support_rep" class="form-required" value="" aria-required="true" placeholder="<?php esc_attr_e( 'WordPress.org username', 'wporg-plugins' ); ?>">
     129                        <span class="screen-reader-text"><?php _e( 'Add a new support rep', 'wporg-plugins' ); ?></span>
    130130                    </label>
    131                     <input type="button" id="add-committer-submit" class="button" data-wp-lists="add:the-committer-list:add-committer::post_id=<?php echo get_post()->ID; ?>" value="<?php _e( 'Add Committer', 'wporg-plugins' ); ?>">
     131                    <input type="button" id="add-support-rep-submit" class="button" data-wp-lists="add:the-support-rep-list:add-support-rep::post_id=<?php echo get_post()->ID; ?>" value="<?php _e( 'Add Support Rep', 'wporg-plugins' ); ?>">
    132132                </p>
    133133            </td>
     
    151151        list( $columns, $hidden, $primary ) = $this->get_column_info();
    152152
    153         // Set up the hover actions for this committer.
     153        // Set up the hover actions for this support rep.
    154154        $actions = array();
    155155
    156         // Check if the committer for this row is removable.
     156        // Check if the support rep for this row is removable.
    157157        $post_id = get_post()->ID;
    158         if ( current_user_can( 'plugin_remove_committer', $post_id ) && $user_object->ID != get_current_user_id() ) {
    159             $actions['delete'] = "<a class='submitremove' data-wp-lists='delete:the-committer-list:committer-{$user_object->ID}:faafaa:post_id={$post_id}' href='" . wp_nonce_url( 'users.php?action=remove&amp;committer=' . $user_object->ID, "remove-committer-{$user_object->ID}" ) . "'>" . __( 'Remove', 'wporg-plugins' ) . "</a>";
     158        if ( current_user_can( 'plugin_remove_support_rep', $post_id ) && $user_object->ID != get_current_user_id() ) {
     159            $actions['delete'] = "<a class='submitremove' data-wp-lists='delete:the-support-rep-list:support-rep-{$user_object->ID}:faafaa:post_id={$post_id}' href='" . wp_nonce_url( 'users.php?action=remove&amp;support-rep=' . $user_object->ID, "remove-support-rep-{$user_object->ID}" ) . "'>" . __( 'Remove', 'wporg-plugins' ) . "</a>";
    160160        }
    161161
    162162        /**
    163          * Filter the action links displayed under each committer in the Committers list table.
     163         * Filter the action links displayed under each support rep in the Support Reps list table.
    164164         *
    165165         * @param array    $actions     An array of action links to be displayed.
    166          * @param \WP_User $user_object WP_User object for the currently-listed committer.
     166         * @param \WP_User $user_object WP_User object for the currently-listed support rep.
    167167         */
    168         $actions = apply_filters( 'committer_row_actions', $actions, $user_object );
    169 
    170         $row = "<tr id='committer-$user_object->ID'>";
     168        $actions = apply_filters( 'support_rep_row_actions', $actions, $user_object );
     169
     170        $row = "<tr id='support-rep-$user_object->ID'>";
    171171
    172172        foreach ( $columns as $column_name => $column_display_name ) {
     
    203203                     * @param int    $user_id     ID of the currently-listed user.
    204204                     */
    205                     $row .= apply_filters( 'manage_committers_custom_column', '', $column_name, $user_object->ID );
     205                    $row .= apply_filters( 'manage_support_reps_custom_column', '', $column_name, $user_object->ID );
    206206            }
    207207            if ( $primary === $column_name ) {
Note: See TracChangeset for help on using the changeset viewer.