WC_REST_Product_Reviews_Controller::handle_status_param()
Sets the comment_status of a given review object when creating or updating a review.
Метод класса: WC_REST_Product_Reviews_Controller{}
Хуков нет.
Возвращает
true|false
. Whether the status was changed.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->handle_status_param( $new_status, $id );
- $new_status(строка|int) (обязательный)
- New review status.
- $id(int) (обязательный)
- Review ID.
Список изменений
С версии 3.5.0 | Введена. |
Код WC_REST_Product_Reviews_Controller::handle_status_param() WC REST Product Reviews Controller::handle status param WC 9.2.3
protected function handle_status_param( $new_status, $id ) { $old_status = wp_get_comment_status( $id ); if ( $new_status === $old_status ) { return false; } switch ( $new_status ) { case 'approved': case 'approve': case '1': $changed = wp_set_comment_status( $id, 'approve' ); break; case 'hold': case '0': $changed = wp_set_comment_status( $id, 'hold' ); break; case 'spam': $changed = wp_spam_comment( $id ); break; case 'unspam': $changed = wp_unspam_comment( $id ); break; case 'trash': $changed = wp_trash_comment( $id ); break; case 'untrash': $changed = wp_untrash_comment( $id ); break; default: $changed = false; break; } return $changed; }