Ejemplo n.º 1
0
 /**
  * Create a new columns
  *
  * @param array $structure Column structure
  */
 public function __construct($structure)
 {
     $structure = $this->validate_structure($structure);
     $this->width = $structure['width'];
     $this->options = new Layotter_Options('col', $structure['options']);
     foreach ($structure['elements'] as $element) {
         $element_object = false;
         // if a template_id is set, try to create a template
         if (isset($element['template_id'])) {
             $element_object = Layotter_Templates::create_element($element);
         }
         // if the template doesn't exist anymore, create a regular element
         if (!$element_object) {
             $element_object = Layotter::create_element($element);
         }
         if ($element_object) {
             $this->elements[] = $element_object;
         }
     }
 }
Ejemplo n.º 2
0
function layotter_ajax_delete_template()
{
    $post_data = layotter_get_angular_post_data();
    // template ID is required
    if (isset($post_data['template_id'])) {
        $template_object = Layotter_Templates::create_element($post_data['template_id']);
        if ($template_object) {
            Layotter_Templates::delete($post_data['template_id']);
            $template_object->unset_template_id();
            echo json_encode($template_object->to_array());
        }
    }
    die;
    // required by Wordpress after any AJAX call
}