Пример #1
0
 /**
  * Gets all config data in an array
  */
 function set_config_data()
 {
     global $wp;
     global $wp_query;
     global $pl_dynamic_templates;
     //print_r( $GLOBALS['wp_query']);
     $a['query'] = $GLOBALS['wp_query']->query;
     // ID of the currently active user
     $a['userID'] = wp_get_current_user()->ID;
     // URL of the current page
     $a['currentURL'] = add_query_arg($wp->query_string, '', home_url($wp->request));
     /** Should we save styles? set to 1 on change */
     $a['saveStyles'] = 0;
     /** Render mode is set on the fly as template is loaded */
     $a['tplRender'] = $pl_dynamic_templates;
     // Currently active page template
     $a['tplActive'] = $this->page->template();
     // The current template scope mode
     $a['tplMode'] = $this->page->template_mode();
     $a['editID'] = pl_edit_id();
     $a['editslug'] = pl_edit_slug();
     // The ID for the current page
     $a['pageID'] = $this->page->id;
     $a['pageslug'] = $this->page->meta_slug;
     // The ID for the current type
     $a['typeID'] = $this->page->typeid;
     $a['typeslug'] = $this->page->type_slug;
     // The ID for the current type
     $a['termID'] = $this->page->termid;
     $a['termslug'] = $this->page->term_slug;
     // The slug ID of the current type (?)
     $a['typename'] = $this->page->type;
     // Page Name and Slug Format
     $a['currentPageName'] = esc_attr($this->page->get_current_page_name());
     $a['currentPageSlug'] = $this->page->get_current_page_slug();
     $a['currentTaxonomy'] = $this->page->get_current_taxonomy();
     $a['themename'] = wp_get_theme()->name;
     // A cache key for various settings
     $a['CacheKey'] = pl_cache_key();
     // Is the user on localhost
     $a['LocalHost'] = pl_is_local();
     // Is developer mode activated?
     $a['debug'] = pl_dev_mode() ? 'true' : 'false';
     // Is this page a WP special page: e.g. multi-post, 404, etc..
     $a['isSpecial'] = $this->page->is_special();
     $a['needsave'] = isset($_GET['needsave']) ? 1 : 0;
     $a['tplMap'] = $this->map->map;
     $a['templateOpts'] = pl_get_template_settings();
     $a['nonce'] = wp_create_nonce('pl-ajax-nonce');
     return array_merge($a, $this->additions);
 }
Пример #2
0
 /**
  * Get all information related to drawing a page.
  * Includes sections, data, and their model keys
  * @return array uniqueIDs, Data, option keys for model
  */
 function get_view_model()
 {
     $view_model = $this->list['sections'];
     foreach ($view_model as $uid => &$info) {
         // Dont need the data added below
         unset($info['data']);
         $info['values'] = array('type' => '', 'value' => '', 'opts' => '');
         $defaults = isset($this->factory[$info['object']]) ? $this->factory[$info['object']]->section_defaults() : array();
         $data = isset($this->sections_data[$uid]) ? $this->sections_data[$uid] : $defaults;
         $modelized_data = pl_defaults_model($data);
         $keys = array();
         $opts = array();
         if (pl_is_static_template('viewmodel') && $info['object'] == 'PL_Content') {
             $opts = pl_get_template_settings();
         } elseif (isset($this->factory[$info['object']])) {
             $opts = $this->factory[$info['object']]->section_opts();
         }
         $keys = $this->recursive_parse_opts($opts, $data);
         /** Parse together for standard section options which aren't in array */
         $info['values'] = wp_parse_args($keys, $modelized_data);
         $info = apply_filters('pl_model_' . $info['object'], $info);
     }
     unset($info);
     // set by reference
     if (isset($view_model[''])) {
         unset($view_model['']);
     }
     return $view_model;
 }