WordPress.org

Making WordPress.org


Ignore:
Timestamp:
12/03/2017 07:32:59 PM (21 months ago)
Author:
Otto42
Message:

Plugins: General code cleanup, migrate events that happen on transistions to single place, remove duplicated code, add auditing, simplify logic. props @joostdevalk See #2860

File:
1 edited

Legend:

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

    r6129 r6217  
    4040        add_filter( 'wp_insert_post_data', array( $this, 'check_existing_plugin_slug_on_post_update' ), 10, 2 );
    4141        add_filter( 'wp_unique_post_slug', array( $this, 'check_existing_plugin_slug_on_inline_save' ), 10, 6 );
    42 
    43         add_action( 'save_post', array( $this, 'save_close_reason' ), 10, 2 );
    4442
    4543        add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 );
     
    379377
    380378    /**
    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         update_post_meta( $post_id, '_close_date',   current_time( 'mysql' ) );
    401     }
    402 
    403     /**
    404379     * Register the Admin metaboxes for the plugin management screens.
    405380     *
Note: See TracChangeset for help on using the changeset viewer.