protected function section() { global $db; $params = array(); if ($this->method == "GET") { if (sizeof($this->args) == 2) { if ($this->args[0] == "data") { $main_arg = $this->args[1]; if (is_numeric($main_arg)) { $params["section_id"] = $main_arg; return get_section_data($db, $params); } else { return "The id you passed in is not a number!"; } } else { $this->args[0] == "id" ? $type = "id" : ($type = "name"); $main_arg = $this->args[1]; if ($type == "id") { $params["section_id"] = $main_arg; } else { if ($type == "name") { $params["section_name"] = $main_arg; } else { return "The type of parameter you are passing in is not valid!"; } } return get_sections($db, $params); } } else { return "The number of parameters is not correct!"; } } else { return "This only accepts GET requests!"; } }
/** * 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); }
/** * 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); }