Changeset 6034
- Timestamp:
- 10/16/2017 12:35:07 AM (7 years 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-customizations.php
r5997 r6034 41 41 add_filter( 'wp_unique_post_slug', array( $this, 'check_existing_plugin_slug_on_inline_save' ), 10, 6 ); 42 42 43 add_action( 'save_post', array( $this, 'save_close_reason' ), 10, 2 ); 44 43 45 add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 ); 44 46 add_filter( 'comment_row_actions', array( $this, 'custom_comment_row_actions' ), 10, 2 ); … … 51 53 add_filter( 'postbox_classes_plugin_internal-notes', array( __NAMESPACE__ . '\Metabox\Internal_Notes', 'postbox_classes' ) ); 52 54 add_filter( 'postbox_classes_plugin_plugin-committers', array( __NAMESPACE__ . '\Metabox\Committers', 'postbox_classes' ) ); 53 add_filter( 'postbox_classes_plugin_plugin-support-reps', array( __NAMESPACE__ . '\Metabox\Support_Reps', 54 add_filter( 'wp_ajax_add-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer' 55 add_filter( 'postbox_classes_plugin_plugin-support-reps', array( __NAMESPACE__ . '\Metabox\Support_Reps', 'postbox_classes' ) ); 56 add_filter( 'wp_ajax_add-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer' ) ); 55 57 add_filter( 'wp_ajax_delete-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'remove_committer' ) ); 56 58 add_filter( 'wp_ajax_add-support-rep', array( __NAMESPACE__ . '\Metabox\Support_Reps', 'add_support_rep' ) ); 57 59 add_filter( 'wp_ajax_delete-support-rep', array( __NAMESPACE__ . '\Metabox\Support_Reps', 'remove_support_rep' ) ); 58 60 add_action( 'wp_ajax_plugin-author-lookup', array( __NAMESPACE__ . '\Metabox\Author', 'lookup_author' ) ); 59 60 61 } 61 62 … … 378 379 379 380 /** 381 * Save the reason for closing or disabling a plugin. 382 * 383 * @param int $post_id Post ID. 384 * @param \WP_Post $post Post object. 385 */ 386 public function save_close_reason( $post_id, $post ) { 387 if ( 'plugin' !== $post->post_type || ! isset( $_POST['close_reason'] ) ) { 388 return; 389 } 390 391 if ( ! current_user_can( 'plugin_approve', $post_id ) ) { 392 return; 393 } 394 395 if ( ! in_array( $post->post_status, array( 'closed', 'disabled' ) ) ) { 396 return; 397 } 398 399 update_post_meta( $post_id, '_close_reason', sanitize_key( $_POST['close_reason'] ) ); 400 } 401 402 /** 380 403 * Register the Admin metaboxes for the plugin management screens. 381 404 * -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
r5715 r6034 15 15 */ 16 16 static function display() { 17 echo '<div class="submitbox" id="submitpost">'; 18 echo '<div id="misc-publishing-actions">'; 17 ?> 18 <div class="submitbox" id="submitpost"> 19 <div id="misc-publishing-actions"> 20 <?php 19 21 self::display_post_status(); 20 22 … … 22 24 self::display_tested_up_to(); 23 25 } 24 echo '</div>'; 26 ?> 27 </div> 25 28 26 echo '<div id="major-publishing-actions"><div id="publishing-action">'; 27 echo '<span class="spinner"></span>'; 28 printf( '<input type="submit" name="save_changes" id="publish" class="button button-primary button-large" value="%s">', __( 'Save Changes', 'wporg-plugins' ) ); 29 echo '</div><div class="clear"></div></div>'; 30 echo '</div>'; 29 <div id="major-publishing-actions"> 30 <div id="publishing-action"> 31 <span class="spinner"></span> 32 <input type="submit" name="save_changes" id="publish" class="button button-primary button-large" value="<?php esc_attr_e( 'Save Changes', 'wporg-plugins' ); ?>"> 33 </div> 34 <div class="clear"></div> 35 </div> 36 </div> 37 <?php 31 38 } 32 39 … … 66 73 67 74 /** 75 * Get reasons for closing or disabling a plugin. 76 * 77 * @return array Close/disable reason labels. 78 */ 79 public static function get_close_reasons() { 80 return array( 81 'security-issue' => __( 'Security Issue', 'wporg-plugins' ), 82 'author-request' => __( 'Author Request', 'wporg-plugins' ), 83 'guideline-violation' => __( 'Guideline Violation', 'wporg-plugins' ), 84 'licensing-trademark-violation' => __( 'Licensing/Trademark Violation', 'wporg-plugins' ), 85 'merged-into-core' => __( 'Merged into Core', 'wporg-plugins' ), 86 ); 87 } 88 89 /** 68 90 * Displays the Plugin Status control in the Publish metabox. 69 91 */ … … 81 103 $statuses = Status_Transitions::get_allowed_transitions( $post->post_status ); 82 104 } 105 106 $close_reasons = self::get_close_reasons(); 107 $close_reason = (string) get_post_meta( $post->ID, '_close_reason', true ); 108 109 if ( isset( $close_reasons[ $close_reason ] ) ) { 110 $reason_label = $close_reasons[ $close_reason ]; 111 $reason_unknown = false; 112 } else { 113 $reason_label = _x( 'Unknown', 'unknown close reason', 'wporg-plugins' ); 114 $reason_unknown = true; 115 } 83 116 ?> 84 117 <div class="misc-pub-section misc-pub-plugin-status"> … … 86 119 <strong id="plugin-status-display"><?php echo esc_html( get_post_status_object( $post->post_status )->label ); ?></strong> 87 120 121 <?php if ( 'closed' === $post->post_status ) : ?> 122 123 <p><?php printf( __( 'Close Reason: %s', 'wporg-plugins' ), '<strong>' . $reason_label . '</strong>' ); ?></p> 124 125 <?php elseif ( 'disabled' === $post->post_status ) : ?> 126 127 <p><?php printf( __( 'Disable Reason: %s', 'wporg-plugins' ), '<strong>' . $reason_label . '</strong>' ); ?></p> 128 129 <?php endif; ?> 130 131 <?php if ( 132 ( in_array( 'closed', $statuses, true ) || in_array( 'disabled', $statuses, true ) ) 133 && 134 ! in_array( $post->post_status, array( 'closed', 'disabled' ) ) || $reason_unknown 135 ) : ?> 136 137 <p> 138 <label for="close_reason"><?php _e( 'Close/Disable Reason:', 'wporg-plugins' ); ?></label> 139 <select name="close_reason" id="close_reason"> 140 <?php foreach ( $close_reasons as $key => $label ) : ?> 141 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $close_reason ); ?>><?php echo esc_html( $label ); ?></option> 142 <?php endforeach; ?> 143 </select> 144 </p> 145 146 <?php endif; ?> 147 88 148 <?php foreach ( $statuses as $status ) : ?> 149 89 150 <p><button type="submit" name="post_status" value="<?php echo esc_attr( $status ); ?>" class="button set-plugin-status"> 90 151 <?php echo self::get_status_button_label( $status ); ?> 91 152 </button></p> 153 92 154 <?php endforeach; ?> 93 155 </div><!-- .misc-pub-section --><?php
Note: See TracChangeset
for help on using the changeset viewer.