- Timestamp:
- 11/23/2016 03:32:25 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r39342 r39348 568 568 569 569 if ( isset( $request['status'] ) ) { 570 $comment = get_comment( $comment_id ); 571 572 $this->handle_status_param( $request['status'], $comment ); 573 } 570 $this->handle_status_param( $request['status'], $comment_id ); 571 } 572 573 $comment = get_comment( $comment_id ); 574 575 /** 576 * Fires after a comment is created or updated via the REST API. 577 * 578 * @since 4.7.0 579 * 580 * @param WP_Comment $comment Inserted or updated comment object. 581 * @param WP_REST_Request $request Request object. 582 * @param bool $creating True when creating a comment, false 583 * when updating. 584 */ 585 do_action( 'rest_insert_comment', $comment, $request, true ); 574 586 575 587 $schema = $this->get_item_schema(); … … 583 595 } 584 596 585 $comment = get_comment( $comment_id );586 587 597 $fields_update = $this->update_additional_fields_for_object( $comment, $request ); 588 598 … … 601 611 $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment_id ) ) ); 602 612 603 /**604 * Fires after a comment is created or updated via the REST API.605 *606 * @since 4.7.0607 *608 * @param array $comment Comment as it exists in the database.609 * @param WP_REST_Request $request The request sent to the API.610 * @param bool $creating True when creating a comment, false when updating.611 */612 do_action( 'rest_insert_comment', $comment, $request, true );613 613 614 614 return $response; … … 667 667 if ( empty( $prepared_args ) && isset( $request['status'] ) ) { 668 668 // Only the comment status is being changed. 669 $change = $this->handle_status_param( $request['status'], $ comment);669 $change = $this->handle_status_param( $request['status'], $id ); 670 670 671 671 if ( ! $change ) { … … 696 696 697 697 if ( isset( $request['status'] ) ) { 698 $this->handle_status_param( $request['status'], $comment ); 699 } 700 } 698 $this->handle_status_param( $request['status'], $id ); 699 } 700 } 701 702 $comment = get_comment( $id ); 703 704 /* This action is documented in lib/endpoints/class-wp-rest-comments-controller.php */ 705 do_action( 'rest_insert_comment', $comment, $request, false ); 701 706 702 707 $schema = $this->get_item_schema(); … … 710 715 } 711 716 712 $comment = get_comment( $id );713 714 717 $fields_update = $this->update_additional_fields_for_object( $comment, $request ); 715 718 … … 721 724 722 725 $response = $this->prepare_item_for_response( $comment, $request ); 723 724 /* This action is documented in lib/endpoints/class-wp-rest-comments-controller.php */725 do_action( 'rest_insert_comment', $comment, $request, false );726 726 727 727 return rest_ensure_response( $response ); … … 1434 1434 * 1435 1435 * @param string|int $new_status New comment status. 1436 * @param WP_Comment $comment Comment data.1436 * @param int $comment_id Comment ID. 1437 1437 * @return bool Whether the status was changed. 1438 1438 */ 1439 protected function handle_status_param( $new_status, $comment ) {1440 $old_status = wp_get_comment_status( $comment ->comment_ID);1439 protected function handle_status_param( $new_status, $comment_id ) { 1440 $old_status = wp_get_comment_status( $comment_id ); 1441 1441 1442 1442 if ( $new_status === $old_status ) { … … 1448 1448 case 'approve': 1449 1449 case '1': 1450 $changed = wp_set_comment_status( $comment ->comment_ID, 'approve' );1450 $changed = wp_set_comment_status( $comment_id, 'approve' ); 1451 1451 break; 1452 1452 case 'hold': 1453 1453 case '0': 1454 $changed = wp_set_comment_status( $comment ->comment_ID, 'hold' );1454 $changed = wp_set_comment_status( $comment_id, 'hold' ); 1455 1455 break; 1456 1456 case 'spam' : 1457 $changed = wp_spam_comment( $comment ->comment_ID);1457 $changed = wp_spam_comment( $comment_id ); 1458 1458 break; 1459 1459 case 'unspam' : 1460 $changed = wp_unspam_comment( $comment ->comment_ID);1460 $changed = wp_unspam_comment( $comment_id ); 1461 1461 break; 1462 1462 case 'trash' : 1463 $changed = wp_trash_comment( $comment ->comment_ID);1463 $changed = wp_trash_comment( $comment_id ); 1464 1464 break; 1465 1465 case 'untrash' : 1466 $changed = wp_untrash_comment( $comment ->comment_ID);1466 $changed = wp_untrash_comment( $comment_id ); 1467 1467 break; 1468 1468 default :
Note: See TracChangeset
for help on using the changeset viewer.