Changeset 1382
- Timestamp:
- 03/06/2015 02:22:56 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r1379 r1382 276 276 */ 277 277 function wporg_themes_update_version_status( $post_id, $current_version, $new_status ) { 278 $meta = get_post_meta( $post_id, '_status', true ); 278 $meta = get_post_meta( $post_id, '_status', true ); 279 $old_status = $meta[ $current_version ]; 280 281 // Don't do anything when the status hasn't changed. 282 if ( $new_status == $old_status ) { 283 return; 284 } 279 285 280 286 switch ( $new_status ) { … … 303 309 * @param string $current_version The theme version that was updated. 304 310 * @param string $new_status The new status for that theme version. 311 * @param string $old_status The old status for that theme version. 305 312 */ 306 do_action( 'wporg_themes_update_version_status', $post_id, $current_version, $new_status );313 do_action( 'wporg_themes_update_version_status', $post_id, $current_version, $new_status, $old_status ); 307 314 308 315 /** … … 312 319 * @param int $post_id Post ID. 313 320 * @param string $current_version The theme version that was updated. 321 * @param string $old_status The old status for that theme version. 314 322 */ 315 do_action( "wporg_themes_update_version_{$new_status}", $post_id, $current_version );323 do_action( "wporg_themes_update_version_{$new_status}", $post_id, $current_version, $old_status ); 316 324 317 325 return update_post_meta( $post_id, '_status', $meta ); … … 325 333 * @param int $post_id 326 334 * @param string $version 327 */ 328 function wporg_themes_approve_version( $post_id, $version ) { 329 $post = get_post( $post_id ); 335 * @param string $old_status 336 */ 337 function wporg_themes_approve_version( $post_id, $version, $old_status ) { 338 $post = get_post( $post_id ); 339 340 wporg_themes_update_wpthemescom( $post->post_name, $version ); 341 342 /* 343 * Bail if we're activating an old version, the author does not need to be 344 * notified about that. 345 */ 346 if ( 'old' == $old_status ) { 347 return; 348 } 349 330 350 $ticket_id = wporg_themes_get_version_meta( $post_id, '_ticket_id', $version ); 331 351 $subject = $content = ''; … … 353 373 354 374 wp_mail( get_user_by( 'id', $post->post_author )->user_email, $subject, $content, 'From: themes@wordpress.org' ); 355 356 wporg_themes_update_wpthemescom( $post->post_name, $version ); 357 } 358 add_action( 'wporg_themes_update_version_live', 'wporg_themes_approve_version', 10, 2 ); 375 } 376 add_action( 'wporg_themes_update_version_live', 'wporg_themes_approve_version', 10, 3 ); 359 377 360 378 /** … … 382 400 } 383 401 add_action( 'wporg_themes_update_version_old', 'wporg_themes_close_version', 10, 2 ); 402 403 /** 404 * Rolls back a live theme version. 405 * 406 * If the rolledback version was live, it finds the previous live version and 407 * sets it live again. 408 * 409 * @param int $post_id 410 * @param string $version 411 * @param string $old_status 412 */ 413 function wporg_themes_rollback_version( $post_id, $current_version, $old_status ) { 414 // If the version wasn't live, there's nothing for us to do. 415 if ( 'live' != $old_status ) { 416 return; 417 } 418 419 if ( ! class_exists( 'Trac' ) ) { 420 require_once ABSPATH . WPINC . '/class-IXR.php'; 421 require_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php'; 422 require_once WPORGPATH . 'bb-theme/themes/lib/class-trac.php'; 423 } 424 425 // Check for tickets that were set to live previously. 426 $trac = new Trac( 'themetracbot', THEME_TRACBOT_PASSWORD, 'https://themes.trac.wordpress.org/login/xmlrpc' ); 427 $tickets = (array) $trac->ticket_query( add_query_arg( array( 428 'status' => 'closed', 429 'resolution' => 'live', 430 'keywords' => '~theme-' . get_post( $post_id )->post_name, 431 'order' => 'changetime', 432 'desc' => 1, 433 ) ) ); 434 $ticket = next( $tickets ); 435 436 // Bail if there is no prior live versions. 437 if ( ! $ticket ) { 438 return; 439 } 440 441 // Find the version number associated with the approved ticket. 442 $ticket_ids = get_post_meta( $post_id, '_ticket_id', true ); 443 $prev_version = array_search( $ticket, $ticket_ids ); 444 445 wporg_themes_update_version_status( $post_id, $prev_version, 'live' ); 446 } 447 add_action( 'wporg_themes_update_version_new', 'wporg_themes_rollback_version', 10, 3 ); 384 448 385 449 /**
Note: See TracChangeset
for help on using the changeset viewer.