Making WordPress.org


Ignore:
Timestamp:
10/16/2017 12:35:07 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Plugin Directory: Provide the ability to specify a reason when closing or disabling a plugin.

Props jdgrimes.
See #2860.

File:
1 edited

Legend:

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

    r5997 r6034  
    4141        add_filter( 'wp_unique_post_slug', array( $this, 'check_existing_plugin_slug_on_inline_save' ), 10, 6 );
    4242
     43        add_action( 'save_post', array( $this, 'save_close_reason' ), 10, 2 );
     44
    4345        add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 );
    4446        add_filter( 'comment_row_actions', array( $this, 'custom_comment_row_actions' ), 10, 2 );
     
    5153        add_filter( 'postbox_classes_plugin_internal-notes',      array( __NAMESPACE__ . '\Metabox\Internal_Notes', 'postbox_classes' ) );
    5254        add_filter( 'postbox_classes_plugin_plugin-committers',   array( __NAMESPACE__ . '\Metabox\Committers',     'postbox_classes' ) );
    53         add_filter( 'postbox_classes_plugin_plugin-support-reps', array( __NAMESPACE__ . '\Metabox\Support_Reps',     'postbox_classes' ) );
    54         add_filter( 'wp_ajax_add-committer',        array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer'    ) );
     55        add_filter( 'postbox_classes_plugin_plugin-support-reps', array( __NAMESPACE__ . '\Metabox\Support_Reps',   'postbox_classes' ) );
     56        add_filter( 'wp_ajax_add-committer',        array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer' ) );
    5557        add_filter( 'wp_ajax_delete-committer',     array( __NAMESPACE__ . '\Metabox\Committers', 'remove_committer' ) );
    5658        add_filter( 'wp_ajax_add-support-rep',      array( __NAMESPACE__ . '\Metabox\Support_Reps', 'add_support_rep' ) );
    5759        add_filter( 'wp_ajax_delete-support-rep',   array( __NAMESPACE__ . '\Metabox\Support_Reps', 'remove_support_rep' ) );
    5860        add_action( 'wp_ajax_plugin-author-lookup', array( __NAMESPACE__ . '\Metabox\Author', 'lookup_author' ) );
    59 
    6061    }
    6162
     
    378379
    379380    /**
     381     * Save the reason for closing or disabling a plugin.
     382     *
     383     * @param int      $post_id Post ID.
     384     * @param \WP_Post $post    Post object.
     385     */
     386    public function save_close_reason( $post_id, $post ) {
     387        if ( 'plugin' !== $post->post_type || ! isset( $_POST['close_reason'] ) ) {
     388            return;
     389        }
     390
     391        if ( ! current_user_can( 'plugin_approve', $post_id ) ) {
     392            return;
     393        }
     394
     395        if ( ! in_array( $post->post_status, array( 'closed', 'disabled' ) ) ) {
     396            return;
     397        }
     398
     399        update_post_meta( $post_id, '_close_reason', sanitize_key( $_POST['close_reason'] ) );
     400    }
     401
     402    /**
    380403     * Register the Admin metaboxes for the plugin management screens.
    381404     *
Note: See TracChangeset for help on using the changeset viewer.