Making WordPress.org


Ignore:
Timestamp:
12/08/2023 03:47:14 AM (9 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/metabox/class-controls.php

    r12610 r13033  
    8686        }
    8787
    88         $close_reasons   = Template::get_close_reasons();
    89         $close_reason    = (string) get_post_meta( $post->ID, '_close_reason', true );
    90         $active_installs = (int) get_post_meta( $post->ID, 'active_installs', true );
    91 
    92         $reason_label   = Template::get_close_reason();
    93         $reason_unknown = ( _x( 'Unknown', 'unknown close reason', 'wporg-plugins' ) === $reason_label );
     88        $close_reasons     = Template::get_close_reasons();
     89        $close_reason      = (string) get_post_meta( $post->ID, '_close_reason', true );
     90        $rejection_reasons = Template::get_rejection_reasons();
     91        $rejection_reason  = (string) get_post_meta( $post->ID, '_rejection_reason', true );
     92        $active_installs   = (int) get_post_meta( $post->ID, 'active_installs', true );
     93
     94        $close_reason_label     = Template::get_close_reason();
     95        $close_reason_unknown   = ( _x( 'Unknown', 'unknown close reason', 'wporg-plugins' ) === $reason_label );
     96        $rejection_reason_label = $rejection_reasons[ $rejection_reason ] ?? $rejection_reasons[ 'other' ];
    9497        ?>
    9598        <div class="misc-pub-section misc-pub-plugin-status">
     
    97100            <?php if ( 'closed' === $post->post_status ) : ?>
    98101
    99                 <p><?php printf( __( 'Close Reason: %s', 'wporg-plugins' ), '<strong>' . $reason_label . '</strong>' ); ?></p>
     102                <p><?php printf( __( 'Close Reason: %s', 'wporg-plugins' ), '<strong>' . $close_reason_label . '</strong>' ); ?></p>
    100103
    101104            <?php elseif ( 'disabled' === $post->post_status ) : ?>
    102105
    103                 <p><?php printf( __( 'Disable Reason: %s', 'wporg-plugins' ), '<strong>' . $reason_label . '</strong>' ); ?></p>
     106                <p><?php printf( __( 'Disable Reason: %s', 'wporg-plugins' ), '<strong>' . $close_reason_label . '</strong>' ); ?></p>
     107
     108            <?php elseif ( 'rejected' === $post->post_status ) : ?>
     109
     110                <p><?php printf(
     111                        __( 'Rejection Reason: %s', 'wporg-plugins' ),
     112                        '<strong>' . $rejection_reason_label . '</strong>'
     113                ); ?></p>
    104114
    105115            <?php elseif ( 'publish' === $post->post_status ) : ?>
     
    108118                    <p><strong><?php _e( 'Notice:', 'wporg-plugins' ); ?></strong> <?php _e( 'Due to the large volume of active users, the developers should be warned and their plugin remain open save under extreme circumstances.', 'wporg-plugins' ); ?>.</p>
    109119                <?php endif; ?>
    110 
    111             <?php endif; ?>
    112 
    113             <?php
    114             if (
    115                     ( in_array( 'closed', $statuses, true ) || in_array( 'disabled', $statuses, true ) )
    116                 &&
    117                     ( ! in_array( $post->post_status, array( 'closed', 'disabled' ) ) || $reason_unknown )
    118                 ) :
    119                 ?>
    120 
    121                 <p>
    122                     <label for="close_reason"><?php _e( 'Close/Disable Reason:', 'wporg-plugins' ); ?></label>
    123                     <select name="close_reason" id="close_reason">
    124                         <?php foreach ( $close_reasons as $key => $label ) : ?>
    125                             <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $close_reason ); ?>><?php echo esc_html( $label ); ?></option>
    126                         <?php endforeach; ?>
    127                     </select>
    128                 </p>
    129120
    130121            <?php endif; ?>
     
    142133                }
    143134
     135                if ( 'closed' === $status || 'disabled' === $status ) { ?>
     136                    <p>
     137                        <label for="close_reason"><?php _e( 'Close/Disable Reason:', 'wporg-plugins' ); ?></label>
     138                        <select name="close_reason" id="close_reason">
     139                            <?php foreach ( $close_reasons as $key => $label ) : ?>
     140                                <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $close_reason ); ?>><?php echo esc_html( $label ); ?></option>
     141                            <?php endforeach; ?>
     142                        </select>
     143                    </p>
     144                <?php }
     145
     146                if ( 'rejected' === $status ) { ?>
     147                    <p>
     148                        <label for="rejection_reason"><?php _e( 'Rejection Reason:', 'wporg-plugins' ); ?></label>
     149                        <select name="rejection_reason" id="rejection_reason">
     150                            <?php foreach ( $rejection_reasons as $key => $label ) : ?>
     151                                <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $rejection_reason ); ?>><?php echo esc_html( $label ); ?></option>
     152                            <?php endforeach; ?>
     153                        </select>
     154                    </p>
     155                <?php }
     156
    144157                printf(
    145158                    '<button type="submit" name="post_status" value="%s" class="button set-plugin-status">%s</button>',
Note: See TracChangeset for help on using the changeset viewer.