Example #1
0
 /**
  * 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);
 }
Example #2
0
 function render_section($map_meta, $level = 1)
 {
     /** Section is available, render it in the UI */
     if ($this->in_factory($map_meta['object'])) {
         $s = $this->factory[$map_meta['object']];
         $s->meta = $map_meta;
         $s->level = $level;
         $s->content = $map_meta['content'];
         $s->render($map_meta, $level);
         wp_reset_postdata();
         // Reset $post data
         wp_reset_query();
         // Reset wp_query
     } else {
         pl_missing_section($map_meta['object'], $map_meta['clone'], $level);
     }
 }
Example #3
0
/**
 * 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);
}