Beispiel #1
0
 private function create_layout($name)
 {
     // @todo check with Ric to get a more handy class to create a new layout.
     // currently there is only (which I found)
     // - create_layout_auto(), which has a redirect
     // - create_layout_callback() for ajax only -> uses die()
     global $wpddlayout;
     if (!$this->needed_components_loaded()) {
         return false;
     }
     // permissions
     if (!current_user_can('manage_options') && WPDD_Layouts_Users_Profiles::user_can_create() && WPDD_Layouts_Users_Profiles::user_can_assign()) {
         return false;
     }
     $layout = WPDD_Layouts::create_layout(12, 'fluid');
     // Define layout parameters
     $layout['type'] = 'fluid';
     // layout_type
     $layout['cssframework'] = $wpddlayout->get_css_framework();
     $layout['template'] = '';
     $layout['parent'] = '';
     $layout['name'] = $name;
     $args = array('post_title' => $name, 'post_content' => '', 'post_status' => 'publish', 'post_type' => WPDDL_LAYOUTS_POST_TYPE);
     $layout_id = wp_insert_post($args);
     // force layout object to take right ID
     // @see WPDD_Layouts::create_layout_callback() @ wpddl.class.php
     $layout_post = get_post($layout_id);
     $layout['id'] = $layout_id;
     $layout['slug'] = $layout_post->post_name;
     // update changes
     WPDD_Layouts::save_layout_settings($layout_id, $layout);
     return $layout_id;
 }