| @@ -43,9 +43,9 @@ | ||
| 43 | 43 | |
| 44 | 44 | if ($status == 'success' && !empty($html_url)) { |
| 45 | 45 | |
| 46 | 46 | if (!bwp_can_optimize_page_url($page_url)) { |
| 47 | - echo json_encode(['status' => 'error', 'msg' => 'Invalid page url.']); | |
| 47 | + echo wp_json_encode(['status' => 'error', 'msg' => 'Invalid page url.']); | |
| 48 | 48 | exit; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Download the HTML |
| @@ -54,9 +54,9 @@ | ||
| 54 | 54 | |
| 55 | 55 | // Check for errors |
| 56 | 56 | if (is_wp_error($response) || $response_code !== 200) { |
| 57 | 57 | $berq_log->info("Failed to download cache: $page_url"); |
| 58 | - echo json_encode(['status' => 'error', 'msg' => 'Could not download html cache']); | |
| 58 | + echo wp_json_encode(['status' => 'error', 'msg' => 'Could not download html cache']); | |
| 59 | 59 | exit; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $html = wp_remote_retrieve_body($response); |
| @@ -64,9 +64,9 @@ | ||
| 64 | 64 | // Allow other plugins to modify cache html |
| 65 | 65 | $html = apply_filters('berqwp_cache_buffer', $html); |
| 66 | 66 | |
| 67 | 67 | if (empty($license_key_hash) || empty($license_key) || $license_key_hash !== md5($license_key)) { |
| 68 | - echo json_encode(['status' => 'error', 'msg' => 'Request authentication failed']); | |
| 68 | + echo wp_json_encode(['status' => 'error', 'msg' => 'Request authentication failed']); | |
| 69 | 69 | http_response_code(403); |
| 70 | 70 | exit; |
| 71 | 71 | } |
| 72 | 72 | |
| @@ -71,9 +71,9 @@ | ||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | if (empty($html)) { |
| 74 | 74 | $berq_log->info("Empty html cache: $page_url"); |
| 75 | - echo json_encode(['status' => 'error', 'msg' => 'Empty html cache']); | |
| 75 | + echo wp_json_encode(['status' => 'error', 'msg' => 'Empty html cache']); | |
| 76 | 76 | exit; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $cache = new Cache(null, bwp_get_cache_dir()); |
| @@ -89,8 +89,8 @@ | ||
| 89 | 89 | if ($check_connection['status'] == 'error') { |
| 90 | 90 | delete_transient('berqwp_connection_status'); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - echo json_encode(['status' => 'success']); | |
| 93 | + echo wp_json_encode(['status' => 'success']); | |
| 94 | 94 | exit; |
| 95 | 95 | } |
| 96 | 96 | } |