function download()
 {
     $font = wp_remote_get('https://www.googleapis.com/webfonts/v1/webfonts?key=' . THEME_GOOGLE_FONT_KEY, array('sslverify' => false));
     ThemeOption::updateOption(array('font_google_time' => time()));
     if (is_wp_error($font)) {
         return false;
     }
     update_option(THEME_OPTION_PREFIX_FONT, $font['body']);
     return true;
 }
Exemplo n.º 2
0
 function adminOptionPanelSave()
 {
     $option = ThemeHelper::getPostOption();
     ThemeHelper::removeUIndex($option, 'maintenance_mode_user_id');
     $response = array('global' => array('error' => 1));
     $CSS = new ThemeCSS();
     $Blog = new ThemeBlog();
     $Notice = new ThemeNotice();
     $Easing = new ThemeEasing();
     $FancyBox = new ThemeFancybox();
     $Background = new ThemeBackground();
     $Validation = new ThemeValidation($Notice);
     $ResponsiveMode = new ThemeResponsiveMode($this->responsiveMode);
     $media = $ResponsiveMode->getMedia();
     $invalidValue = esc_html__('Invalid value', THEME_DOMAIN);
     /* Main */
     $Validation->notice('isNumber', array($option['header_enable'], 0, 1), array(ThemeHelper::getFormName('header_enable', false), $invalidValue));
     if (!array_key_exists($option['header_background_image_repeat'], $Background->backgroundRepeat)) {
         $Notice->addError(ThemeHelper::getFormName('header_background_image_repeat', false), $invalidValue);
     }
     if (!array_key_exists($option['header_background_image_size_1'], $Background->backgroundSize)) {
         $Notice->addError(ThemeHelper::getFormName('header_background_image_size_1', false), $invalidValue);
     }
     /* Blog */
     if (!in_array($option['blog_sort_field'], array_keys($Blog->sortPostBlogField))) {
         $Notice->addError(ThemeHelper::getFormName('blog_sort_field', false), $invalidValue);
     }
     if (!in_array($option['blog_sort_direction'], array_keys($Blog->sortDirection))) {
         $Notice->addError(ThemeHelper::getFormName('blog_sort_direction', false), $invalidValue);
     }
     $Validation->notice('isNumber', array($option['blog_automatic_excerpt_length'], 0, 999), array(ThemeHelper::getFormName('blog_automatic_excerpt_length', false), $invalidValue));
     /* Post */
     $Validation->notice('isNumber', array($option['post_category_visible'], 0, 1), array(ThemeHelper::getFormName('post_category_visible', false), $invalidValue));
     $Validation->notice('isNumber', array($option['post_author_visible'], 0, 1), array(ThemeHelper::getFormName('post_author_visible', false), $invalidValue));
     $Validation->notice('isNumber', array($option['post_tag_visible'], 0, 1), array(ThemeHelper::getFormName('post_tag_visible', false), $invalidValue));
     $Validation->notice('isNumber', array($option['post_comment_count_visible'], 0, 1), array(ThemeHelper::getFormName('post_comment_count_visible', false), $invalidValue));
     $Validation->notice('isNumber', array($option['post_navigation_visible'], 0, 1), array(ThemeHelper::getFormName('post_navigation_visible', false), $invalidValue));
     /* Plugins / Menu top */
     if (!in_array($option['menu_responsive_mode'], $this->responsiveMode)) {
         $Notice->addError(ThemeHelper::getFormName('menu_responsive_mode', false), $invalidValue);
     }
     $Validation->notice('isNumber', array($option['menu_sticky_enable'], 0, 1), array(ThemeHelper::getFormName('menu_sticky_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['menu_hide_scroll_enable'], 0, 1), array(ThemeHelper::getFormName('menu_hide_scroll_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['menu_animation_enable'], 0, 1), array(ThemeHelper::getFormName('menu_animation_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['menu_animation_speed_open'], 0, 99999), array(ThemeHelper::getFormName('menu_animation_speed_open', false), $invalidValue));
     $Validation->notice('isNumber', array($option['menu_animation_speed_close'], 0, 99999), array(ThemeHelper::getFormName('menu_animation_speed_close', false), $invalidValue));
     $Validation->notice('isNumber', array($option['menu_animation_delay'], 0, 99999), array(ThemeHelper::getFormName('menu_animation_delay', false), $invalidValue));
     $Validation->notice('isNumber', array($option['menu_scroll_animation_enable'], 0, 1), array(ThemeHelper::getFormName('menu_scroll_animation_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['menu_scroll_animation_speed'], 0, 99999), array(ThemeHelper::getFormName('menu_scroll_animation_speed', false), $invalidValue));
     if (!in_array($option['menu_scroll_animation_easing'], array_keys($Easing->easingType))) {
         $Notice->addError(ThemeHelper::getFormName('menu_scroll_animation_easing', false), $invalidValue);
     }
     /* Footer */
     $Validation->notice('isNumber', array($option['footer_enable'], 0, 1), array(ThemeHelper::getFormName('footer_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['footer_sticky_enable'], 0, 1), array(ThemeHelper::getFormName('footer_sticky_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['footer_top_enable'], 0, 1), array(ThemeHelper::getFormName('footer_top_enable', false), $invalidValue));
     if (!array_key_exists($option['footer_top_background_image_repeat'], $Background->backgroundRepeat)) {
         $Notice->addError(ThemeHelper::getFormName('footer_top_background_image_repeat', false), $invalidValue);
     }
     if (!array_key_exists($option['footer_top_background_image_size_1'], $Background->backgroundSize)) {
         $Notice->addError(ThemeHelper::getFormName('footer_top_background_image_size_1', false), $invalidValue);
     }
     $Validation->notice('isNumber', array($option['footer_bottom_enable'], 0, 1), array(ThemeHelper::getFormName('footer_bottom_enable', false), $invalidValue));
     /* Content copying */
     $Validation->notice('isNumber', array($option['right_click_enable'], 0, 1), array(ThemeHelper::getFormName('right_click_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['copy_selection_enable'], 0, 1), array(ThemeHelper::getFormName('copy_selection_enable', false), $invalidValue));
     /* Responsive mode */
     $Validation->notice('isNumber', array($option['responsive_mode_enable'], 0, 1), array(ThemeHelper::getFormName('responsive_mode_enable', false), $invalidValue));
     /* Go to page to */
     $Validation->notice('isNumber', array($option['go_to_page_top_enable'], 0, 1), array(ThemeHelper::getFormName('go_to_page_top_enable', false), $invalidValue));
     $Validation->notice('isNotEmpty', array($option['go_to_page_top_hash']), array(ThemeHelper::getFormName('go_to_page_top_hash', false), $invalidValue));
     $Validation->notice('isNumber', array($option['go_to_page_top_animation_enable'], 0, 1), array(ThemeHelper::getFormName('go_to_page_top_animation_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['go_to_page_top_animation_duration'], 0, 99999), array(ThemeHelper::getFormName('go_to_page_top_animation_duration', false), $invalidValue));
     if (!in_array($option['go_to_page_top_animation_easing'], array_keys($Easing->easingType))) {
         $Notice->addError(ThemeHelper::getFormName('go_to_page_top_animation_easing', false), $invalidValue);
     }
     /* Font */
     $font = array('base', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6');
     foreach ($font as $value) {
         foreach ($media as $mediaIndex => $mediaValue) {
             $Validation->notice('isNumber', array($option['font_' . $value . '_size_' . $mediaIndex], 1, 100), array(ThemeHelper::getFormName('font_' . $value . '_size_' . $mediaIndex, false), $invalidValue));
         }
         if (!in_array($option['font_' . $value . '_style'], array_keys($CSS->fontStyle))) {
             $Notice->addError(ThemeHelper::getFormName('font_' . $value . '_style', false), $invalidValue);
         }
         if (!in_array($option['font_' . $value . '_weight'], array_keys($CSS->fontWeight))) {
             $Notice->addError(ThemeHelper::getFormName('font_' . $value . '_weight', false), $invalidValue);
         }
     }
     /* Plugin / Fancybox for images */
     $Validation->notice('isNumber', array($option['fancybox_image_padding'], 0, 999), array(ThemeHelper::getFormName('fancybox_image_padding', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_margin'], 0, 999), array(ThemeHelper::getFormName('fancybox_image_margin', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_min_width'], 1, 9999), array(ThemeHelper::getFormName('fancybox_image_min_width', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_min_height'], 1, 9999), array(ThemeHelper::getFormName('fancybox_image_min_height', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_max_width'], 1, 9999), array(ThemeHelper::getFormName('fancybox_image_max_width', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_max_height'], 1, 9999), array(ThemeHelper::getFormName('fancybox_image_max_height', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_helper_button_enable'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_helper_button_enable', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_autoresize'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_autoresize', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_autocenter'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_autocenter', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_fittoview'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_fittoview', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_arrow'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_arrow', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_close_button'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_close_button', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_close_click'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_close_click', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_next_click'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_next_click', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_mouse_wheel'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_mouse_wheel', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_autoplay'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_autoplay', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_loop'], 0, 1), array(ThemeHelper::getFormName('fancybox_image_loop', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_playspeed'], 1, 99999), array(ThemeHelper::getFormName('fancybox_image_playspeed', false), $invalidValue));
     if (!in_array($option['fancybox_image_animation_effect_open'], array_keys($FancyBox->transitionType))) {
         $Notice->addError(ThemeHelper::getFormName('fancybox_image_animation_effect_open', false), $invalidValue);
     }
     if (!in_array($option['fancybox_image_animation_effect_close'], array_keys($FancyBox->transitionType))) {
         $Notice->addError(ThemeHelper::getFormName('fancybox_image_animation_effect_close', false), $invalidValue);
     }
     if (!in_array($option['fancybox_image_animation_effect_next'], array_keys($FancyBox->transitionType))) {
         $Notice->addError(ThemeHelper::getFormName('fancybox_image_animation_effect_next', false), $invalidValue);
     }
     if (!in_array($option['fancybox_image_animation_effect_previous'], array_keys($FancyBox->transitionType))) {
         $Notice->addError(ThemeHelper::getFormName('fancybox_image_animation_effect_previous', false), $invalidValue);
     }
     if (!in_array($option['fancybox_image_easing_open'], array_keys($Easing->easingType))) {
         $Notice->addError(ThemeHelper::getFormName('fancybox_image_easing_open', false), $invalidValue);
     }
     if (!in_array($option['fancybox_image_easing_close'], array_keys($Easing->easingType))) {
         $Notice->addError(ThemeHelper::getFormName('fancybox_image_easing_close', false), $invalidValue);
     }
     if (!in_array($option['fancybox_image_easing_next'], array_keys($Easing->easingType))) {
         $Notice->addError(ThemeHelper::getFormName('fancybox_image_easing_next', false), $invalidValue);
     }
     if (!in_array($option['fancybox_image_easing_previous'], array_keys($Easing->easingType))) {
         $Notice->addError(ThemeHelper::getFormName('fancybox_image_easing_previous', false), $invalidValue);
     }
     $Validation->notice('isNumber', array($option['fancybox_image_speed_open'], 1, 99999), array(ThemeHelper::getFormName('fancybox_image_speed_open', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_speed_close'], 1, 99999), array(ThemeHelper::getFormName('fancybox_image_speed_close', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_speed_next'], 1, 99999), array(ThemeHelper::getFormName('fancybox_image_speed_next', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_image_speed_previous'], 1, 99999), array(ThemeHelper::getFormName('fancybox_image_speed_previous', false), $invalidValue));
     /* Plugin / Fancybox for videos */
     $Validation->notice('isNumber', array($option['fancybox_video_padding'], 0, 999), array(ThemeHelper::getFormName('fancybox_video_padding', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_margin'], 0, 999), array(ThemeHelper::getFormName('fancybox_video_margin', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_min_width'], 1, 9999), array(ThemeHelper::getFormName('fancybox_video_min_width', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_min_height'], 1, 9999), array(ThemeHelper::getFormName('fancybox_video_min_height', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_max_width'], 1, 9999), array(ThemeHelper::getFormName('fancybox_video_max_width', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_max_height'], 1, 9999), array(ThemeHelper::getFormName('fancybox_video_max_height', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_autoresize'], 0, 1), array(ThemeHelper::getFormName('fancybox_video_autoresize', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_autocenter'], 0, 1), array(ThemeHelper::getFormName('fancybox_video_autocenter', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_fittoview'], 0, 1), array(ThemeHelper::getFormName('fancybox_video_fittoview', false), $invalidValue));
     $Validation->notice('isNumber', array($option['fancybox_video_close_button'], 0, 1), array(ThemeHelper::getFormName('fancybox_video_close_button', false), $invalidValue));
     /* Plugin / Maintenance mode */
     $Validation->notice('isNumber', array($option['maintenance_mode_enable'], 0, 1), array(ThemeHelper::getFormName('maintenance_mode_enable', false), $invalidValue));
     if ($Notice->isError()) {
         $response['local'] = $Notice->getError();
     } else {
         $response['global']['error'] = 0;
         ThemeOption::updateOption($option);
         $this->createCSSFile();
     }
     $response['global']['notice'] = $Notice->createHTML(THEME_PATH_TEMPLATE . 'notice.php');
     echo json_encode($response);
     exit;
 }
 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('ThemePunch_Fonts')) {
                 if (array_key_exists('font', $ti_data['plugin_revslider'])) {
                     if ($this->checkCode(10001)) {
                         $Font = new ThemePunch_Fonts();
                         foreach ($ti_data['plugin_revslider']['font'] as $fontValue) {
                             $Font->add_new_font($fontValue);
                         }
                         $this->createResponse(null, false, 10002);
                     }
                 }
             }
             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);
                     $widget_data = $json_data[1];
                     $sidebars_data = $json_data[0];
                     $current_sidebars = get_option('sidebars_widgets');
                     $current_sidebars['wp_inactive_widgets'] = array();
                     update_option('sidebars_widgets', $current_sidebars);
                     $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 = null;
                                 if (array_key_exists('_multiwidget', $current_widget_data)) {
                                     $current_multiwidget = $current_widget_data['_multiwidget'];
                                 }
                                 $new_multiwidget = $widget_data[$title]['_multiwidget'];
                                 $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) {
                             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 ($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 = mb_substr($bIndex, mb_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;
                 }
             }
         }
     }
     /**********************************************************************/
     $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);
     }
     /**********************************************************************/
     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);
 }