<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13033] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory: Plugin Directory: Record the reason a plugin is rejected.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/13033">13033</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/13033","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-12-08 03:47:14 +0000 (Fri, 08 Dec 2023)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Plugin Directory: Record the reason a plugin is rejected.

See <a href="http://meta.trac.wordpress.org/ticket/5653">#5653</a>.
Closes https://github.com/WordPress/wordpress.org/pull/107.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclasscustomizationsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclassstatustransitionsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminlisttableclasspluginpostsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclasscontrolsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadmintoolsclassstatsreportphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasstemplatephp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryemailclasspluginrejectedphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/email/class-plugin-rejected.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclasscustomizationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php  2023-12-07 21:28:09 UTC (rev 13032)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php    2023-12-08 03:47:14 UTC (rev 13033)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -474,7 +474,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $post_status = $_REQUEST['post_status'];
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( 'disabled' == $post->post_status && 'disabled' != $post_status ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'disabled' == $post->post_status ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $post_states['disabled'] = _x( 'Disabled', 'plugin status', 'wporg-plugins' );
</span><span class="cx" style="display: block; padding: 0 10px">                        // Affix the reason it's disabled.
</span><span class="cx" style="display: block; padding: 0 10px">                        $reason = Template::get_close_reason( $post );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -482,7 +482,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $post_states['reason'] = $reason;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( 'closed' == $post->post_status && 'closed' != $post_status ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               if ( 'closed' == $post->post_status ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $post_states['closed'] = _x( 'Closed', 'plugin status', 'wporg-plugins' );
</span><span class="cx" style="display: block; padding: 0 10px">                        // Affix the reason it's closed.
</span><span class="cx" style="display: block; padding: 0 10px">                        $reason = Template::get_close_reason( $post );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -490,8 +491,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $post_states['reason'] = $reason;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( 'rejected' == $post->post_status && 'rejected' != $post_status ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               if ( 'rejected' == $post->post_status ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $post_states['rejected'] = _x( 'Rejected', 'plugin status', 'wporg-plugins' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       if ( $post->_rejection_reason ) {
+                               $post_states['reason'] = Template::get_rejection_reasons()[ $post->_rejection_reason ] ?? '';
+                       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">                if ( 'approved' == $post->post_status && 'approved' != $post_status ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $post_states['approved'] = _x( 'Approved', 'plugin status', 'wporg-plugins' );
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminclassstatustransitionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php      2023-12-07 21:28:09 UTC (rev 13032)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php        2023-12-08 03:47:14 UTC (rev 13033)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -141,6 +141,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                break;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'rejected':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                $this->save_rejected_reason( $post->ID );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $this->rejected( $post->ID, $post );
</span><span class="cx" style="display: block; padding: 0 10px">                                $this->clear_reviewer( $post );
</span><span class="cx" style="display: block; padding: 0 10px">                                break;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -270,14 +271,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        [
</span><span class="cx" style="display: block; padding: 0 10px">                                'slug'            => $original_permalink,
</span><span class="cx" style="display: block; padding: 0 10px">                                'submission_date' => $submission_date,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'reason'          => sanitize_key( $_POST['rejection_reason'] ?? '' )
</ins><span class="cx" style="display: block; padding: 0 10px">                         ]
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // ..and log rejection.
-               if ( $email->send() ) {
-                       Tools::audit_log( 'Plugin rejected.', $post_id ); 
-               } else {
-                       Tools::audit_log( 'Plugin rejected. Email not sent.', $post_id );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $email->send();
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -330,7 +328,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! current_user_can( 'plugin_approve', $post_id ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! current_user_can( 'plugin_close', $post_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -343,6 +341,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Save the reason for rejecting a plugin.
+        *
+        * @param int $post_id Post ID.
+        */
+       public function save_rejected_reason( $post_id ) {
+               if ( ! isset( $_REQUEST['rejection_reason'] ) ) {
+                       return;
+               }
+
+               if ( ! current_user_can( 'plugin_reject', $post_id ) ) {
+                       return;
+               }
+
+               $rejection_reason = sanitize_key( $_REQUEST['rejection_reason'] );
+
+               update_post_meta( $post_id, '_rejection_reason', $rejection_reason );
+               update_post_meta( $post_id, 'plugin_rejected_date', current_time( 'mysql' ) );
+
+               Tools::audit_log( sprintf( 'Plugin rejected. Reason: %s', $rejection_reason ), $post_id );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Records a plugin owner change.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param integer $post_id     Post ID.
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminlisttableclasspluginpostsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php 2023-12-07 21:28:09 UTC (rev 13032)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php   2023-12-08 03:47:14 UTC (rev 13033)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -605,6 +605,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                <?php endforeach; ?>
</span><span class="cx" style="display: block; padding: 0 10px">                        </select>
</span><span class="cx" style="display: block; padding: 0 10px">                </fieldset>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               <fieldset class="alignleft actions hide-if-js bulk-plugin_reject" disabled="disabled">
+                       <select name="rejection_reason" id="rejection_reason">
+                               <option disabled="disabled" value='' selected="selected"><?php esc_html_e( 'Rejection Reason:', 'wporg-plugins' ); ?></option>
+                               <?php foreach ( Template::get_rejection_reasons() as $key => $label ) : ?>
+                                       <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></option>
+                               <?php endforeach; ?>
+                       </select>
+               </fieldset>
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 <?php
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Output the JS+CSS needed
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadminmetaboxclasscontrolsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php        2023-12-07 21:28:09 UTC (rev 13032)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php  2023-12-08 03:47:14 UTC (rev 13033)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -85,23 +85,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $statuses = Status_Transitions::get_allowed_transitions( $post->post_status );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $close_reasons   = Template::get_close_reasons();
-               $close_reason    = (string) get_post_meta( $post->ID, '_close_reason', true );
-               $active_installs = (int) get_post_meta( $post->ID, 'active_installs', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $close_reasons     = Template::get_close_reasons();
+               $close_reason      = (string) get_post_meta( $post->ID, '_close_reason', true );
+               $rejection_reasons = Template::get_rejection_reasons();
+               $rejection_reason  = (string) get_post_meta( $post->ID, '_rejection_reason', true );
+               $active_installs   = (int) get_post_meta( $post->ID, 'active_installs', true );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $reason_label   = Template::get_close_reason();
-               $reason_unknown = ( _x( 'Unknown', 'unknown close reason', 'wporg-plugins' ) === $reason_label );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $close_reason_label     = Template::get_close_reason();
+               $close_reason_unknown   = ( _x( 'Unknown', 'unknown close reason', 'wporg-plugins' ) === $reason_label );
+               $rejection_reason_label = $rejection_reasons[ $rejection_reason ] ?? $rejection_reasons[ 'other' ];
</ins><span class="cx" style="display: block; padding: 0 10px">                 ?>
</span><span class="cx" style="display: block; padding: 0 10px">                <div class="misc-pub-section misc-pub-plugin-status">
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        <?php if ( 'closed' === $post->post_status ) : ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                <p><?php printf( __( 'Close Reason: %s', 'wporg-plugins' ), '<strong>' . $reason_label . '</strong>' ); ?></p>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         <p><?php printf( __( 'Close Reason: %s', 'wporg-plugins' ), '<strong>' . $close_reason_label . '</strong>' ); ?></p>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        <?php elseif ( 'disabled' === $post->post_status ) : ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                <p><?php printf( __( 'Disable Reason: %s', 'wporg-plugins' ), '<strong>' . $reason_label . '</strong>' ); ?></p>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         <p><?php printf( __( 'Disable Reason: %s', 'wporg-plugins' ), '<strong>' . $close_reason_label . '</strong>' ); ?></p>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        <?php elseif ( 'rejected' === $post->post_status ) : ?>
+
+                               <p><?php printf(
+                                               __( 'Rejection Reason: %s', 'wporg-plugins' ),
+                                               '<strong>' . $rejection_reason_label . '</strong>'
+                               ); ?></p>
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         <?php elseif ( 'publish' === $post->post_status ) : ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                <?php if ( $active_installs >= '20000' ) : ?>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -110,25 +120,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <?php
-                       if (
-                                       ( in_array( 'closed', $statuses, true ) || in_array( 'disabled', $statuses, true ) )
-                               &&
-                                       ( ! in_array( $post->post_status, array( 'closed', 'disabled' ) ) || $reason_unknown )
-                               ) :
-                               ?>
-
-                               <p>
-                                       <label for="close_reason"><?php _e( 'Close/Disable Reason:', 'wporg-plugins' ); ?></label>
-                                       <select name="close_reason" id="close_reason">
-                                               <?php foreach ( $close_reasons as $key => $label ) : ?>
-                                                       <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $close_reason ); ?>><?php echo esc_html( $label ); ?></option>
-                                               <?php endforeach; ?>
-                                       </select>
-                               </p>
-
-                       <?php endif; ?>
-
</del><span class="cx" style="display: block; padding: 0 10px">                         <?php foreach ( $statuses as $status ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                echo '<p>';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -141,6 +132,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        );
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                if ( 'closed' === $status || 'disabled' === $status ) { ?>
+                                       <p>
+                                               <label for="close_reason"><?php _e( 'Close/Disable Reason:', 'wporg-plugins' ); ?></label>
+                                               <select name="close_reason" id="close_reason">
+                                                       <?php foreach ( $close_reasons as $key => $label ) : ?>
+                                                               <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $close_reason ); ?>><?php echo esc_html( $label ); ?></option>
+                                                       <?php endforeach; ?>
+                                               </select>
+                                       </p>
+                               <?php }
+
+                               if ( 'rejected' === $status ) { ?>
+                                       <p>
+                                               <label for="rejection_reason"><?php _e( 'Rejection Reason:', 'wporg-plugins' ); ?></label>
+                                               <select name="rejection_reason" id="rejection_reason">
+                                                       <?php foreach ( $rejection_reasons as $key => $label ) : ?>
+                                                               <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $rejection_reason ); ?>><?php echo esc_html( $label ); ?></option>
+                                                       <?php endforeach; ?>
+                                               </select>
+                                       </p>
+                               <?php }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 printf(
</span><span class="cx" style="display: block; padding: 0 10px">                                        '<button type="submit" name="post_status" value="%s" class="button set-plugin-status">%s</button>',
</span><span class="cx" style="display: block; padding: 0 10px">                                        esc_attr( $status ),
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryadmintoolsclassstatsreportphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php      2023-12-07 21:28:09 UTC (rev 13032)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php        2023-12-08 03:47:14 UTC (rev 13033)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,8 +276,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                AND `user_id` IN( {$reviewer_ids_list} )
</span><span class="cx" style="display: block; padding: 0 10px">                                AND `comment_agent` = ''
</span><span class="cx" style="display: block; padding: 0 10px">                                AND (
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        `comment_content` IN( 'Plugin Approved.', 'Plugin Rejected.', 'Unassigned.' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 `comment_content` IN( 'Plugin Approved.', 'Unassigned.' )
</ins><span class="cx" style="display: block; padding: 0 10px">                                         OR `comment_content` LIKE 'Assigned TO%'
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        OR `comment_content` LIKE 'Plugin rejected.%'
</ins><span class="cx" style="display: block; padding: 0 10px">                                         OR (
</span><span class="cx" style="display: block; padding: 0 10px">                                                `comment_content` LIKE 'Plugin closed.%'
</span><span class="cx" style="display: block; padding: 0 10px">                                                AND NOT `comment_content` LIKE '%Author Self-close%'
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -652,10 +653,37 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><span class="cx" style="display: block; padding: 0 10px">                                echo '</td>';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // Plugins Approved, Rejected.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         // Plugins Approved.
</ins><span class="cx" style="display: block; padding: 0 10px">                                 echo '<td>', number_format_i18n( $user_stat[ 'Plugin approved.' ] ?? 0 ), '</td>';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                echo '<td>', number_format_i18n( $user_stat[ 'Plugin rejected.' ] ?? 0 ), '</td>';
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                // Plugins Rejected.
+                               $user_rejected_breakdown = '';
+                               $user_rejected_count     = 0;
+                               foreach ( $user_stat as $key => $count ) {
+                                       if ( ! preg_match( '/^Plugin rejected\./', $key ) ) {
+                                               continue;
+                                       }
+                                       $user_rejected_count += $count;
+                                       $reason               = trim( explode( ':', $key )[1] ?? '' );
+
+                                       if ( ! $reason ) {
+                                               continue;
+                                       }
+
+                                       $user_rejected_breakdown .= sprintf(
+                                               "%s: %s\n",
+                                               Template::get_rejection_reasons()[ $reason ],
+                                               number_format_i18n( $count )
+                                       );
+                               }
+                               $user_rejected_breakdown = trim( $user_rejected_breakdown );
+
+                               echo '<td class="breakdown">', '<span title="', esc_attr( $user_rejected_breakdown ), '">', number_format_i18n( $user_rejected_count ), '</span>';
+                               if ( $user_rejected_breakdown ) {
+                                       echo '<div class="hidden">', nl2br( $user_rejected_breakdown ), '</div>';
+                               }
+                               echo '</td>';
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 // Plugins Closed.
</span><span class="cx" style="display: block; padding: 0 10px">                                $user_closed_breakdown = '';
</span><span class="cx" style="display: block; padding: 0 10px">                                $user_closed_count     = 0;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -692,7 +720,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $("table.review-stats").on( "click", ".breakdown", function() {
</span><span class="cx" style="display: block; padding: 0 10px">                                        $(this).children().length > 1 && $(this).children().toggleClass("hidden");
</span><span class="cx" style="display: block; padding: 0 10px">                                } );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        } );</script>'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 } );</script>';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        ?>
</span><span class="cx" style="display: block; padding: 0 10px">                        <ul style="font-style:italic;">
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryclasstemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php      2023-12-07 21:28:09 UTC (rev 13032)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php        2023-12-08 03:47:14 UTC (rev 13033)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -911,6 +911,31 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Returns the reasons for rejecting a plugin.
+        *
+        * @return array Rejection reason labels.
+        */
+       public static function get_rejection_reasons() {
+               return array(
+                       '3-month'              => '3 months without completion',
+                       'core-supports'        => 'Code is already in core',
+                       'duplicate-copy'       => 'Duplicate (copy) of another Plugin',
+                       'library-or-framework' => 'Framework or Library Plugin',
+                       'generic'              => "Something we're just not hosting",
+                       'duplicate'            => 'New/renamed version of their own plugin',
+                       'wp-cli'               => 'WP-CLI Only Plugins',
+                       'storefront'           => 'Storefront',
+                       'not-owner'            => 'Not the submitters plugin',
+                       'script-insertion'     => 'Script Insertion Plugins are Dangerous',
+                       'demo'                 => 'Test/Demo plugin (non functional)',
+                       'translation'          => 'Translation of existing plugin',
+                       'banned'               => 'Banned developer trying to sneak back in',
+                       'author-request'       => 'Author requested not to continue',
+                       'other'                => 'OTHER: See notes',
+               );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Returns the close/disable reason for a plugin.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryemailclasspluginrejectedphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/email/class-plugin-rejected.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/email/class-plugin-rejected.php 2023-12-07 21:28:09 UTC (rev 13032)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/email/class-plugin-rejected.php   2023-12-08 03:47:14 UTC (rev 13033)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -18,6 +18,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function body() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // NOTE: $this->args['reason'] has rejection reason if applicable.
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 /* translators: 1: plugin name, 2: plugin permalink, 3: date of submission, 4: plugins@wordpress.org */
</span><span class="cx" style="display: block; padding: 0 10px">                $email_text = __(
</span><span class="cx" style="display: block; padding: 0 10px">                        'Unfortunately your plugin submission for %1$s (%2$s), submitted on %3$s, has been rejected from the WordPress Plugin Directory.
</span></span></pre>
</div>
</div>

</body>
</html>