Ticket #2796: 2796.2.patch
File 2796.2.patch, 8.3 KB (added by , 7 years ago) |
---|
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
32 32 add_action( 'load-edit.php', array( $this, 'bulk_reject_plugins' ) ); 33 33 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); 34 34 add_filter( 'admin_head-edit.php', array( $this, 'plugin_posts_list_table' ) ); 35 add_filter( 'post_row_actions', array( $this, 'plugin_row_actions' ) ); 35 36 add_action( 'edit_form_top', array( $this, 'show_permalink' ) ); 36 37 add_action( 'admin_notices', array( $this, 'add_post_status_notice' ) ); 37 38 add_action( 'all_admin_notices', array( $this, 'admin_notices' ) ); … … 162 163 } 163 164 164 165 /** 166 * Disables Quick Edit for plugins. 167 * 168 * @param array $actions An array of row action links. 169 * @return array Filtered array of row action links. 170 */ 171 public function plugin_row_actions( $actions ) { 172 global $post_type; 173 174 if ( 'plugin' === $post_type ) { 175 unset( $actions['inline hide-if-no-js'] ); 176 } 177 178 return $actions; 179 } 180 181 /** 165 182 * Rejects plugins in bulk. 166 183 */ 167 184 public function bulk_reject_plugins() { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php
31 31 } 32 32 33 33 /** 34 * Get the list of allowed status transitions for a given plugin. 35 * 36 * @param string $post_status Plugin post status. 37 * @return array An array of allowed post status transitions. 38 */ 39 public static function get_allowed_transitions( $post_status ) { 40 switch ( $post_status ) { 41 case 'new': 42 $transitions = array( 'pending', 'approved', 'rejected' ); 43 break; 44 case 'pending': 45 $transitions = array( 'approved', 'rejected' ); 46 break; 47 case 'approved': 48 // Plugins move from 'approved' to 'publish' on first commit, but cannot be published manually. 49 $transitions = array(); 50 break; 51 case 'rejected': 52 $transitions = array( 'pending' ); 53 break; 54 case 'publish': 55 $transitions = array( 'disabled', 'closed' ); 56 break; 57 case 'disabled': 58 $transitions = array( 'publish', 'closed' ); 59 break; 60 case 'closed': 61 $transitions = array( 'publish', 'disabled' ); 62 break; 63 default: 64 $transitions = array( 'new', 'pending' ); 65 break; 66 } 67 68 return $transitions; 69 } 70 71 /** 34 72 * Checks permissions before allowing a post_status change for plugins. 35 73 * 36 74 * @param array $data An array of slashed post data. … … 51 89 } 52 90 53 91 // ...or it's a plugin admin... 54 if ( current_user_can( 'plugin_approve', $postarr['ID'] ) ) {92 if ( current_user_can( 'plugin_approve', $postarr['ID'] ) && in_array( $postarr['post_status'], self::get_allowed_transitions( $postarr['post_status'] ) ) ) { 55 93 return $data; 56 94 } 57 95 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php
74 74 if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { 75 75 if ( $this->is_trash ) { 76 76 $actions['untrash'] = __( 'Restore', 'wporg-plugins' ); 77 } else {78 $actions['edit'] = __( 'Edit', 'wporg-plugins' );79 77 } 80 78 } 81 79 … … 289 287 } 290 288 291 289 /** 290 * Remove the Quick/Bulk Edit hidden row. 291 */ 292 public function inline_edit() { 293 } 294 295 /** 292 296 * Prepares list view links, including plugins that the current user has commit access to. 293 297 * 294 298 * @global array $locked_post_status This seems to be deprecated. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 use WordPressdotorg\Plugin_Directory\Admin\Status_Transitions; 3 4 4 5 /** 5 6 * The Plugin Controls / Publish metabox. … … 41 42 } 42 43 43 44 $statuses = array( 'new', 'pending' ); 45 44 46 if ( current_user_can( 'plugin_approve', $post ) ) { 45 if ( in_array( $post->post_status, array( 'new', 'draft', 'pending', 'rejected', 'approved' ) ) ) { 46 $statuses = array_merge( $statuses, array( 'approved', 'rejected' ) ); 47 } else { 48 $statuses = array( 'publish', 'disabled', 'closed', 'pending' ); 49 } 47 $statuses = Status_Transitions::get_allowed_transitions( $post->post_status ); 50 48 } 51 49 ?> 52 50 <div class="misc-pub-section misc-pub-plugin-status"> 53 51 <label for="post_status"><?php _e( 'Status:', 'wporg-plugins' ); ?></label> 54 52 <strong id="plugin-status-display"><?php echo esc_html( get_post_status_object( $post->post_status )->label ); ?></strong> 55 <button type="button" class="button-link edit-plugin-status hide-if-no-js">56 <span aria-hidden="true"><?php _e( 'Edit', 'wporg-plugins' ); ?></span>57 <span class="screen-reader-text"><?php _e( 'Edit plugin status', 'wporg-plugins' ); ?></span>58 </button>59 53 60 <div id="plugin-status-select" class="plugin-control-select hide-if-js"> 61 <input type="hidden" name="hidden_post_status" id="hidden-post-status" value="<?php echo esc_attr( $post->post_status ); ?>"> 62 <label class="screen-reader-text" for="plugin-status"><?php _e( 'Plugin status', 'wporg-plugins' ); ?></label> 63 <select name="post_status" id="plugin-status"> 64 <?php 65 foreach ( $statuses as $statii ) { 66 $status_object = get_post_status_object( $statii ); 67 printf( 68 '<option value="%s" %s>%s</option>', 69 esc_attr( $statii ), 70 selected( $post->post_status, $statii, false ), 71 esc_html( $status_object->label ) 72 ); 73 } 74 ?> 75 </select> 76 <button type="button" class="save-plugin-status hide-if-no-js button"><?php _e( 'OK', 'wporg-plugins' ); ?></button> 77 <button type="button" class="cancel-plugin-status hide-if-no-js button-link"><?php _e( 'Cancel', 'wporg-plugins' ); ?></button> 78 </div> 54 <?php if ( $statuses ) : ?> 55 <button type="button" class="button-link edit-plugin-status hide-if-no-js"> 56 <span aria-hidden="true"><?php _e( 'Edit', 'wporg-plugins' ); ?></span> 57 <span class="screen-reader-text"><?php _e( 'Edit plugin status', 'wporg-plugins' ); ?></span> 58 </button> 79 59 60 <div id="plugin-status-select" class="plugin-control-select hide-if-js"> 61 <input type="hidden" name="hidden_post_status" id="hidden-post-status" value="<?php echo esc_attr( $post->post_status ); ?>"> 62 <label class="screen-reader-text" for="plugin-status"><?php _e( 'Plugin status', 'wporg-plugins' ); ?></label> 63 <select name="post_status" id="plugin-status"> 64 <?php 65 foreach ( $statuses as $statii ) { 66 $status_object = get_post_status_object( $statii ); 67 printf( 68 '<option value="%s" %s>%s</option>', 69 esc_attr( $statii ), 70 selected( $post->post_status, $statii, false ), 71 esc_html( $status_object->label ) 72 ); 73 } 74 ?> 75 </select> 76 <button type="button" class="save-plugin-status hide-if-no-js button"><?php _e( 'OK', 'wporg-plugins' ); ?></button> 77 <button type="button" class="cancel-plugin-status hide-if-no-js button-link"><?php _e( 'Cancel', 'wporg-plugins' ); ?></button> 78 </div> 79 <?php endif; ?> 80 80 81 </div><!-- .misc-pub-section --><?php 81 82 } 82 83