Exemplo n.º 1
0
 function et_pb_add_predefined_layouts()
 {
     $et_pb_layouts = et_pb_get_predefined_layouts();
     if (isset($et_pb_layouts) && is_array($et_pb_layouts)) {
         foreach ($et_pb_layouts as $et_pb_layout) {
             et_pb_create_layout($et_pb_layout['name'], $et_pb_layout['content'], true);
         }
     }
     set_theme_mod('et_pb_predefined_layouts_added', 'on');
 }
Exemplo n.º 2
0
function et_pb_save_layout()
{
    if (!wp_verify_nonce($_POST['et_load_nonce'], 'et_load_nonce')) {
        die(-1);
    }
    if ('' !== $_POST['et_layout_name']) {
        $layout_type = isset($_POST['et_layout_type']) ? $_POST['et_layout_type'] : 'layout';
        $layout_selected_cats = isset($_POST['et_layout_cats']) ? $_POST['et_layout_cats'] : '';
        $layout_new_cat = isset($_POST['et_layout_new_cat']) ? $_POST['et_layout_new_cat'] : '';
        $columns_layout = isset($_POST['et_columns_layout']) ? $_POST['et_columns_layout'] : '0';
        $module_type = isset($_POST['et_module_type']) ? $_POST['et_module_type'] : 'et_pb_unknown';
        $layout_cats_processed = array();
        if ('' !== $layout_selected_cats) {
            $layout_cats_array = explode(',', $layout_selected_cats);
            $layout_cats_processed = array_map('intval', $layout_cats_array);
        }
        $meta = array();
        if ('row' === $layout_type && '0' !== $columns_layout) {
            $meta = array_merge($meta, array('_et_pb_row_layout' => $columns_layout));
        }
        if ('module' === $layout_type) {
            $meta = array_merge($meta, array('_et_pb_module_type' => $module_type));
        }
        $tax_input = array('scope' => isset($_POST['et_layout_scope']) ? $_POST['et_layout_scope'] : 'not_global', 'layout_type' => $layout_type, 'module_width' => isset($_POST['et_module_width']) ? $_POST['et_module_width'] : 'regular', 'layout_category' => $layout_cats_processed);
        $new_layout_id = et_pb_create_layout($_POST['et_layout_name'], $_POST['et_layout_content'], $meta, $tax_input, $layout_new_cat);
        $new_post_data['post_id'] = $new_layout_id;
    }
    $new_post_data['edit_link'] = htmlspecialchars_decode(get_edit_post_link($new_layout_id));
    $json_post_data = json_encode($new_post_data);
    die($json_post_data);
}
 function et_pb_add_predefined_layouts()
 {
     $et_builder_layouts = et_pb_get_predefined_layouts();
     $meta = array('_et_pb_predefined_layout' => 'on', '_et_pb_built_for_post_type' => 'page');
     if (isset($et_builder_layouts) && is_array($et_builder_layouts)) {
         foreach ($et_builder_layouts as $et_builder_layout) {
             et_pb_create_layout($et_builder_layout['name'], $et_builder_layout['content'], $meta);
         }
     }
     set_theme_mod('et_pb_predefined_layouts_added', 'on');
 }
Exemplo n.º 4
0
function et_pb_save_layout()
{
    if (!wp_verify_nonce($_POST['et_load_nonce'], 'et_load_nonce')) {
        die(-1);
    }
    if ('' !== $_POST['et_layout_name']) {
        et_pb_create_layout($_POST['et_layout_name'], $_POST['et_layout_content']);
    }
    die;
}
Exemplo n.º 5
0
 function et_pb_submit_layout($args)
 {
     if (empty($args)) {
         return;
     }
     $layout_cats_processed = array();
     if ('' !== $args['layout_selected_cats']) {
         $layout_cats_array = explode(',', $args['layout_selected_cats']);
         $layout_cats_processed = array_map('intval', $layout_cats_array);
     }
     $meta = array();
     if ('row' === $args['layout_type'] && '0' !== $args['columns_layout']) {
         $meta = array_merge($meta, array('_et_pb_row_layout' => $args['columns_layout']));
     }
     if ('module' === $args['layout_type']) {
         $meta = array_merge($meta, array('_et_pb_module_type' => $args['module_type']));
     }
     //et_layouts_built_for_post_type
     $meta = array_merge($meta, array('_et_pb_built_for_post_type' => $args['built_for_post_type']));
     $tax_input = array('scope' => $args['layout_scope'], 'layout_type' => $args['layout_type'], 'module_width' => $args['module_width'], 'layout_category' => $layout_cats_processed);
     $new_layout_id = et_pb_create_layout($args['layout_name'], $args['layout_content'], $meta, $tax_input, $args['layout_new_cat']);
     $new_post_data['post_id'] = $new_layout_id;
     $new_post_data['edit_link'] = htmlspecialchars_decode(get_edit_post_link($new_layout_id));
     $json_post_data = json_encode($new_post_data);
     return $json_post_data;
 }