[ 'pubid' => $pubid, 'styleid' => $styleid, 'site' => get_site_url(), 'targetElement' => $targetElement, 'countKeywords' => $countKeywords, 'countSponsoredLinks' => $countSponsoredLinks, 'status' => $status, 'rewardData' => json_encode($rewardData), ], 'timeout' => 30, 'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', 'Accept' => 'application/json, text/plain, */*', 'Accept-Language' => 'en-US,en;q=0.9', 'Origin' => get_site_url(), 'Referer' => get_site_url(), ], 'sslverify' => true ]); if (is_wp_error($response)) { return false; } $response_code = wp_remote_retrieve_response_code($response); if ($response_code !== 200) { return false; } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); // Check if the JSON response is valid and has status = 1 if (!$data || !isset($data['status']) || $data['status'] != 1 || !isset($data['script'])) { return false; } // Return just the script portion from the JSON response return $data['script']; } }