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/metabox/class-support-reps.php

    r5864 r5867  
    55
    66/**
    7  * The Plugin Committers admin metabox.
     7 * The Plugin Support Reps admin metabox.
    88 *
    99 * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
    1010 */
    11 class Committers {
     11class Support_Reps {
    1212
    1313    /**
     
    1818     */
    1919    public static function postbox_classes( $classes ) {
    20         $classes[] = 'committers-meta-box';
     20        $classes[] = 'support-reps-meta-box';
    2121
    2222        return array_filter( $classes );
     
    2424
    2525    /**
    26      * Displays a list of committers for the current plugin.
     26     * Displays a list of support reps for the current plugin.
    2727     */
    2828    public static function display() {
    29         $list = new List_Table\Committers();
     29        $list = new List_Table\Support_Reps();
    3030        $list->prepare_items();
    3131        $list->display();
     
    3333
    3434    /**
    35      * Ajax handler for adding a new committer.
     35     * Ajax handler for adding a new support rep.
    3636     */
    37     public static function add_committer() {
    38         $login    = isset( $_POST['add_committer'] ) ? sanitize_user( $_POST['add_committer'] ) : '';
     37    public static function add_support_rep() {
     38        $login    = isset( $_POST['add_support_rep'] ) ? sanitize_user( $_POST['add_support_rep'] ) : '';
    3939        $post_id  = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
    4040
    41         check_ajax_referer( 'add-committer' );
     41        check_ajax_referer( 'add-support-rep' );
    4242
    43         if ( ! current_user_can( 'plugin_add_committer', $post_id ) || 'publish' !== get_post_status( $post_id ) ) {
     43        if ( ! current_user_can( 'plugin_add_support_rep', $post_id ) || 'publish' !== get_post_status( $post_id ) ) {
    4444            wp_die( -1 );
    4545        }
     
    5050        $post     = get_post( $post_id );
    5151
    52         if ( ! $committer = get_user_by( 'login', $login ) ) {
     52        if ( ! $support_rep = get_user_by( 'login', $login ) ) {
    5353            $response->add( array(
    54                 'what' => 'committer',
     54                'what' => 'support_rep',
    5555                'data' => new \WP_Error( 'error', sprintf( __( 'The user %s does not exist.', 'wporg-plugins' ), '<code>' . $login . '</code>' ) ),
    5656            ) );
     
    5858        }
    5959
    60         $result = Tools::grant_plugin_committer( $post->post_name, $committer );
     60        $result = Tools::add_plugin_support_rep( $post->post_name, $support_rep );
    6161
    6262        if ( ! $result ) {
     
    6464
    6565            $response->add( array(
    66                 'what' => 'committer',
     66                'what' => 'support_rep',
    6767                'data' => new \WP_Error( 'error', $message ),
    6868            ) );
     
    7070        }
    7171
    72         $wp_list_table = new List_Table\Committers();
     72        $wp_list_table = new List_Table\Support_Reps();
    7373
    7474        $response->add( array(
    75             'what'     => 'committer',
    76             'id'       => $committer->ID,
    77             'data'     => $wp_list_table->single_row( $committer ),
     75            'what'     => 'support_rep',
     76            'id'       => $support_rep->ID,
     77            'data'     => $wp_list_table->single_row( $support_rep ),
    7878            'position' => -1,
    7979        ) );
     
    8282
    8383    /**
    84      * Ajax handler for removing a committer.
     84     * Ajax handler for removing a support rep.
    8585     */
    86     public static function remove_committer() {
     86    public static function remove_support_rep() {
    8787        $id      = isset( $_POST['id'] )      ? (int) $_POST['id']      : 0;
    8888        $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
    8989
    90         check_ajax_referer( "remove-committer-$id" );
     90        check_ajax_referer( "remove-support-rep-$id" );
    9191
    92         if ( ! current_user_can( 'plugin_remove_committer', $post_id ) || 'publish' !== get_post_status( $post_id ) ) {
     92        if ( ! current_user_can( 'plugin_remove_support_rep', $post_id ) || 'publish' !== get_post_status( $post_id ) ) {
    9393            wp_die( -1 );
    9494        }
     
    9797        $plugin_slug = get_post( $post_id )->post_name;
    9898
    99         if ( ! $committer = get_user_by( 'id', $id ) ) {
     99        if ( ! $support_rep = get_user_by( 'id', $id ) ) {
    100100            $response->add( array(
    101                 'what' => 'committer',
     101                'what' => 'support_rep',
    102102                'data' => new \WP_Error( 'error', __( 'The specified user does not exist.', 'wporg-plugins' ) ),
    103103            ) );
     
    105105        }
    106106
    107         $result = Tools::revoke_plugin_committer( $plugin_slug, $committer );
     107        $result = Tools::remove_plugin_support_rep( $plugin_slug, $support_rep );
    108108
    109109        wp_die( $result );
Note: See TracChangeset for help on using the changeset viewer.