Я не понимаю эту функцию.Может ли кто-нибудь помочь мне понять это?
это функция, которая позволяет получить XML-файл, но я не понимаю детали кода, например, что такое setColumns или глобальная переменная?
function get_xml_import(){
global $xml_import;
if(defined("DOING_CRON") && DOING_CRON){
$history = new PMXI_File_List();
$history->setColumns('id', 'name', 'registered_on', 'path')->getBy(array('import_id' => (int) $_GET['import_id'] ), 'id DESC');
if ($history->count()){
$history_file = new PMXI_File_Record();
if($history_file->getBy('id', $history[0]['id'])){
$filePath = wp_all_import_get_absolute_path($history_file->path);
$string = file_get_contents( $filePath );
if($string){
try{
$xml_import = new SimpleXMLElement($string);
}catch (Exception $e){
die($e->getCode()." ".$e->getMessage());
}
}else{
die("Probleme filepath : ".$filePath);
}
return $xml_import;
}else{
die("history problem");
}
}else{
die("probleme");
}
}else{
//$import = PMXI_Plugin::$session;
$import = get_import_object();
if($string = file_get_contents( $import->filepath )){
$xml_import = new SimpleXMLElement($string);
return $xml_import;
}else{
return false;
}
}
}