Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save propertyhive/7ec7bcd9cf166f7e7516d33ed1f1c7cd to your computer and use it in GitHub Desktop.
Save propertyhive/7ec7bcd9cf166f7e7516d33ed1f1c7cd to your computer and use it in GitHub Desktop.
add_action( 'propertyhive_before_property_import_cron', 'download_caldes_xml' );
function download_caldes_xml()
{
$xml_url = 'https://example.com/path/to/your/caldes.xml'; // set to URL provided by Caldes
$local_dir = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/uploads/ph_import'; // change accordingly to your setup
// Local file path
$local_file = $local_dir . '/caldes.xml';
// Use file_get_contents to fetch the XML content
$xml_content = file_get_contents($xml_url);
// Check if the fetch was successful
if ($xml_content === FALSE) {
error_log('Failed to download the XML file from the specified URL.');
return;
}
// Write the content to the local file
$result = file_put_contents($local_file, $xml_content);
// Check if the write was successful
if ($result === FALSE) {
error_log('Failed to write the XML file to the local directory.');
} else {
error_log('XML file successfully downloaded and saved.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment