if file_exists / get_theme_data
-
Hi guys and girls,
I am trying to set up a function for a theme options panel to look up the version on a remote site to determine whether a new version is available.
I tried simply calling the get_theme_data function but quickly discovered that if the file doesn’t exist (e.g. if the remote site is down) it returns every page in the local site as error 500 – internal server error.
My solution was to use this code:
$remote_version_url = 'https://www.jamesmorrison.me/style-test.css'; if ( file_exists($remote_version_url) ) { $remote_theme_data = get_theme_data($remote_version_url); $remote_version = $remote_theme_data['Version']; } else { $remote_version = "0"; // ensures that update message is not shown }
to ensure that the file is looked up before processing the data, but the file always shows as not found (even though it exists).
Have I missed something obvious or is there an error with the code?
Many thanks for any help!
James
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘if file_exists / get_theme_data’ is closed to new replies.