/** * Prepopulate the current installation with a dummy content, if provided. * * @return void */ private function prepopulateInstallation() { $dummy_setup = THB_THEME_CONFIG_DIR . '/dummy/thb-dummy.thb-backup'; if (file_exists($dummy_setup)) { $backup = @file_get_contents($dummy_setup); $data = unserialize(base64_decode($backup)); if (isset($data['options'])) { thb_theme()->importOptions($data['options']); } if (isset($data['mods'])) { $theme = get_option('stylesheet'); update_option("theme_mods_{$theme}", $data['mods']); } if (isset($data['duplicable'])) { thb_duplicable_remove_all(); foreach ($data['duplicable'] as $row) { $row['meta'] = serialize($row['meta']); $row['value'] = serialize($row['value']); thb_duplicable_add($row); } } } }
/** * Import options and skin into the system. * * @param boolean $importOptions * @param boolean $importMods * @param boolean $importDuplicable */ function thb_import($importOptions = true, $importMods = true, $importDuplicable = true) { if (!empty($_FILES)) { foreach ($_FILES as $uploaded_file) { $file = thb_upload($uploaded_file); if (file_exists($file['file']['file'])) { $fileinfo = pathinfo($file['file']['file']); if ($fileinfo['extension'] == 'thb-backup') { $backup = @file_get_contents($file['file']['file']); $data = unserialize(base64_decode($backup)); $success = false; if ($importOptions && isset($data['options'])) { $thb_theme = thb_theme(); $thb_theme->importOptions($data['options']); $success = true; } if ($importMods && isset($data['mods'])) { $theme = get_option('stylesheet'); update_option("theme_mods_{$theme}", $data['mods']); $success = true; } if ($importDuplicable && isset($data['duplicable'])) { thb_duplicable_remove_all(); foreach ($data['duplicable'] as $itemKey => $datas) { foreach ($datas as $dat) { thb_duplicable_add($itemKey, $dat); } // thb_duplicable_add($itemKey, $da) // $row['meta'] = serialize($row['meta']); // $row['value'] = serialize($row['value']); // thb_duplicable_add($row); } $success = true; } if ($success) { $result = thb_system_raise_success(__('Data imported correctly', 'thb_text_domain')); } else { $result = thb_system_raise_error(__('No data imported', 'thb_text_domain')); } } else { $result = thb_system_raise_error(sprintf(__('Wrong file type. Only files with the following extensions are allowed: %s.', 'thb_text_domain'), '.thb-backup')); } unlink($file['file']['file']); } else { $result = thb_system_raise_error(__('Upload failed', 'thb_text_domain')); } thb_system_set_flashdata($result); } } }