Making WordPress.org

Changeset 2737


Ignore:
Timestamp:
03/11/2016 06:59:07 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Limit comment row actions for internal notes.

Plugin Reviewers should only need to be able to reply to notes, Plugin Admins
probably don't need more than quickedit, trash, and untrash.

See #1603.

File:
1 edited

Legend:

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

    r2736 r2737  
    3333
    3434        add_filter( 'postbox_classes_plugin_internal-notes', array( $this, 'postbox_classes' ) );
     35        add_filter( 'comment_row_actions', array( $this, 'custom_comment_row_actions' ), 10, 2 );
    3536    }
    3637
     
    105106        );
    106107
    107         // Replace the publish box
     108        // Replace the publish box.
    108109        add_meta_box(
    109110            'submitdiv',
     
    144145
    145146        return array_filter( $classes );
     147    }
     148
     149    /**
     150     * Filter the action links displayed for each comment.
     151     *
     152     * Actions for internal notes can be limited to replying for plugin reviewers.
     153     * Plugin Admins can additionally trash, untrash, and quickedit a note.
     154     *
     155     * @param array       $actions An array of comment actions. Default actions include:
     156     *                             'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
     157     *                             'Delete', and 'Trash'.
     158     * @param \WP_Comment $comment The comment object.
     159     * @return array Array of comment actions.
     160     */
     161    public function custom_comment_row_actions( $actions, $comment ) {
     162        if ( 'internal-note' === $comment->comment_type ) {
     163            $allowed_actions = array( 'reply' => true );
     164
     165            if ( current_user_can( 'manage_comments' ) ) {
     166                $allowed_actions['trash']     = true;
     167                $allowed_actions['untrash']   = true;
     168                $allowed_actions['quickedit'] = true;
     169            }
     170
     171            $actions = array_intersect_key( $actions, $allowed_actions );
     172        }
     173
     174        return $actions;
    146175    }
    147176
Note: See TracChangeset for help on using the changeset viewer.