← All changes
|
json-endpoints/class.wpcom-json-api-update-comment-endpoint.php
+10
-0
13.3.3
→
16.3-a.1
View file →
| @@ -10,8 +10,12 @@ | ||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | use Automattic\Jetpack\Status; |
| 13 | 13 | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit( 0 ); | |
| 16 | +} | |
| 17 | + | |
| 14 | 18 | new WPCOM_JSON_API_Update_Comment_Endpoint( |
| 15 | 19 | array( |
| 16 | 20 | 'description' => 'Create a comment on a post.', |
| 17 | 21 | 'group' => 'comments', |
| @@ -147,8 +151,10 @@ | ||
| 147 | 151 | ); |
| 148 | 152 | |
| 149 | 153 | /** |
| 150 | 154 | * Update comments endpoint class. |
| 155 | + * | |
| 156 | + * @phan-constructor-used-for-side-effects | |
| 151 | 157 | */ |
| 152 | 158 | class WPCOM_JSON_API_Update_Comment_Endpoint extends WPCOM_JSON_API_Comment_Endpoint { |
| 153 | 159 | /** |
| 154 | 160 | * WPCOM_JSON_API_Update_Comment_Endpoint constructor. |
| @@ -308,8 +314,12 @@ | ||
| 308 | 314 | 'comment_content' => $input['content'], |
| 309 | 315 | 'comment_parent' => $comment_parent_id, |
| 310 | 316 | 'comment_type' => 'comment', |
| 311 | 317 | ); |
| 318 | + | |
| 319 | + if ( ! empty( $this->api->token_details['user']['user_ip'] ) && filter_var( $this->api->token_details['user']['user_ip'], FILTER_VALIDATE_IP ) ) { | |
| 320 | + $insert['comment_author_IP'] = $this->api->token_details['user']['user_ip']; | |
| 321 | + } | |
| 312 | 322 | |
| 313 | 323 | if ( $comment_parent_id ) { |
| 314 | 324 | if ( '0' === $comment_parent->comment_approved && current_user_can( 'edit_comment', $comment_parent->comment_ID ) ) { |
| 315 | 325 | wp_set_comment_status( $comment_parent->comment_ID, 'approve' ); |