Making WordPress.org


Ignore:
Timestamp:
12/08/2023 03:47:14 AM (10 months ago)
Author:
dd32
Message:

Plugin Directory: Record the reason a plugin is rejected.

See #5653.
Closes https://github.com/WordPress/wordpress.org/pull/107.

File:
1 edited

Legend:

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

    r12991 r13033  
    142142
    143143            case 'rejected':
     144                $this->save_rejected_reason( $post->ID );
    144145                $this->rejected( $post->ID, $post );
    145146                $this->clear_reviewer( $post );
     
    271272                'slug'            => $original_permalink,
    272273                'submission_date' => $submission_date,
     274                'reason'          => sanitize_key( $_POST['rejection_reason'] ?? '' )
    273275            ]
    274276        );
    275         // ..and log rejection.
    276         if ( $email->send() ) {
    277             Tools::audit_log( 'Plugin rejected.', $post_id );
    278         } else {
    279             Tools::audit_log( 'Plugin rejected. Email not sent.', $post_id );
    280         }
     277
     278        $email->send();
    281279    }
    282280
     
    331329        }
    332330
    333         if ( ! current_user_can( 'plugin_approve', $post_id ) ) {
     331        if ( ! current_user_can( 'plugin_close', $post_id ) ) {
    334332            return;
    335333        }
     
    341339
    342340        Tools::audit_log( sprintf( 'Plugin closed. Reason: %s', $close_reason ), $post_id );
     341    }
     342
     343    /**
     344     * Save the reason for rejecting a plugin.
     345     *
     346     * @param int $post_id Post ID.
     347     */
     348    public function save_rejected_reason( $post_id ) {
     349        if ( ! isset( $_REQUEST['rejection_reason'] ) ) {
     350            return;
     351        }
     352
     353        if ( ! current_user_can( 'plugin_reject', $post_id ) ) {
     354            return;
     355        }
     356
     357        $rejection_reason = sanitize_key( $_REQUEST['rejection_reason'] );
     358
     359        update_post_meta( $post_id, '_rejection_reason', $rejection_reason );
     360        update_post_meta( $post_id, 'plugin_rejected_date', current_time( 'mysql' ) );
     361
     362        Tools::audit_log( sprintf( 'Plugin rejected. Reason: %s', $rejection_reason ), $post_id );
    343363    }
    344364
Note: See TracChangeset for help on using the changeset viewer.