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(); }