REST_Author.php
2 years ago
REST_Course.php
2 years ago
REST_Course_Announcement.php
2 years ago
REST_Lesson.php
2 years ago
REST_Quiz.php
1 year ago
REST_Rating.php
2 years ago
REST_Response.php
2 years ago
REST_Topic.php
2 years ago
RestAuth.php
2 months ago
REST_Response.php
36 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Ensure REST response |
| 4 | * |
| 5 | * @package Tutor\RestAPI |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 1.7.1 |
| 9 | */ |
| 10 | |
| 11 | namespace TUTOR; |
| 12 | |
| 13 | use WP_REST_Response; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | trait REST_Response { |
| 20 | |
| 21 | /** |
| 22 | * Send response |
| 23 | * |
| 24 | * @since 1.7.1 |
| 25 | * @since 2.7.0 renamed filter to tutor_rest_api_response like as pro API response. |
| 26 | * |
| 27 | * @param array $response The response data. |
| 28 | * |
| 29 | * @return WP_REST_Response |
| 30 | */ |
| 31 | public static function send( array $response ) { |
| 32 | $response = new WP_REST_Response( $response ); |
| 33 | return rest_ensure_response( apply_filters( 'tutor_rest_api_response', $response ) ); |
| 34 | } |
| 35 | } |
| 36 |