/** * Template for the shortcode */ function template($atts, $content) { extract(shortcode_atts(array('section' => 'content', 'id' => isset($atts['section']) ? $atts['section'] . pl_edit_id() : false, 'settings' => array()), $atts)); global $plfactory; if (!isset($plfactory->section_ids[$section])) { pl_missing_section($section); return; } else { $object = $plfactory->section_ids[$section]; } $s = $plfactory->factory[$object]; $s->meta = array('clone' => $id, 'object' => $object, 'content' => array()); /** Allow for a function that can be used to set defaults */ $settings = get_section_data($s); $plfactory->add_section_to_factory($id, $object, $settings); $s->meta['set'] = $settings; ob_start(); $s->section_styles(); /** Auto load build.css document which is generated from build.less */ if (is_file($s->base_dir . '/build.css')) { pl_style($section, $s->base_url . '/build.css'); } if (is_file($s->base_dir . '/style.css')) { pl_style($section, $s->base_url . '/style.css'); } echo '<div class="temp-wrap pl-sn-shortcode" data-bind="stopBinding: true" >'; $s->render($s->meta); echo "\n</div>\n"; wp_reset_postdata(); // Reset $post data wp_reset_query(); // Reset wp_query return apply_filters('pl_section', ob_get_clean(), $atts, $content); }
/** * 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); }
/** * Function for plsection shortcode */ function pl_get_section($config) { $defaults = array(); $defaults['section'] = 'content'; $defaults['id'] = isset($config['section']) ? $config['section'] . pl_edit_id() : $defaults['section']; $defaults['settings'] = array(); $config = shortcode_atts($defaults, $config); global $plfactory; $sid = $config['section']; $uid = $config['id']; if (!isset($plfactory->section_ids[$sid])) { pl_missing_section($sid); return; } else { $object = $plfactory->section_ids[$sid]; } $s = $plfactory->factory[$object]; $s->meta = array('clone' => $uid, 'object' => $object, 'content' => array()); $plfactory->list['sections'][$uid] = array('object' => $object); /** Allow for a function that can be used to set defaults */ $settings = get_section_data($s, $config['settings']); $plfactory->sections_data[$uid] = $settings; $s->meta['set'] = $settings; ob_start(); $s->section_styles(); /** Auto load build.css document which is generated from build.less */ if (is_file($s->base_dir . '/build.css')) { pl_style($sid, $s->base_url . '/build.css'); } if (is_file($s->base_dir . '/style.css')) { pl_style($sid, $s->base_url . '/style.css'); } echo '<div class="temp-wrap" data-bind="stopBinding: true" >'; $s->render($s->meta); echo "\n</div>\n"; wp_reset_postdata(); // Reset $post data wp_reset_query(); // Reset wp_query return apply_filters('pl_get_section', ob_get_clean(), $config); }