Changeset 6217 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php
- Timestamp:
- 12/03/2017 07:32:59 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php
r6026 r6217 1 1 <?php 2 2 3 namespace WordPressdotorg\Plugin_Directory\Admin; 4 3 5 use WordPressdotorg\Plugin_Directory\Tools; 4 6 use WordPressdotorg\Plugin_Directory\Tools\SVN; … … 11 13 */ 12 14 class Status_Transitions { 13 14 15 /** 15 16 * Fetch the instance of the Status_Transitions class. … … 32 33 * 33 34 * @param string $post_status Plugin post status. 35 * 34 36 * @return array An array of allowed post status transitions. 35 37 */ … … 72 74 * @param array $data An array of slashed post data. 73 75 * @param array $postarr An array of sanitized, but otherwise unmodified post data. 76 * 74 77 * @return array 75 78 */ … … 93 96 94 97 // ...or it's a white-listed status for plugin reviewers. 95 if ( current_user_can( 'plugin_review', $postarr['ID'] ) && in_array( $postarr['post_status'], array( 'new', 'pending' ) ) ) { 98 if ( current_user_can( 'plugin_review', $postarr['ID'] ) && in_array( $postarr['post_status'], array( 99 'new', 100 'pending', 101 ) ) ) { 96 102 return $data; 97 103 } … … 128 134 $this->rejected( $post->ID, $post ); 129 135 break; 136 case 'publish': 137 $this->clean_closed_date( $post->ID ); 138 break; 139 case 'disabled': 140 case 'closed': 141 $this->save_close_reason( $post->ID ); 142 break; 130 143 } 131 144 … … 141 154 */ 142 155 public function approved( $post_id, $post ) { 143 $attachments = get_attached_media( 'application/zip', $post_id );156 $attachments = get_attached_media( 'application/zip', $post_id ); 144 157 $plugin_author = get_user_by( 'id', $post->post_author ); 145 158 … … 178 191 179 192 /* translators: 1: plugin name, 2: plugin slug */ 180 $content 193 $content = sprintf( __( 'Congratulations, your plugin hosting request for %1$s has been approved. 181 194 182 195 Within one hour you will have access to your SVN repository with the WordPress.org username and password you used to log in and submit your request. Your username is case sensitive. … … 215 228 ); 216 229 230 $this->audit_log( 'Plugin approved.', $post_id ); 217 231 wp_mail( $plugin_author->user_email, $subject, $content, 'From: plugins@wordpress.org' ); 218 232 } … … 234 248 wp_update_post( array( 235 249 'ID' => $post_id, 236 'post_name' => sprintf( 'rejected-%s-rejected', $post->post_name ) 250 'post_name' => sprintf( 'rejected-%s-rejected', $post->post_name ), 237 251 ) ); 238 252 … … 242 256 243 257 /* translators: 1: plugin name, 2: plugins@wordpress.org */ 244 $content 258 $content = sprintf( __( 'Unfortunately your plugin submission for %1$s has been rejected from the WordPress Plugin Directory. 245 259 246 260 If you believe this to be in error, please email %2$s with your plugin attached as a zip and explain why you feel your plugin should be an exception. … … 253 267 ); 254 268 269 $this->audit_log( 'Plugin rejected.', $post_id ); 255 270 wp_mail( $email, $subject, $content, 'From: plugins@wordpress.org' ); 256 271 } … … 260 275 * 261 276 * @param string $dir Directory to search in. 277 * 262 278 * @return string 263 279 */ … … 279 295 return $plugin_root; 280 296 } 297 298 /** 299 * Deletes the plugin closed date meta field. 300 * 301 * @param integer $post_id Post ID. 302 */ 303 public function clean_closed_date( $post_id ) { 304 delete_post_meta( $post_id, 'plugin_closed_date' ); 305 delete_post_meta( $post_id, '_close_reason' ); 306 } 307 308 /** 309 * Save the reason for closing or disabling a plugin. 310 * 311 * @param int $post_id Post ID. 312 */ 313 public function save_close_reason( $post_id ) { 314 if ( ! isset( $_POST['close_reason'] ) ) { 315 return; 316 } 317 318 if ( ! current_user_can( 'plugin_approve', $post_id ) ) { 319 return; 320 } 321 322 $close_reason = sanitize_key( $_POST['close_reason'] ); 323 324 update_post_meta( $post_id, '_close_reason', $close_reason ); 325 update_post_meta( $post_id, 'plugin_closed_date', current_time( 'mysql' ) ); 326 327 $this->audit_log( sprintf( 'Plugin closed for: %s', $close_reason ), $post_id ); 328 } 329 330 /** 331 * Saves an audit_log comment for the plugin. 332 * 333 * @param string $message The message for the audit log. 334 * @param integer $post_id The Post ID. 335 */ 336 private function audit_log( $message, $post_id ) { 337 $comment = array( 338 'comment_type' => 'audit_log', 339 'comment_post_ID' => $post_id, 340 'comment_author' => get_current_user_id(), 341 'comment_content' => $message, 342 ); 343 wp_insert_comment( $comment ); 344 } 281 345 }
Note: See TracChangeset
for help on using the changeset viewer.