| @@ -171,10 +171,9 @@ | ||
| 171 | 171 | $action_data['data']['editor_post_id'] = $editor_post_id; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | try { |
| 175 | - $data = $action_data['data'] ?? []; | |
| 176 | - $results = call_user_func( $this->ajax_actions[ $action_data['action'] ]['callback'], $data, $this ); | |
| 175 | + $results = call_user_func( $this->ajax_actions[ $action_data['action'] ]['callback'], $action_data['data'], $this ); | |
| 177 | 176 | |
| 178 | 177 | if ( false === $results ) { |
| 179 | 178 | $this->add_response_data( false ); |
| 180 | 179 | } else { |
| @@ -265,10 +264,19 @@ | ||
| 265 | 264 | while ( ob_get_status() ) { |
| 266 | 265 | ob_end_clean(); |
| 267 | 266 | } |
| 268 | 267 | |
| 269 | - header( 'Content-Type: application/json; charset=UTF-8' ); | |
| 270 | - echo $json; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 268 | + if ( function_exists( 'gzencode' ) ) { | |
| 269 | + $response = gzencode( $json ); | |
| 270 | + | |
| 271 | + header( 'Content-Type: application/json; charset=utf-8' ); | |
| 272 | + header( 'Content-Encoding: gzip' ); | |
| 273 | + header( 'Content-Length: ' . strlen( $response ) ); | |
| 274 | + | |
| 275 | + echo $response; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 276 | + } else { | |
| 277 | + echo $json; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 278 | + } | |
| 271 | 279 | |
| 272 | 280 | wp_die( '', '', [ 'response' => null ] ); |
| 273 | 281 | } |
| 274 | 282 | |