Ejemplo n.º 1
0
 function get_options_config()
 {
     $opts_config = array();
     // BACKWARDS COMPATIBILITY
     add_action('override_metatab_register', array($this, 'get_opts_from_optionator'), 10, 2);
     foreach ($this->section_list as $key => $meta) {
         if ($this->in_factory($meta['object'])) {
             $s = $this->factory[$meta['object']];
             $s->meta = $meta;
             $opts_config[$s->meta['clone']] = array('name' => $s->name);
             $opts = array();
             // Grab the options
             $opts = $s->section_opts();
             // Deal with special case flags...
             if (is_array($opts)) {
                 foreach ($opts as $index => $opt) {
                     if (isset($opt['case'])) {
                         // Special Page Only Option (e.g. used in post loop)
                         if ($opt['case'] == 'special' && !$this->page->is_special()) {
                             unset($opts[$index]);
                         }
                         if ($opt['case'] == 'page' && !is_page()) {
                             unset($opts[$index]);
                         }
                         if ($opt['case'] == 'post' && !is_post()) {
                             unset($opts[$index]);
                         }
                     }
                 }
             }
             // For backwards compatibility with the older optionator format
             // It works by using a hook to hijack the 'register_metapanel' function
             // The hook then sets an attribute of this class to the array of options from the section
             if (!$opts || empty($opts)) {
                 $this->current_option_array = array();
                 // backwards comp
                 $s->section_optionator(array());
                 if (isset($this->current_option_array)) {
                     $opts = process_to_new_option_format($this->current_option_array);
                 }
             }
             // deals with legacy special stuff
             if (!empty($opts)) {
                 foreach ($opts as $okey => &$o) {
                     if ($o['type'] == 'multi') {
                         if (isset($o['opts']) && is_array($o['opts'])) {
                             foreach ($o['opts'] as $okeysub => &$osub) {
                                 if (!isset($osub['key'])) {
                                     $osub['key'] = $okeysub;
                                 }
                                 $this->opts_list[] = $osub['key'];
                             }
                             unset($osub);
                             // set by reference
                         }
                     } else {
                         if (!isset($o['key'])) {
                             $o['key'] = $okey;
                         }
                         $this->opts_list[] = $o['key'];
                     }
                 }
                 unset($o);
                 // set by reference
             }
             $opts = array_merge($opts, pl_standard_section_options($s));
             $opts_config[$s->meta['clone']]['opts'] = $opts;
         }
     }
     remove_action('override_metatab_register', array($this, 'get_opts_from_optionator'), 10, 2);
     foreach ($opts_config as $item => &$i) {
         $i['opts'] = $this->opts_add_values($i['opts']);
     }
     unset($i);
     return apply_filters('get_options_config', $opts_config);
 }
Ejemplo n.º 2
0
function pl_add_settings_panel($settings)
{
    global $pagelines_add_settings_panel;
    if (!isset($pagelines_add_settings_panel) || !is_array($pagelines_add_settings_panel)) {
        return $settings;
    }
    foreach ($pagelines_add_settings_panel as $panel => $setup) {
        if (strpos($setup['icon'], "http://") !== false) {
            $setup['icon'] = 'icon-circle';
        }
        $setup['opts'] = process_to_new_option_format($setup['opts']);
        if (!isset($settings[$panel])) {
            $settings[$panel] = $setup;
        }
    }
    return $settings;
}