← All changes
|
json-endpoints/class.wpcom-json-api-comment-endpoint.php
+16
-1
13.9.2
→
16.3-a.1
View file →
| @@ -5,8 +5,13 @@ | ||
| 5 | 5 | * @todo - can this file be written without overriding global variables? |
| 6 | 6 | * |
| 7 | 7 | * @phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited |
| 8 | 8 | */ |
| 9 | + | |
| 10 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 11 | + exit( 0 ); | |
| 12 | +} | |
| 13 | + | |
| 9 | 14 | /** |
| 10 | 15 | * Comment endpoint class. |
| 11 | 16 | */ |
| 12 | 17 | abstract class WPCOM_JSON_API_Comment_Endpoint extends WPCOM_JSON_API_Endpoint { |
| @@ -70,9 +75,19 @@ | ||
| 70 | 75 | if ( ! $comment || is_wp_error( $comment ) ) { |
| 71 | 76 | return new WP_Error( 'unknown_comment', 'Unknown comment', 404 ); |
| 72 | 77 | } |
| 73 | 78 | |
| 74 | - $types = array( '', 'comment', 'pingback', 'trackback', 'review' ); | |
| 79 | + /** | |
| 80 | + * Filter the comment types that are allowed to be returned. | |
| 81 | + * | |
| 82 | + * @since 14.2 | |
| 83 | + * | |
| 84 | + * @module json-api | |
| 85 | + * | |
| 86 | + * @param array $types Array of comment types. | |
| 87 | + */ | |
| 88 | + $types = apply_filters( 'jetpack_json_api_comment_types', array( '', 'comment', 'pingback', 'trackback', 'review' ) ); | |
| 89 | + | |
| 75 | 90 | // @todo - can we make this comparison strict without breaking anything? |
| 76 | 91 | // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict |
| 77 | 92 | if ( ! in_array( $comment->comment_type, $types ) ) { |
| 78 | 93 | return new WP_Error( 'unknown_comment', 'Unknown comment', 404 ); |