WordPress.org

Making WordPress.org

Changeset 2929


Ignore:
Timestamp:
04/11/2016 01:37:50 PM (3 years ago)
Author:
obenland
Message:

Plugin Directory: Allow committer mangament only for active plugins.

Plugins that are not yet live or are deprecated/hidden, should not have
committers added to them.

See #1570.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin
Files:
2 edited

Legend:

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

    r2927 r2929  
    2626    private function __construct() {
    2727        // Admin Metaboxes
    28         add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ), 10, 1 );
     28        add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ), 10, 2 );
    2929        add_action( 'do_meta_boxes', array( $this, 'replace_title_global' ) );
    3030
     
    220220     * Register the Admin metaboxes for the plugin management screens.
    221221     *
    222      * @param string $post_type The post type of the current screen.
     222     * @param string   $post_type The post type of the current screen.
     223     * @param \WP_Post $post      Post object.
    223224     * @return void.
    224225     */
    225     public function register_admin_metaboxes( $post_type ) {
     226    public function register_admin_metaboxes( $post_type, $post ) {
    226227        if ( 'plugin' != $post_type ) {
    227228            return;
     
    260261        );
    261262
    262         add_meta_box(
    263             'plugin-committers',
    264             __( 'Plugin Committers', 'wporg-plugins' ),
    265             array( __NAMESPACE__ . '\Metabox\Committers', 'display' ),
    266             'plugin', 'side'
    267         );
     263        if ( 'publish' === $post->post_status ) {
     264            add_meta_box(
     265                'plugin-committers',
     266                __( 'Plugin Committers', 'wporg-plugins' ),
     267                array( __NAMESPACE__ . '\Metabox\Committers', 'display' ),
     268                'plugin', 'side'
     269            );
     270        }
    268271
    269272        // Remove unnecessary metaboxes.
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php

    r2789 r2929  
    4040
    4141        check_ajax_referer( 'add-committer' );
     42
     43        if ( ! current_user_can( 'plugin_add_committer', $post_id ) || 'publish' !== get_post_status( $post_id ) ) {
     44            wp_die( -1 );
     45        }
     46
    4247        global $post;
    4348
     
    5156            ) );
    5257            $response->send();
    53         }
    54 
    55         if ( ! current_user_can( 'plugin_add_committer', $post_id ) ) {
    56                 wp_die( -1 );
    5758        }
    5859
     
    8990        check_ajax_referer( "remove-committer-$id" );
    9091
     92        if ( ! current_user_can( 'plugin_remove_committer', $post_id ) || 'publish' !== get_post_status( $post_id ) ) {
     93            wp_die( -1 );
     94        }
     95
    9196        $response    = new \WP_Ajax_Response();
    9297        $plugin_slug = get_post( $post_id )->post_name;
     
    100105        }
    101106
    102         if ( ! current_user_can( 'plugin_remove_committer', $post_id ) ) {
    103                 wp_die( -1 );
    104         }
    105 
    106107        $result = Tools::revoke_plugin_committer( $plugin_slug, $committer );
    107108
Note: See TracChangeset for help on using the changeset viewer.