Changeset 5573 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
- Timestamp:
- 06/15/2017 02:05:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
r5318 r5573 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 use WordPressdotorg\Plugin_Directory\Admin\Status_Transitions; 3 4 4 5 /** … … 31 32 32 33 /** 34 * Get button label for setting the plugin status. 35 * 36 * @param string $post_status Plugin post status. 37 * @return string Status button label. 38 */ 39 public static function get_status_button_label( $post_status ) { 40 switch ( $post_status ) { 41 case 'approved': 42 $label = __( 'Approve' ); 43 break; 44 case 'rejected': 45 $label = __( 'Reject' ); 46 break; 47 case 'pending': 48 $label = __( 'Mark as Pending' ); 49 break; 50 case 'publish': 51 $label = __( 'Open' ); 52 break; 53 case 'disabled': 54 $label = __( 'Disable' ); 55 break; 56 case 'closed': 57 $label = __( 'Close' ); 58 break; 59 default: 60 $label = __( 'Mark as Pending' ); 61 break; 62 } 63 64 return $label; 65 } 66 67 /** 33 68 * Displays the Plugin Status control in the Publish metabox. 34 69 */ … … 42 77 43 78 $statuses = array( 'new', 'pending' ); 79 44 80 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 } 81 $statuses = Status_Transitions::get_allowed_transitions( $post->post_status ); 50 82 } 51 83 ?> … … 53 85 <label for="post_status"><?php _e( 'Status:', 'wporg-plugins' ); ?></label> 54 86 <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 87 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 88 <p> 89 <?php foreach ( $statuses as $status ) : ?> 90 <button type="submit" name="post_status" value="<?php echo esc_attr( $status ); ?>" class="button set-plugin-status"> 91 <?php echo self::get_status_button_label( $status ); ?> 92 </button> 93 <?php endforeach; ?> 94 </p> 80 95 </div><!-- .misc-pub-section --><?php 81 96 }
Note: See TracChangeset
for help on using the changeset viewer.