<?php /******************************************************************************/ /******************************************************************************/ global $wpdb; $themeContext = 'ft'; $themeOptionPrefix = 'ft_option'; /***/ $dummyContentFile = array(array('path' => get_template_directory() . '/dummy_content/content.part0.xml'), array('path' => get_template_directory() . '/dummy_content/content.part1.xml'), array('path' => get_template_directory() . '/dummy_content/content.part2.xml'), array('path' => get_template_directory() . '/dummy_content/content.part3.xml'), array('path' => get_template_directory() . '/dummy_content/content.part4.xml'), array('path' => get_template_directory() . '/dummy_content/content.part5.xml'), array('path' => get_template_directory() . '/dummy_content/content.part6.xml'), array('path' => get_template_directory() . '/dummy_content/content.part7.xml'), array('path' => get_template_directory() . '/dummy_content/content.part8.xml'), array('path' => get_template_directory() . '/dummy_content/content.part9.xml'), array('path' => get_template_directory() . '/dummy_content/content.part10.xml'), array('path' => get_template_directory() . '/dummy_content/content.part11.xml'), array('path' => get_template_directory() . '/dummy_content/content.part12.xml'), array('path' => get_template_directory() . '/dummy_content/content.part13.xml'), array('path' => get_template_directory() . '/dummy_content/content.part14.xml'), array('path' => get_template_directory() . '/dummy_content/content.part15.xml'), array('path' => get_template_directory() . '/dummy_content/content.part16.xml'), array('path' => get_template_directory() . '/dummy_content/content.part17.xml'), array('path' => get_template_directory() . '/dummy_content/content.part18.xml'), array('path' => get_template_directory() . '/dummy_content/content.part19.xml'), array('path' => get_template_directory() . '/dummy_content/content.part20.xml'), array('path' => get_template_directory() . '/dummy_content/content.part21.xml'), array('path' => get_template_directory() . '/dummy_content/content.part22.xml'), array('path' => get_template_directory() . '/dummy_content/content.part23.xml'), array('path' => get_template_directory() . '/dummy_content/content.part24.xml'), array('path' => get_template_directory() . '/dummy_content/content.part25.xml'), array('path' => get_template_directory() . '/dummy_content/content.part26.xml'), array('path' => get_template_directory() . '/dummy_content/content.part27.xml'), array('path' => get_template_directory() . '/dummy_content/content.part28.xml'), array('path' => get_template_directory() . '/dummy_content/content.part29.xml'), array('path' => get_template_directory() . '/dummy_content/content.part30.xml'), array('path' => get_template_directory() . '/dummy_content/content.part31.xml'), array('path' => get_template_directory() . '/dummy_content/content.part32.xml'), array('path' => get_template_directory() . '/dummy_content/content.part33.xml'), array('path' => get_template_directory() . '/dummy_content/content.part34.xml'), array('path' => get_template_directory() . '/dummy_content/content.part35.xml'), array('path' => get_template_directory() . '/dummy_content/content.part36.xml'), array('path' => get_template_directory() . '/dummy_content/content.part37.xml'), array('path' => get_template_directory() . '/dummy_content/content.part38.xml'), array('path' => get_template_directory() . '/dummy_content/content.part39.xml'), array('path' => get_template_directory() . '/dummy_content/content.part40.xml'), array('path' => get_template_directory() . '/dummy_content/content.part41.xml'), array('path' => get_template_directory() . '/dummy_content/content.part42.xml'), array('path' => get_template_directory() . '/dummy_content/content.part43.xml')); if (TIPlugin::isActive('woocommerce/woocommerce.php')) { array_push($dummyContentFile, array('path' => get_template_directory() . '/dummy_content/woocommerce.xml')); } TIData::set('value', 'dummy_content_file', $dummyContentFile); /***/ TIData::set('value', 'widget_settings_file', array(array('path' => get_template_directory() . '/dummy_content/widget_settings.json'))); /***/ TIData::set('meta', 'post_menu', array('post_title' => 'Home - Scrolling One Page', 'post_type' => 'page', 'menu_title' => 'Scrolling One Page', 'meta_name' => 'menu_top')); /***/ TIData::set('plugin_revslider', 'path', get_template_directory() . '/dummy_content/revslider_1.zip'); TIData::set('plugin_revslider', 'font', array(array('url' => 'Lato:600,400,300,900,400italic', 'handle' => 'lato'), array('url' => 'Handlee', 'handle' => 'handlee'))); /***/ TIData::set('plugin_timetable', 'sql', "INSERT INTO " . $wpdb->base_prefix . "event_hours(event_hours_id,event_id,weekday_id,start,end,tooltip,before_hour_text,after_hour_text,category) VALUES\n(152, 512, 506, '10:30:00', '11:00:00', '', 'Learning', '', ''),\n(159, 521, 502, '10:00:00', '10:30:00', '', 'Play Time', '', ''),\n(153, 511, 502, '09:30:00', '10:00:00', '', 'Learning', '', ''),\n(155, 512, 505, '10:30:00', '11:00:00', '', 'Learning', '', ''),\n(164, 523, 506, '09:30:00', '10:30:00', '', 'Learning', 'Class Educator - Angelica Watson', ''),\n(46, 507, 505, '08:00:00', '08:30:00', '', 'Arrival & Dismissal', '', ''),\n(45, 507, 504, '08:00:00', '08:30:00', '', 'Arrival & Dismissal', '', ''),\n(44, 507, 502, '08:00:00', '08:30:00', '', 'Arrival & Dismissal', '', ''),\n(79, 511, 503, '09:30:00', '10:00:00', '', 'Learning', '', ''),\n(165, 516, 503, '11:00:00', '12:30:00', '', 'Play Time', '', ''),\n(161, 517, 506, '11:00:00', '12:30:00', '', 'Learning', '', ''),\n(142, 513, 506, '13:00:00', '15:00:00', '', 'Play Time', 'City Zoo Trip', ''),\n(109, 517, 504, '13:00:00', '14:00:00', '', 'Learning', '', ''),\n(167, 513, 505, '11:00:00', '12:30:00', '', 'Play Time', '', ''),\n(130, 521, 505, '08:00:00', '08:30:00', '', 'Play Time', '', ''),\n(169, 522, 503, '10:30:00', '11:00:00', '', 'Learning', '', ''),\n(170, 510, 504, '09:30:00', '10:15:00', '', 'Play Time', 'Whole Group', ''),\n(34, 518, 502, '17:00:00', '17:30:00', '', '', '', ''),\n(35, 518, 503, '17:00:00', '17:30:00', '', '', '', ''),\n(127, 508, 504, '08:00:00', '08:30:00', '', 'Play Time', '', ''),\n(39, 509, 502, '09:00:00', '09:30:00', '', 'Meals', '', ''),\n(166, 522, 505, '09:30:00', '10:00:00', '', 'Learning', '', ''),\n(40, 509, 504, '09:00:00', '09:30:00', '', 'Meals', '', ''),\n(41, 509, 505, '09:00:00', '09:30:00', '', 'Meals', '', ''),\n(42, 509, 503, '09:00:00', '09:30:00', '', 'Meals', '', ''),\n(43, 509, 506, '09:00:00', '09:30:00', '', 'Meals', '', ''),\n(47, 507, 503, '08:00:00', '08:30:00', '', 'Arrival & Dismissal', '', ''),\n(48, 507, 506, '08:00:00', '08:30:00', '', 'Arrival & Dismissal', '', ''),\n(150, 520, 502, '13:00:00', '14:30:00', '', 'Exercises', 'Yoga For Kids', ''),\n(119, 523, 505, '08:30:00', '09:00:00', '', 'Learning', '', ''),\n(131, 524, 504, '08:30:00', '09:00:00', '', 'Play Time', '', ''),\n(129, 519, 503, '08:30:00', '09:00:00', '', 'Exercises', '', ''),\n(94, 515, 502, '12:30:00', '13:00:00', '', 'Meals', '', ''),\n(158, 508, 506, '08:00:00', '09:00:00', '', 'Play Time', 'With Special Guest Ruth Williams', ''),\n(196, 845, 502, '09:00:00', '09:30:00', '', '', 'Water or Milk', ''),\n(88, 523, 503, '10:00:00', '10:30:00', '', 'Learning', '', ''),\n(96, 515, 504, '12:30:00', '13:00:00', '', 'Meals', '', ''),\n(95, 515, 503, '12:30:00', '13:00:00', '', 'Meals', '', ''),\n(149, 520, 505, '13:00:00', '14:30:00', '', 'Exercises', 'Exercises With Mike Morgan', ''),\n(122, 510, 505, '10:00:00', '10:30:00', '', 'Play Time', '', ''),\n(97, 515, 505, '12:30:00', '13:00:00', '', 'Meals', '', ''),\n(98, 515, 506, '12:30:00', '13:00:00', '', 'Meals', '', ''),\n(125, 508, 503, '08:00:00', '08:30:00', '', 'Play Time', '', ''),\n(107, 514, 504, '14:00:00', '15:00:00', '', 'Learning', '', ''),\n(108, 514, 503, '14:00:00', '15:00:00', '', 'Learning', '', ''),\n(110, 517, 503, '13:00:00', '14:00:00', '', 'Learning', '', ''),\n(168, 513, 503, '11:00:00', '12:30:00', '', 'Play Time', '', ''),\n(157, 508, 502, '08:00:00', '09:00:00', '', 'Play Time', 'Individual Welcome, Self Activities', ''),\n(163, 522, 504, '10:30:00', '12:30:00', '', 'Learning', 'Class Educator - Marta Smith', ''),\n(198, 856, 506, '15:00:00', '15:15:00', '', '', 'Water and Yoghurt', ''),\n(195, 846, 503, '09:00:00', '09:30:00', '', '', 'Water or Milk', ''),\n(194, 847, 504, '09:00:00', '09:30:00', '', '', 'Water or Milk', ''),\n(211, 849, 502, '12:30:00', '13:00:00', '', '', 'Apple and Cheese, Water, Puree Vegies', ''),\n(209, 851, 504, '12:30:00', '13:00:00', '', '', 'Apple and Cheese, Water, Puree Vegies', ''),\n(204, 858, 503, '16:00:00', '16:15:00', '', '', 'Water or Juice', ''),\n(203, 858, 505, '16:00:00', '16:15:00', '', '', 'Water or Juice', ''),\n(201, 853, 502, '15:00:00', '15:15:00', '', '', 'Water and Yoghurt', ''),\n(200, 854, 503, '15:00:00', '15:15:00', '', '', 'Water and Yoghurt', ''),\n(199, 855, 504, '15:00:00', '15:15:00', '', '', 'Water and Yoghurt', ''),\n(210, 851, 506, '12:30:00', '13:00:00', '', '', 'Apple and Cheese, Water, Puree Vegies', ''),\n(208, 852, 505, '12:30:00', '13:00:00', '', '', 'Apple and Cheese, Water, Puree Vegies', ''),\n(206, 857, 506, '16:00:00', '16:15:00', '', '', 'Water or Juice', ''),\n(205, 857, 502, '16:00:00', '16:15:00', '', '', 'Water or Juice', ''),\n(192, 850, 503, '12:30:00', '13:00:00', '', '', 'Apple and Cheese, Water, Puree Vegies', ''),\n(193, 848, 506, '09:00:00', '09:30:00', '', '', 'Water or Milk', ''),\n(197, 845, 505, '09:00:00', '09:30:00', '', '', 'Water or Milk', ''),\n(202, 853, 505, '15:00:00', '15:15:00', '', '', 'Water and Yoghurt', ''),\n(207, 857, 504, '16:00:00', '16:15:00', '', '', 'Water or Juice', '')"); /***/ TIData::set('post_id', $themeOptionPrefix . '_widget_area_sidebar_woocommerce', array('title' => 'Shop', 'postType' => $themeContext . '_widget_area')); TIData::set('post_id', $themeOptionPrefix . '_widget_area_footer', array('title' => 'Footer', 'postType' => $themeContext . '_widget_area')); TIData::set('post_id', $themeOptionPrefix . '_widget_area_footer_woocommerce', array('title' => 'Footer', 'postType' => $themeContext . '_widget_area')); TIData::set('term_id', $themeOptionPrefix . '_menu_top', array('title' => 'Main', 'taxonomy' => 'nav_menu')); TIData::set('term_id', $themeOptionPrefix . '_menu_top_woocommerce', array('title' => 'Main', 'taxonomy' => 'nav_menu')); TIData::set('path', $themeOptionPrefix . '_header_background_image_src', array('title' => 'pattern', 'postType' => 'attachment')); /***/ TIData::set('post_id', $themeOptionPrefix . '_blog_category_post_id', array('title' => 'Blog Right Sidebar', 'postType' => 'page'));
function installSampleData() { error_reporting(E_ALL); ob_start(); ob_clean(); $this->code = 0; $this->buffer = null; $dataImport = array(); if (array_key_exists('code', $_POST)) { $this->code = (int) $_POST['code']; } if (array_key_exists('buffer', $_POST)) { $this->buffer = stripslashes($_POST['buffer']); } if (array_key_exists('data_import', $_POST)) { $dataImport = (array) $_POST['data_import']; } if (count($dataImport) == 0) { $this->createResponse(__('Please select at least one option of data which need to be imported.', PLUGIN_THEME_INSTALLER_DOMAIN), true); } global $ti_data; if (!ini_get('safe_mode')) { set_time_limit(0); ini_set('memory_limit', '512M'); } if (in_array(1, $dataImport)) { /***/ if (array_key_exists('plugin_timetable', $ti_data)) { if ($this->checkCode(10000)) { global $wpdb; $wpdb->query($ti_data['plugin_timetable']['sql']); $this->createResponse(null, false, 10001); } } /***/ if (array_key_exists('plugin_revslider', $ti_data)) { if (class_exists('RevSlider')) { if (array_key_exists('path', $ti_data['plugin_revslider'])) { if ($this->checkCode(10002)) { $Slider = new RevSlider(); $Slider->importSliderFromPost(true, true, $ti_data['plugin_revslider']['path']); $this->createResponse(null, false, 10003); } } } } /***/ if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', true); } TIInclude::includeFile(ABSPATH . 'wp-admin/includes/import.php'); $includeClass = array(array('class' => 'WP_Importer', 'path' => ABSPATH . 'wp-admin/includes/class-wp-importer.php'), array('class' => 'WP_Import', 'path' => PLUGIN_THEME_INSTALLER_LIBRARY_PATH . 'wordpress-importer.php')); foreach ($includeClass as $value) { $r = TIInclude::includeClass($value['path'], array($value['class'])); if ($r !== true) { break; } } if ($r === false) { $this->createResponse(__('Auto import feature couldn\'t be loaded. Please make import manually. You can find import dummy files in folder dummy_content.', PLUGIN_THEME_INSTALLER_DOMAIN)); } foreach ($ti_data['value']['dummy_content_file'] as $index => $value) { if ($this->checkCode(20000 + $index)) { $Import = new WP_Import(); $Import->fetch_attachments = true; $Import->import($value['path']); $this->createResponse(null, false, 20000 + $index + 1); } } /***/ if ($this->checkCode(30000)) { if (array_key_exists('meta', $ti_data)) { foreach ($ti_data['meta'] as $aIndex => $aValue) { switch ($aIndex) { case 'post_menu': $post = get_page_by_title($aValue['post_title'], 'OBJECT', $aValue['post_type']); if (is_null($post)) { break; } $menu = get_term_by('name', $aValue['menu_title'], 'nav_menu'); if ($menu === false) { break; } $meta = get_post_meta($post->ID, THEME_OPTION_PREFIX, true); if ($meta === false) { $meta = array(); } $meta[$aValue['meta_name']] = $menu->term_id; update_post_meta($post->ID, THEME_OPTION_PREFIX, $meta); break; } } } $this->createResponse(null, false, 40000); } } /**********************************************************************/ if ($this->checkCode(40000)) { if (in_array(2, $dataImport)) { if (array_key_exists('widget_settings_file', $ti_data['value'])) { foreach ($ti_data['value']['widget_settings_file'] as $file) { $json_data = json_decode(file_get_contents($file['path']), true); $sidebars_data = $json_data[0]; $widget_data = $json_data[1]; $current_sidebars = get_option('sidebars_widgets'); $new_widgets = array(); foreach ($sidebars_data as $import_sidebar => $import_widgets) { foreach ($import_widgets as $import_widget) { $title = trim(substr($import_widget, 0, strrpos($import_widget, '-'))); $index = trim(substr($import_widget, strrpos($import_widget, '-') + 1)); $current_widget_data = get_option('widget_' . $title); $new_widget_name = $this->getNewWidgetName($title, $index); $new_index = trim(substr($new_widget_name, strrpos($new_widget_name, '-') + 1)); if (!empty($new_widgets[$title]) && is_array($new_widgets[$title])) { while (array_key_exists($new_index, $new_widgets[$title])) { $new_index++; } } $current_sidebars[$import_sidebar][] = $title . '-' . $new_index; if (array_key_exists($title, $new_widgets)) { $new_widgets[$title][$new_index] = $widget_data[$title][$index]; $multiwidget = $new_widgets[$title]['_multiwidget']; unset($new_widgets[$title]['_multiwidget']); $new_widgets[$title]['_multiwidget'] = $multiwidget; } else { $current_widget_data[$new_index] = $widget_data[$title][$index]; $current_multiwidget = array_key_exists('_multiwidget', $current_widget_data) ? $current_widget_data['_multiwidget'] : 0; $new_multiwidget = isset($widget_data[$title]['_multiwidget']) ? $widget_data[$title]['_multiwidget'] : false; $multiwidget = $current_multiwidget != $new_multiwidget ? $current_multiwidget : 1; unset($current_widget_data['_multiwidget']); $current_widget_data['_multiwidget'] = $multiwidget; $new_widgets[$title] = $current_widget_data; } } } if (isset($new_widgets) && isset($current_sidebars)) { update_option('sidebars_widgets', $current_sidebars); foreach ($new_widgets as $title => $content) { $content = apply_filters('widget_data_import', $content, $title); update_option('widget_' . $title, $content); } } } $menu = get_terms('nav_menu'); foreach ($menu as $menuValue) { $option = get_option('widget_nav_menu'); if (is_array($option)) { foreach ($option as $optionIndex => $optionValue) { if (array_key_exists('title', $optionValue) && $optionValue['title'] == $menuValue->name) { $option[$optionIndex]['nav_menu'] = $menuValue->term_id; update_option('widget_nav_menu', $option); break; } } } } } } $this->createResponse(null, false, 50000); } /**********************************************************************/ if ($this->checkCode(50000)) { if (in_array(3, $dataImport)) { $option = array(); foreach ($ti_data as $aIndex => $aValue) { foreach ($aValue as $bIndex => $bValue) { $result = null; switch ($aIndex) { case 'path': if (array_key_exists('title', $bValue)) { $result = get_page_by_title($bValue['title'], 'OBJECT', $bValue['postType']); } if (is_null($result)) { break; } list($result) = wp_get_attachment_image_src($result->ID, 'full'); break; case 'post_id': if (array_key_exists('title', $bValue)) { $result = get_page_by_title($bValue['title'], 'OBJECT', $bValue['postType']); } if (is_null($result)) { break; } $result = $result->ID; break; case 'term_id': if (array_key_exists('title', $bValue)) { $result = get_term_by('name', $bValue['title'], $bValue['taxonomy']); } if ($result === false) { $result = null; break; } $result = $result->term_id; break; case 'value': if (array_key_exists('value', $bValue)) { $result = $bValue['value']; } break; case 'option': if ($bIndex == 'permalink_structure') { global $wp_rewrite; $wp_rewrite->set_permalink_structure($bValue); $result = null; } else { $result = $bValue; } break; } if (!is_null($result)) { if (preg_match('/^' . THEME_OPTION_PREFIX . '_/', $bIndex)) { $key = substr($bIndex, strlen(THEME_OPTION_PREFIX) + 1); $option[THEME_OPTION_PREFIX][$key] = $result; } else { $option['option'][$bIndex] = $result; } } } } foreach ($option as $aIndex => $aValue) { switch ($aIndex) { case 'option': foreach ($aValue as $bIndex => $bValue) { update_option($bIndex, $bValue); } break; case THEME_OPTION_PREFIX: if (class_exists('ThemeOption')) { ThemeOption::updateOption($option[THEME_OPTION_PREFIX]); } break; } } if (TIPlugin::isActive('woocommerce/woocommerce.php')) { $page = get_page_by_title('Shop'); if (!is_null($page)) { update_option('woocommerce_shop_page_id', $page->ID); } $page = get_page_by_title('My Account'); if (!is_null($page)) { update_option('woocommerce_myaccount_page_id', $page->ID); } $page = get_page_by_title('Cart'); if (!is_null($page)) { update_option('woocommerce_cart_page_id', $page->ID); } $page = get_page_by_title('Checkout'); if (!is_null($page)) { update_option('woocommerce_checkout_page_id', $page->ID); } $notice = array_diff(get_option('woocommerce_admin_notices', array()), array('install')); update_option('woocommerce_admin_notices', $notice); do_action('woocommerce_hide_install_notice'); } } } /**********************************************************************/ $page = get_page_by_title('Sample page', 'OBJECT', 'page'); if (!is_null($page)) { wp_delete_post($page->ID); } $post = get_page_by_title('Hello world!', 'OBJECT', 'post'); if (!is_null($post)) { wp_delete_post($post->ID); } /**********************************************************************/ if (function_exists('ti_complete')) { ti_complete(); } /**********************************************************************/ flush_rewrite_rules(); /**********************************************************************/ $this->createResponse(__('Seems,that demo data has been imported. To make sure if this process has been sucessfully completed,please check below content of buffer returned by external applications.', PLUGIN_THEME_INSTALLER_DOMAIN), false); }