function pluginActivation()
 {
     $argument = array('post_type' => array('post', 'page'), 'post_status ' => 'any', 'posts_per_page' => -1);
     $query = new WP_Query($argument);
     if ($query === false) {
         return;
     }
     foreach ($query->posts as $value) {
         $data = $this->getData($value->ID);
         if ($data['data']['enable'] != 1) {
             continue;
         }
         $content = $value->post_content;
         $content = preg_replace('/\\[' . PLUGIN_PAGE_BUILDER_SHORTCODE_PREFIX . 'builder\\]/', null, $content);
         $content = preg_replace('/\\[' . PLUGIN_PAGE_BUILDER_SHORTCODE_PREFIX . 'builder id="[0-9]{1,}"\\]/', null, $content);
         $content = $content . $this->createMainShortcode();
         wp_update_post(array('ID' => $value->ID, 'post_content' => $content));
     }
     $option = $this->optionDefault;
     $optionSave = array();
     $optionCurrent = ThemeOption::getOptionObject();
     foreach ($option as $index => $value) {
         if (!array_key_exists($index, $optionCurrent)) {
             $optionSave[$index] = $value;
         }
     }
     $optionSave = array_merge($optionSave, $optionCurrent);
     foreach ($optionSave as $index => $value) {
         if (!array_key_exists($index, $option)) {
             unset($optionSave[$index]);
         }
     }
     PBOption::resetOption();
     PBOption::updateOption($optionSave);
     $this->createCSSFile();
 }
 function pluginActivation()
 {
     if (version_compare(PHP_VERSION, '5.3', '<')) {
         exit(sprintf('This plugin requires PHP 5.3 or higher. You’re still on %s.', PHP_VERSION));
     }
     if (PBData::get('visual_mode') == 1) {
         $argument = array('post_type' => array('post', 'page'), 'post_status ' => 'any', 'posts_per_page' => -1);
         $query = new WP_Query($argument);
         if ($query === false) {
             return;
         }
         foreach ($query->posts as $value) {
             $data = $this->getData($value->ID);
             if ($data['data']['enable'] != 1) {
                 continue;
             }
             $content = $value->post_content;
             $content = preg_replace('/\\[' . PLUGIN_PAGE_BUILDER_SHORTCODE_PREFIX . 'builder\\]/', null, $content);
             $content = preg_replace('/\\[' . PLUGIN_PAGE_BUILDER_SHORTCODE_PREFIX . 'builder id="[0-9]{1,}"\\]/', null, $content);
             $content = $content . $this->createMainShortcode();
             wp_update_post(array('ID' => $value->ID, 'post_content' => $content));
         }
     }
     $option = $this->pluginOptionDeafult;
     $optionSave = array();
     $optionCurrent = ThemeOption::getOptionObject();
     foreach ($option as $index => $value) {
         if (!array_key_exists($index, $optionCurrent)) {
             $optionSave[$index] = $value;
         }
     }
     $optionSave = array_merge($optionSave, $optionCurrent);
     foreach ($optionSave as $index => $value) {
         if (!array_key_exists($index, $option)) {
             unset($optionSave[$index]);
         }
     }
     PBOption::resetOption();
     PBOption::updateOption($optionSave);
     $this->createCSSFile();
 }
Example #3
0
 function publicInit()
 {
     require_once ABSPATH . 'wp-admin/includes/plugin.php';
     $this->prepareLibrary();
     $GoogleFont = new ThemeGoogleFont();
     $GoogleFont->setToStyle($this->library['style']);
     $this->includeLibrary(ThemeOption::getOption('responsive_mode_enable'), null, array('responsive'));
     $this->includeLibrary(!ThemeOption::getOption('responsive_mode_enable'), null, array('responsive-disable'));
     $this->includeLibrary(!class_exists('TSThemeStyle'), null, array('ts-frontend'));
     $this->includeLibrary(!class_exists('PBPageBuilder'), null, array('pb-frontend', 'pb-frontend-main'));
     $this->addLibrary('style', 2);
     $this->addLibrary('script', 2);
     $aPattern = array('rightClick' => '/^right_click_/', 'selection' => '/^copy_selection_/', 'fancyboxImage' => '/^fancybox_image_/', 'fancyboxVideo' => '/^fancybox_video_/', 'goToPageTop' => '/^go_to_page_top_/');
     $option = ThemeOption::getOptionObject();
     foreach ($aPattern as $indexPattern => $valuePattern) {
         foreach ($option as $index => $value) {
             if (preg_match($valuePattern, $index, $result)) {
                 $nIndex = preg_replace($valuePattern, '', $index);
                 $data[$indexPattern][$nIndex] = $value;
             }
         }
     }
     $data['config']['theme_url'] = THEME_URL;
     $param = array('l10n_print_after' => 'themeOption=' . json_encode($data) . ';');
     wp_localize_script('public', 'themeOption', $param);
 }