Skip to content

Commit 49edb01

Browse files
anomiexmatticbot
authored andcommitted
Add more missing json_encode flags (#46204)
The functions `wp_send_json()`, `wp_send_json_success()`, and `wp_send_json_error()` also have a `$flags` argument that defaults to 0. Given the nature of these functions (returning-and-exiting from ajax endpoints after setting the content type header), `JSON_UNESCAPED_SLASHES` is likely correct for all of them. Also there was one `wp_json_encode` missed, one done incorrectly in an unused test, and three added since the last PR. Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/20037516287 Upstream-Ref: Automattic/jetpack@6516416
1 parent 00299e6 commit 49edb01

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

wp-cache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,18 +378,18 @@ function wpsc_ajax_activate_boost() {
378378
check_ajax_referer( 'activate-boost' );
379379

380380
if ( ! isset( $_POST['source'] ) ) {
381-
wp_send_json_error( 'no source specified' );
381+
wp_send_json_error( 'no source specified', null, JSON_UNESCAPED_SLASHES );
382382
}
383383

384384
$source = sanitize_text_field( wp_unslash( $_POST['source'] ) );
385385
$result = activate_plugin( 'jetpack-boost/jetpack-boost.php' );
386386
if ( is_wp_error( $result ) ) {
387-
wp_send_json_error( $result->get_error_message() );
387+
wp_send_json_error( $result->get_error_message(), null, JSON_UNESCAPED_SLASHES );
388388
}
389389

390390
wpsc_notify_migration_to_boost( $source );
391391

392-
wp_send_json_success();
392+
wp_send_json_success( null, null, JSON_UNESCAPED_SLASHES );
393393
}
394394
add_action( 'wp_ajax_wpsc_activate_boost', 'wpsc_ajax_activate_boost' );
395395

@@ -3310,7 +3310,7 @@ function clear_post_supercache( $post_id ) {
33103310
*/
33113311
function wpsc_ajax_get_preload_status() {
33123312
$preload_status = wpsc_get_preload_status( true );
3313-
wp_send_json_success( $preload_status );
3313+
wp_send_json_success( $preload_status, null, JSON_UNESCAPED_SLASHES );
33143314
}
33153315
add_action( 'wp_ajax_wpsc_get_preload_status', 'wpsc_ajax_get_preload_status' );
33163316

0 commit comments

Comments
 (0)