/** * AJAX callback to import settings from a JSON encoded text file. * * @access private * @since 8.3 * @static */ public static function importSettings() { check_ajax_referer('import_settings'); if (!current_user_can('manage_options')) { wp_send_json(__('You do not have sufficient permissions to import the settings.', 'connections')); } if ('json' != pathinfo($_FILES['import_file']['name'], PATHINFO_EXTENSION)) { wp_send_json(__('Please upload a .json file.', 'connections')); } $file = $_FILES['import_file']['tmp_name']; if (empty($file)) { wp_send_json(__('Please select a file to import.', 'connections')); } $json = file_get_contents($file); $result = cnSettingsAPI::import($json); if (TRUE === $result) { wp_send_json(__('Settings have been imported.', 'connections')); } else { wp_send_json($result); } }