/** * Get all settings from file * @return array Array with fields settings from config file */ function jcf_get_all_settings_from_file() { $filename = jcf_get_settings_file_path(); if (file_exists($filename)) { return jcf_get_settings_from_file($filename); } else { return false; } }
/** * import fields callback */ function jcf_ajax_import_fields() { if (!empty($_POST['action']) && $_POST['action'] == 'jcf_import_fields') { if (!empty($_FILES['import_data']['name'])) { $path_info = pathinfo($_FILES['import_data']['name']); if ($path_info['extension'] == 'json') { $uploaddir = get_home_path() . "wp-content/uploads/"; $uploadfile = $uploaddir . basename($_FILES['import_data']['name']); if (is_readable($_FILES['import_data']['tmp_name'])) { $post_types = jcf_get_settings_from_file($_FILES['import_data']['tmp_name']); unlink($_FILES['import_data']['tmp_name']); if (empty($post_types)) { $notice = array('error', __('<strong>Import FAILED!</strong> File do not contain fields settings data..', JCF_TEXTDOMAIN)); } } else { $notice = array('error', __('<strong>Import FAILED!</strong> Can\'t read uploaded file.', JCF_TEXTDOMAIN)); } } else { $notice = array('error', __('<strong>Import FAILED!</strong> Please upload correct file format.', JCF_TEXTDOMAIN)); } } else { $notice = array('error', __('<strong>Import FAILED!</strong> Import file is missing.', JCF_TEXTDOMAIN)); } } if (!empty($notice)) { jcf_add_admin_notice($notice[0], $notice[1]); } header('Content-Type: text/html; charset=utf-8'); include JCF_ROOT . '/templates/import.tpl.php'; exit; }