/** * Loads the import-data into the self::$import_data property. * The data was prepared by the import-preview screen. * Populates the response object. * * @since 2.0 * @param object $req Initial response object for JSON response. * @return object Updated response object. */ private function prepare_import_data($req) { $data = json_decode(base64_decode(@$_POST['import_data']), true); if (is_array($data['meta']) && is_array($data['sidebars']) && is_array($data['options']) && is_array($data['widgets']) && is_array($data['categories'])) { $data['ignore'] = array(); self::$import_data = $data; // Remove details that does not exist on current blog. $this->prepare_data(); // "selected_data" only contains the items that were selected for import. $this->selected_data = self::$import_data; unset($this->selected_data['meta']); unset($this->selected_data['categories']); unset($this->selected_data['ignore']); if (!isset($_POST['import_plugin_config'])) { unset($this->selected_data['options']); } if (!isset($_POST['import_widgets'])) { unset($this->selected_data['widgets']); } else { foreach ($this->selected_data['widgets'] as $id => $widgets) { $key = 'import_sb_' . $id; if (!isset($_POST[$key])) { unset($this->selected_data['widgets'][$id]); } } } foreach ($this->selected_data['sidebars'] as $id => $sidebar) { $key = 'import_sb_' . $sidebar['id']; if (!isset($_POST[$key])) { unset($this->selected_data['sidebars'][$id]); } } // Finally: Import the config! $req = $this->do_import($req); } else { return self::req_err($req, __('Something unexpected happened and we could not finish ' . 'the import. Please try again.', CSB_LANG)); } return $req; }