using wp_remote_get instead of file_get_contents [duplicate]
IT Nursery
April 14, 2022
0
have run my theme through the Theme checker plugin and it seems upset about use of file_get_contents to get a json url. I’ve found posts saying i should use wp_remote_get. I’m currently decoding the url with the following:
WARNING: file_get_contents was found in the file.php possible file operations.
Is it just saying this because there is a function I could possibly use by wordpress or any other reasons? Also how would I use wp_remote_get. I tried a few variations, mostly replacing file_get_contents with wp_remote_get with no luck. Doesn’t seem to decode the url at all.
3 s 3
If you need to send a JSON response, then there’s a set of functions for that. In case you need that for an AJAX callback: