module = $module;
// vars
$this->name = $this->module->get_import_tool();
$this->title = $this->module->get_message('import_title');
parent::__construct();
}
/**
* html
*
* @return void
*/
function html(){
?>
module->get_message('import_description'); ?>
__('Select File', 'acf'),
'type' => 'file',
'name' => 'acf_import_file',
'value' => false,
'uploader' => 'basic',
));
?>
validate_file();
if(!$json){
return;
}
$ids = array();
// Loop over json
foreach($json as $key => $item){
// prior 0.9
// old import had name as key
if(!is_numeric($key) && !isset($item['name'])){
$item['name'] = $key;
}
// validate
// todo: remove
//$item = $this->module->validate_item($item);
//$item = $this->module->prepare_item_for_import($item);
// search database for existing item
$post = $this->module->get_item_post($item['name']);
if($post){
$item['ID'] = $post->ID;
}
// import item
$item = $this->module->import_item($item);
// append message
$ids[] = $item['ID'];
}
if(empty($ids)){
return;
}
// Count total
$total = count($ids);
$text = $this->module->get_message('import_success_single');
if($total > 1){
$text = sprintf($this->module->get_message('import_success_multiple'), $total);
}
// Add links to text
$links = array();
foreach($ids as $id){
$links[] = '