BUG FIX - WP_Error when Google Maps not available
Sometimes, when editing/submiting a job, I was getting the error
"Cannot use object of type WP_Error as array on theme_geolocation.php line #31".
This error happen when for some reason, google maps cannot be reached and It returns an error instead of the map details on line #31 on the
theme_geolocation.php, file, here:
PHP Code:
$json = json_decode($result['body']);
To fix this I've replaced that line with the following:
PHP Code:
if ( array_key_exists('body', $result) )
$json = json_decode($result['body']);
else
$json = '';
To avoid further errors you can add the following
IF before the
foreach:
PHP Code:
if ($json)
foreach ($json->results as $result)
----------------------------------------------------------------------
Elo Criativo Owner & Developer - developed using
JobRoller
Need help with your theme? - Maybe I can
help