Changeset 13507
- Timestamp:
- 04/12/2024 03:58:20 AM (13 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php
r13440 r13507 36 36 37 37 /** 38 * Get the list of allowed status transitions for a given plugin. 39 * 40 * @param string $post_status Plugin post status. 38 * Get the list of allowed status transitions for a given plugin status & post. 39 * 40 * @param string $post_status Plugin post status. 41 * @param \WP_Post $post Plugin post object. 41 42 * 42 43 * @return array An array of allowed post status transitions. 43 44 */ 44 public static function get_allowed_transitions( $post_status ) { 45 public static function get_allowed_transitions( $post_status, $post ) { 46 // NOTE: $post_status and $post->post_status will differ, as it's used during a pre-update hook. 45 47 switch ( $post_status ) { 46 48 case 'new': … … 48 50 break; 49 51 case 'pending': 50 $transitions = array( 'approved', 'rejected' );52 $transitions = array( 'approved', 'rejected', 'new' ); 51 53 break; 52 54 case 'approved': … … 55 57 break; 56 58 case 'rejected': 57 // Rejections cannot be recovered.58 59 $transitions = array(); 60 // If it was rejected less than a week ago, allow it to be recovered. 61 $rejected_date = get_post_meta( $post->ID, '_rejected', true ); 62 if ( $rejected_date >= strtotime( '-1 week' ) ) { 63 $transitions[] = 'pending'; 64 } 59 65 break; 60 66 case 'publish': … … 97 103 98 104 // ...or it's a plugin admin... 99 if ( current_user_can( 'plugin_approve', $postarr['ID'] ) && in_array( $postarr['post_status'], self::get_allowed_transitions( $old_status ) ) ) {105 if ( current_user_can( 'plugin_approve', $postarr['ID'] ) && in_array( $postarr['post_status'], self::get_allowed_transitions( $old_status, get_post( $postarr['ID'] ) ) ) ) { 100 106 return $data; 101 107 } … … 158 164 $this->set_translation_status( $post, 'inactive' ); 159 165 break; 166 167 case 'pending': 168 if ( 'rejected' === $old_status ) { 169 $this->restore_rejected_plugin( $post ); 170 } 171 172 case 'new': 173 // If it's moved from Pending to new, unasign. 174 if ( 'pending' === $old_status ) { 175 $this->clear_reviewer( $post ); 176 } 160 177 } 161 178 … … 298 315 299 316 /** 317 * Restores a rejected plugin. 318 * 319 * @param \WP_Post $post Post object. 320 */ 321 public function restore_rejected_plugin( $post ) { 322 $slug = $post->post_name; 323 $slug = preg_replace( '!^rejected-(.+)-rejected$!i', '$1', $slug ); 324 325 // Change slug back to 'plugin-name'. 326 wp_update_post( array( 327 'ID' => $post->ID, 328 'post_name' => $slug, 329 ) ); 330 331 delete_post_meta( $post_id, '_rejection_reason' ); 332 delete_post_meta( $post_id, 'plugin_rejected_date' ); 333 } 334 335 /** 300 336 * Returns the path to a plugins root directory. 301 337 * -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
r13199 r13507 66 66 $label = __( 'Close', 'wporg-plugins' ); 67 67 break; 68 case 'new': 69 $label = __( 'Mark as Pending Initial Review', 'wporg-plugins' ); 70 break; 68 71 case 'pending': 69 72 default: … … 89 92 90 93 if ( current_user_can( 'plugin_approve', $post ) ) { 91 $statuses = Status_Transitions::get_allowed_transitions( $post->post_status );94 $statuses = Status_Transitions::get_allowed_transitions( $post->post_status, $post ); 92 95 } 93 96 … … 141 144 if ( 'pending' === $status && ! $post->assigned_reviewer ) { 142 145 printf( 143 '<p class="pending-assign"><button onclick="%s" type="submit" name="post_status" value="%s" class="button set-plugin-status button-primary">%s</button></p>', 144 esc_attr( "document.getElementById('assigned_reviewer').value = userSettings.uid" ), 146 '<p class="pending-assign"><button type="submit" name="post_status" value="%s" class="button set-plugin-status pending-and-assign button-primary">%s</button></p>', 145 147 esc_attr( $status ), 146 148 esc_attr__( 'Mark as Pending & Assign Review', 'wporg-plugins' ),
Note: See TracChangeset
for help on using the changeset viewer.