Esempio n. 1
0
 function __construct(EditorTemplates $tpl)
 {
     $this->tpl = $tpl;
     $this->mode = pl_get_mode();
     global $plpg;
     $this->page = $plpg;
     $this->set = new PageLinesOpts();
     add_filter('pl_load_page_settings', array($this, 'add_template_settings_to_page'));
 }
Esempio n. 2
0
 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 configure_section_data($uids, $rows)
 {
     $config = array();
     $rows_added = false;
     $mode = pl_get_mode();
     foreach ($uids as $uid) {
         $num_rows = 0;
         foreach ($rows as $set) {
             if ($set->uid == $uid) {
                 $num_rows++;
                 $config[$uid] = stripslashes_deep($this->unserialize($set->{$mode}));
             }
         }
         if ($num_rows == 0) {
             $draft = new PageLinesOpts('draft');
             $draft->load_page_settings();
             $upgrade_settings = array();
             $upgrade_settings['draft'] = $draft->get_set($uid);
             $live = new PageLinesOpts('live');
             $live->load_page_settings();
             $upgrade_settings['live'] = $live->get_set($uid);
             $encoded_draft = json_encode($upgrade_settings['draft']);
             $encoded_live = json_encode($upgrade_settings['live']);
             $set = array('uid' => $uid, 'draft' => $encoded_draft, 'live' => $encoded_live);
             $num_rows++;
             $result = $this->wpdb->insert($this->table_name, $set);
             $rows_added = true;
             $config[$uid] = $upgrade_settings[$mode];
         }
     }
     // Remove empties.
     foreach ($config as $i => $val) {
         if (empty($val)) {
             unset($config[$i]);
         }
     }
     return $config;
 }
Esempio n. 4
0
 function current_page_data($scope = 'local')
 {
     $d = array();
     if ($scope == 'local') {
         $d = pl_settings($this->draft->mode, $this->page->id);
     } elseif ($scope == 'type') {
         $d = pl_settings($this->draft->mode, $this->page->typeid);
     } elseif ($scope == 'section') {
         global $sections_handler;
         $d = $sections_handler->get_user_section_settings();
     } elseif ($scope == 'template') {
         global $pl_custom_template;
         $d = !empty($pl_custom_template) ? $pl_custom_template['settings'] : array();
     } elseif ($scope == 'global') {
         $d = pl_get_global_settings(pl_get_mode());
     }
     return $d ? $d : array();
 }
Esempio n. 5
0
function pl_global_update($key, $value)
{
    $settings = pl_get_global_settings();
    $settings[pl_get_mode()][$key] = $value;
    pl_update_global_settings($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];
 }