$meta['_' . $meta_key] = array('parent' => 'meta_boxes', 'meta_key' => '_' . $meta_key, 'title' => $meta_boxes[$meta_key]['title'], 'name' => $meta_boxes[$meta_key]['name']); } elseif (!empty($comment_boxes[$meta_key]['name'])) { $meta['_' . $meta_key] = array('parent' => 'comment_boxes', 'meta_key' => '_' . $meta_key, 'title' => $comment_boxes[$meta_key]['title'], 'name' => $comment_boxes[$meta_key]['name']); } } $taxonomies = get_object_taxonomies('gtcd', 'objects'); //Build array of user import fields $importFields = array(); $importFile = $_POST['file-name']; if ($_POST['file-type'] == 'xml') { $fileData = file_get_contents(GTCDI_DIR . '/' . $importFile); $dom = new DomDocument(); $dom->loadXML($fileData); $xmlArray = gtcd_xml_to_array($dom); $importFields = gtcd_get_xpath($xmlArray, $_POST['file-path']); $importFields = gtcd_get_keys($importFields); } elseif ($_POST['file-type'] == 'csv') { $row = 1; if (($handle = fopen(GTCDI_DIR . '/' . $importFile, 'r')) !== FALSE) { while (($data = fgetcsv($handle, 1000, '|')) !== FALSE) { //get first line column names and break $importFields = $data; break; } fclose($handle); } } //create import fields drop down $options = ''; foreach ($importFields as $field) { $options .= '<option value="' . $field . '">' . $field . '</option>';
function gtcd_get_keys($arr) { $keys = array(); foreach ($arr as $key => $value) { array_push($keys, $key); if (is_array($value) && count($value) > 0) { $key = gtcd_get_keys($value); $keys = array_merge($keys, $key); } } return $keys; }