function get_all() { $all = pl_opt($this->slug, pl_settings_default()); // Upgrade from legacy mode if (!isset($all['draft']) || empty($all['draft'])) { if (!isset($all['draft'])) { $new = array('draft' => $all, 'live' => $all); } elseif (empty($all['draft'])) { $new = wp_parse_args(array('draft' => $this->default_objects()), $all); } pl_opt_update($this->slug, $new); $all = $new; } return $all[pl_get_mode()]; }
function set_default_settings() { $settings = pl_get_global_settings(); if (!$settings) { $settings = pl_settings_default(); } $settings_defaults = apply_filters('pl_theme_default_settings', get_default_settings()); $region_defaults = apply_filters('pl_theme_default_regions', array()); if (empty($settings['draft'])) { $settings['draft'] = array('settings' => $settings_defaults, 'regions' => $region_defaults); } if (empty($settings['live'])) { $settings['live'] = array('settings' => $settings_defaults, 'regions' => $region_defaults); } pl_update_global_settings($settings); return $settings; }
function get_by_mode($set) { $mode = $this->mode == 'detect' ? pl_get_mode() : $this->mode; $set = wp_parse_args($set, pl_settings_default()); return $set[$mode]; }
function user_templates() { $slug = $this->default_template_slug; $this->xlist = new EditorXList(); $templates = ''; $list = ''; $tpls = pl_meta($this->page->id, $this->map_option_slug, pl_settings_default()); $custom_template_handler = new PLCustomTemplates(); $all_templates = $custom_template_handler->get_all(); $count = 1; $cols = 6; $num = count($all_templates); foreach ($all_templates as $index => $template) { $classes = array(sprintf('template_key_%s', $index)); $action_classes = array('x-item-actions'); global $pl_custom_template; if (!empty($pl_custom_template)) { $action_classes[] = $index === $pl_custom_template['key'] ? 'active-template' : ''; } $action_classes[] = $index === $this->default_global_tpl ? 'active-global' : ''; $action_classes[] = $index === $this->default_type_tpl && !$this->page->is_special() ? 'active-type' : ''; ob_start(); echo pl_grid_tool('row_start', $cols, $count, $num, 'pl-list-row'); ?> <div class="row span<?php echo $cols; ?> pl-template-row <?php echo join(' ', $classes); ?> " data-key="<?php echo $index; ?> "> <div class="span8 list-head"> <div class="list-title"><?php echo stripslashes($template['name']); ?> </div> <div class="list-desc"> <?php echo stripslashes($template['desc']); ?> </div> </div> <div class="span4 list-actions"> <div class="<?php echo join(' ', $action_classes); ?> "> <button class="btn btn-mini btn-primary load-template"><?php _e('Load', 'pagelines'); ?> </button> <button class="btn btn-mini btn-important the-active-template"><?php _e('Active', 'pagelines'); ?> </button> <div class="btn-group dropup"> <a class="btn btn-mini dropdown-toggle actions-toggle" data-toggle="dropdown" href="#"> <i class="icon icon-caret-down"></i> </a> <ul class="dropdown-menu"> <li ><a class="update-template"> <i class="icon icon-edit"></i> <?php _e('Update Template with Current Configuration', 'pagelines'); ?> </a></li> <li><a class="set-tpl" data-run="global"> <i class="icon icon-globe"></i> <?php _e('Set as Page Global Default', 'pagelines'); ?> </a></li> <li><a class="delete-template"> <i class="icon icon-remove"></i> <?php _e('Delete This Template', 'pagelines'); ?> </a></li> </ul> </div> <button class="btn btn-mini tpl-tag global-tag tt-top" title="Current Sitewide Default"><i class="icon icon-globe"></i></button> <button class="btn btn-mini tpl-tag posttype-tag tt-top" title="Current Post Type Default"><i class="icon icon-pushpin"></i></button> </div> </div> </div> <?php echo pl_grid_tool('row_end', $cols, $count, $num); $count++; $list .= ob_get_clean(); } ob_start(); ?> <form class="opt standard-form form-save-template"> <fieldset> <h4><?php _e('Save Current Page As New Template', 'pagelines'); ?> </h4> </span> <label for="template-name"><?php _e('Template Name (required)', 'pagelines'); ?> </label> <input type="text" id="template-name" name="name" required /> <label for="template-desc"><?php _e('Template Description', 'pagelines'); ?> </label> <textarea rows="4" id="template-desc" name="desc" ></textarea> <button type="submit" class="btn btn-primary btn-save-template"><?php _e('Save New Template', 'pagelines'); ?> </button> </fieldset> </form> <?php $form = ob_get_clean(); printf('<div class="row"><div class="span8"><div class="pl-list-contain">%s</div></div><div class="span4">%s</div></div>', $list, $form); }
function pl_set_default_settings() { $settings = pl_get_all_settings(); if (!$settings) { $settings = pl_settings_default(); } pl_update_all_settings($settings); return $settings; }