/** * Run first on each AJAX action registered with upfront_add_ajax */ function upfront_ajax_init() { $stylesheet = $layout_ids = $storage_key = $load_dev = false; // Automatically instantiate Upfront_Layout object if ($_SERVER['REQUEST_METHOD'] == 'POST') { $layout_ids = !empty($_POST['layout']) ? $_POST['layout'] : false; $storage_key = !empty($_POST['storage_key']) ? $_POST['storage_key'] : false; $stylesheet = !empty($_POST['stylesheet']) ? $_POST['stylesheet'] : false; $load_dev = !empty($_POST['load_dev']) && $_POST['load_dev'] == 1 ? true : false; } else { if (isset($_GET['layout'])) { $layout_ids = !empty($_GET['layout']) ? $_GET['layout'] : false; $storage_key = !empty($_GET['storage_key']) ? $_GET['storage_key'] : false; $stylesheet = !empty($_GET['stylesheet']) ? $_GET['stylesheet'] : false; $load_dev = !empty($_GET['load_dev']) && $_GET['load_dev'] == 1 ? true : false; } } if ($stylesheet === false) { $stylesheet = apply_filters('upfront_get_stylesheet', $stylesheet); } upfront_switch_stylesheet($stylesheet); if (!is_array($layout_ids)) { return; } $layout = Upfront_Layout::from_entity_ids($layout_ids, $storage_key, $load_dev); if ($layout->is_empty()) { $layout = Upfront_Layout::create_layout($layout_ids); } }
function reset_layout() { if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) { $this->_reject(); } $data = !empty($_POST) ? stripslashes_deep($_POST) : false; $layout = !empty($data['layout']) ? $data['layout'] : array(); $storage_key = $data['storage_key']; $stylesheet = $data['stylesheet'] ? $data['stylesheet'] : get_stylesheet(); $stylesheet_dev = false; if (!empty($data['dev'])) { $stylesheet_dev = "{$stylesheet}_dev"; // Handle dev-mode names } upfront_switch_stylesheet($stylesheet); //$layout = Upfront_Layout::from_php($data, $storage_key); $layout = Upfront_Layout::from_entity_ids($layout, null, !empty($stylesheet_dev)); $layout->delete(true); delete_option('upfront_' . $stylesheet . '_styles'); delete_option('upfront_' . $stylesheet . '_theme_colors'); delete_option('upfront_' . $stylesheet . '_button_presets'); if (!empty($stylesheet_dev)) { delete_option('upfront_' . $stylesheet_dev . '_styles'); } if (!empty($stylesheet_dev)) { delete_option('upfront_' . $stylesheet_dev . '_theme_colors'); } if (!empty($stylesheet_dev)) { delete_option('upfront_' . $stylesheet_dev . '_button_presets'); } $this->_out(new Upfront_JsonResponse_Success("Layout reset")); }
public function parse($request) { upfront_switch_stylesheet($this->stylesheet); add_filter('upfront-storage-key', array($this, 'storage_key_filter')); add_filter('upfront-data-storage-key', array($this, 'storage_key_filter')); add_filter('upfront-enable-dev-saving', '__return_false'); query_posts(''); }