I have a question, is it possible to have the contents of a file from github? I have a file on github and I created a function to retrieve the contents of this file but it does not work.
Here is my function:
function process_import_file( $file ) {
// File exists?
if ( ! file_exists( $file ) ) {
return;
}
// Get file contents and decode.
$data = wp_remote_get( $file );
$data = json_decode( $data );
$this->import_data( $data );
}
The url github is like this: https://raw.githubusercontent.com/name/repo/master/file.json
When I open it in my browser, the content is displayed.
Can you help me?
Thank you a lot :)