Making WordPress.org

Changeset 10224


Ignore:
Timestamp:
09/01/2020 02:54:02 AM (4 years ago)
Author:
dd32
Message:

Plugin Directory: Release Confirmation: Don't disable when it's not enabled. Attempt two.

Previously [10221].
See #5352.

File:
1 edited

Legend:

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

    r10221 r10224  
    3636
    3737    // Save the selection.
    38     static function save_post( $post_id ) {
     38    static function save_post( $post ) {
     39        $post = get_post( $post );
     40
    3941        if (
     42            $post &&
    4043            isset( $_REQUEST['release_confirmation'] ) &&
    4144            is_numeric( $_REQUEST['release_confirmation'] ) &&
    42             current_user_can( 'plugin_admin_edit', $post_id )
     45            current_user_can( 'plugin_admin_edit', $post->ID )
    4346        ) {
    44             if ( $_REQUEST['release_confirmation'] == get_post_meta( $post_id, 'release_confirmation', true ) ) {
    45                 // Do nothing, it's all good.
    46             } else if ( 0 == $_REQUEST['release_confirmation'] ) {
     47            $current = (int) $post->release_confirmation;
     48            $new     = (int) $_REQUEST['release_confirmation'];
     49
     50            if ( $new == $current ) {
     51                return;
     52            }
     53
     54            if ( 0 == $new ) {
    4755                // Disable
    48                 Tools::audit_log( 'Plugin release confirmation disabled.', $post_id );
    49                 update_post_meta( $post_id, 'release_confirmation', 0 );
     56                Tools::audit_log( 'Plugin release confirmation disabled.', $post );
     57                update_post_meta( $post->ID, 'release_confirmation', $new );
    5058
    5159            } else {
     
    5361                $request = new WP_REST_Request(
    5462                    'POST',
    55                     '/plugins/v1/plugin/' . get_post( $post_id )->post_name . '/release-confirmation'
     63                    '/plugins/v1/plugin/' . $post->post_name . '/release-confirmation'
    5664                );
    5765                $request->set_param(
    5866                    'confirmations_required',
    59                     (int) $_REQUEST['release_confirmation']
     67                    $new
    6068                );
    6169
Note: See TracChangeset for help on using the changeset viewer.