function revert_type($typeID) { pl_revert_settings($typeID); pl_meta_update($typeID, $this->slug, false); }
function publish($response, $data) { global $sections_data_handler, $dms_cache; $pageID = $data['pageID']; $typeID = $data['typeID']; $response['result'] = $sections_data_handler->publish_items($data['store']); $section_handler = new PLCustomSections(); $section_handler->update_objects('publish'); $tpl_handler = new PLCustomTemplates(); $tpl_handler->update_objects('publish'); $settings = array(); $settings['local'] = pl_meta($pageID, PL_SETTINGS); $settings['type'] = pl_meta($typeID, PL_SETTINGS); $settings['global'] = pl_get_global_settings(); foreach ($settings as $scope => $set) { $set = wp_parse_args($set, array('live' => array(), 'draft' => array())); $set['live'] = $set['draft']; $settings[$scope] = $set; } pl_meta_update($pageID, PL_SETTINGS, $settings['local']); pl_meta_update($typeID, PL_SETTINGS, $settings['type']); pl_update_global_settings($settings['global']); // Flush less $dms_cache->purge('live_css'); // run clean post action to trigger caches to clear. Varnish, WPE etc. do_action('clean_post_cache'); return $response; }
function set_template($response, $data) { $run = $data['run']; if ($run == 'update') { $response['key'] = $this->handler->update($data['key'], $data['config']); } elseif ($run == 'delete') { $response['key'] = $this->handler->delete($data['key']); } elseif ($run == 'create') { $response['key'] = $this->handler->create($data['config']); } elseif ($run == 'template_mode') { $value = $data['value']; $pageID = $data['pageID']; $key = 'pl_template_mode'; pl_meta_update($pageID, $key, $value); $response['result'] = pl_meta($pageID, $key); } elseif ($run == 'set_global') { $field = 'page-template'; $value = $data['value']; $previous_val = pl_global($field); if ($previous_val == $value) { pl_global_update($field, false); } else { pl_global_update($field, $value); } $response['result'] = pl_global($field); } $response['hi'] = 'hello'; return $response; }
function update_setting($args = array()) { $defaults = array('key' => '', 'val' => '', 'mode' => 'draft', 'scope' => 'global', 'uid' => 'settings'); $a = wp_parse_args($args, $defaults); $scope = $a['scope']; $mode = $a['mode']; $key = $a['key']; $val = $a['val']; $uid = $a['uid']; $parse_value = array($key => $val); if ($scope == 'global') { $settings = pl_get_global_settings(); $old_settings = isset($settings[$mode][$uid]) ? $settings[$mode][$uid] : array(); $settings[$mode][$uid] = wp_parse_args($parse_value, $old_settings); pl_update_global_settings($settings); } elseif ($scope == 'local' || $scope == 'type') { global $plpg; $theID = $scope == 'local' ? $plpg->id : $plpg->typeid; $settings = $this->meta($theID, PL_SETTINGS, pl_settings_default()); $old_settings = isset($settings[$mode][$uid]) ? $settings[$mode][$uid] : array(); $settings[$mode][$uid] = wp_parse_args($parse_value, $old_settings); pl_meta_update($theID, PL_SETTINGS, $settings); } }