| @@ -39,9 +39,9 @@ | ||
| 39 | 39 | $license_key = berqwp_get_license_key(); |
| 40 | 40 | global $berq_log; |
| 41 | 41 | |
| 42 | 42 | if (empty($license_key_hash) || empty($license_key) || $license_key_hash !== md5($license_key)) { |
| 43 | - echo json_encode(['status' => 'error', 'msg' => 'Request authentication failed']); | |
| 43 | + echo wp_json_encode(['status' => 'error', 'msg' => 'Request authentication failed']); | |
| 44 | 44 | http_response_code(403); |
| 45 | 45 | exit; |
| 46 | 46 | } |
| 47 | 47 | |
| @@ -47,15 +47,15 @@ | ||
| 47 | 47 | |
| 48 | 48 | if ($status == 'success' && !empty($page_url) && $event == 'store_cache') { |
| 49 | 49 | |
| 50 | 50 | if (!bwp_can_optimize_page_url($page_url)) { |
| 51 | - echo json_encode(['status' => 'error', 'msg' => 'Invalid page url.']); | |
| 51 | + echo wp_json_encode(['status' => 'error', 'msg' => 'Invalid page url.']); | |
| 52 | 52 | exit; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | if (empty($html_url)) { |
| 56 | 56 | $berq_log->info("Empty html url: $page_url"); |
| 57 | - echo json_encode(['status' => 'error', 'msg' => 'Empty html url']); | |
| 57 | + echo wp_json_encode(['status' => 'error', 'msg' => 'Empty html url']); | |
| 58 | 58 | exit; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Download the HTML |
| @@ -64,9 +64,9 @@ | ||
| 64 | 64 | |
| 65 | 65 | // Check for errors |
| 66 | 66 | if (is_wp_error($response) || $response_code !== 200) { |
| 67 | 67 | $berq_log->info("Failed to download cache: $page_url"); |
| 68 | - echo json_encode(['status' => 'error', 'msg' => "Could not download html cache, $html_url"]); | |
| 68 | + echo wp_json_encode(['status' => 'error', 'msg' => "Could not download html cache, $html_url"]); | |
| 69 | 69 | exit; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $html = wp_remote_retrieve_body($response); |
| @@ -87,8 +87,8 @@ | ||
| 87 | 87 | if ($check_connection['status'] == 'error') { |
| 88 | 88 | delete_transient('berqwp_connection_status'); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - echo json_encode(['status' => 'success']); | |
| 91 | + echo wp_json_encode(['status' => 'success']); | |
| 92 | 92 | exit; |
| 93 | 93 | } |
| 94 | 94 | } |