<?php
/*
Plugin Name: Divi Cloud
Plugin URI: https://www.layoutscloud.com/
Description: This plugin gives your Divi site a development supercharge with access to free and premium layouts listed on the Layouts Cloud website.
Author: Page Builder Cloud
Author URI: https://www.layoutscloud.com/
Version: 2.1.1

Changelog:

V1.0 - 8/3/17
- initial proof of concept

V1.14 - 5/4/17
- More features...

V1.15 - 19/4/17
- Added helpful error messages for debugging purposes. Also added an initial check for cURL SSL to avoid confusion at setup

V1.2 - 28/4/17
- Added gallery view to Divi Cloud near the divi icon in the admin area allowing direct download to library
- Included modules and sections in the gallery view for import
- Fixed bug in personal cloud whereby some layouts didn't completely send and therefore corrupted
- Stability improvements
- CSS changes to make using the plugin easier and more enjoyable, A whole new layout for the library selection
- Ability to save favourites and filter by them
- Ability to delete own layouts from the cloud
- Ability to preview own layouts from the cloud
- Added auto update to facilitate delivery of future versions
- Assigned category to builder layouts to make sorting/filtering easier

V1.3 - 3/6/17
- Fixed issue effecting a few servers whereby importing a personal cloud item returned an 'unknown error'. Reinitialised the $return array to fix.

V1.4 - 20/6/17
- Added Community Cloud settings and saving options
- Hit return to search instead of having to press the search button

V1.4.1 - 25/6/17
- Fixed community cloud load from library link
- Added EMP advert

V1.5 - 28/6/17
- Fixed a issue with the auto-update system

V1.6 - 2/8/17
- Added pagination to layout lists for easier and faster navigation
- Added 'replace content' checkbox so you can optionally append your layouts to the builder
- Allowed for categorisation of 'my cloud' layouts for easier archiving and recall

V1.7 - 25/9/17
- Removed superfluous 'replace content' box from within gallery view
- CSS changes
- Added basic white labelling functionality
- Layout Sets can now be filtered on within the Divi Cloud interface
- Added new snippet system for feeelancer/agency users
- Added new Navigation Bar templates within the Divi Cloud gallery view

V1.8 - 4/12/17
- Added images for own cloud items.
- Laid out ‘my cloud’ page to include images in backgrounds
- Added images for community cloud items
- Updated colorbox to the latest version / fixed CSS relating to this
- Made the categories on ‘my cloud’ interface easier when you have no categories yet
- Integrated intercom into the settings pages
- Added entire site skinning using a complete customiser import. includes nav bars, fonts, sizes, etc..
- Obfuscated API key
- White labelling now supports constraining “my cloud” to certain categories. This could be used whereby you may have categories for client/project names and assign them on the sites where you use DC in white labelling mode
- Added white label option to hide community cloud
- Added default view setting so that ‘my cloud’ can be shown first when hitting the Divi Cloud button
- Added pagination to top as well as of the layout grid
- Added helper ‘one moment please…’ notification to the gallery view to reassure the user that something is actually happening
- Added ability to hide the Layouts Cloud layouts leaving only ‘my cloud’ content
- Widened dialogue box for loading layouts to make layout prettier

V1.9 - 30/01/18
- added ?dc_conn_test={api_key} parameter for connectivity debugging purposes. Allows us to diagnose bvad connections between the DU server and the customers for faster support
- Added cache buster code to the js file to prevent any delay when requesting new layouts, snippets and nav bars.
- Changed the URL of the API from diviunited.com to layoutscloud.com due to the change in domain name with the company
- Changed all occurrences of 1divi.com to 2divi.com

V1.9.1 - 01/02/18
- Fixed scrolling in the latest version of Divi
- A bit of a facelift to remove some shadows and rounded corners so the design is more inkeeping with the new layouts system
- Removed 'replace content' checkbox as no longer supported by Divi

V1.9.2 - 13/02/18
- Fixed "my cloud" previews

V1.9.3 - 22/02/18
- Put back 'replace content' and hooked it up in the new way as it was re-added to Divi in the latest version
- Fixed custom width of the save section, row, module overlay as it was smaller before

V1.9.4 - 21/03/18
- Fixed community cloud styling (my CC)
- Replaced all references of divi united for layouts cloud

v1.9.5 - 5/6/18
- Finished replacing the branding
- Removed Site Skins and Navbars due to refocus
- Added admin sidebar link to 'my cloud'

v1.9.6 - 5/11/18
- Removed live chat as we have swapped systems and they don't have a direct integration
- New colour scheme

v1.9.7 - 16/01/19
- Made the snippets system more prominent
- Added support for the Cloud Only package
- Added ability to upload to My Cloud directly from the Divi Library

v1.9.8 - 31/05/19
- Added permissions framework so parts of DC can be turned on or off at account level.
- Added ability to place a wl.php file in the root of the LC plugin and it will automatically enter the api key and set up white labelling. Note the constants can be defined anywhere, not just in the LC root
- Save content to my cloud from the VB
- Recover content from my cloud from the VB
- Load LC layouts from LC from the VB

v1.9.9 - 07/01/20
- Fixed issue with the Divi Builder whereby Divi Premade layouts wouldn't import when LC was active.
- Fixed jQuery error in VB console

v2.0 - 06/03/20
- Completely refactored codebase and design. Comprising the following and more...
- Multi API Key management from within the plugin (with different levels of permission at key level)
- Improved tabbed based settings interface
- First use splash screen to facilitate the journey for new users
- Syntax highlighting for the snippet system for easier legibility
- Snippet categorisation (including add and delete for snippet categories)
- My Cloud Layout categorisation (including new delete functionality)
- New List View option in My Cloud
- Various settings added to new settings tab. Layouts per page, default view, sort ordering etc...
- New ability to edit the names of your My Cloud layout items
- New notes field for My Cloud layout items. Great for storing general descriptions for your white label customers or chunks of CSS etc
- New AJAX Spinner when API calls are being made complete with a description of what it's actually doing. Saving
- New and improved layout for LC Layouts (sections and layouts) and my Cloud
- New Spotlight view for both LC Layouts and My Cloud allowing a clearer way of previewing a layout and quick links to other layouts in the same set
- Split date based categories out of the categories filter for easier use
- Save Posts, Pages and Projects to My Cloud without having to first save them to the Divi Library. Available directly from the page list in wp-admin
- Added fallback method of API requests for those who were having connection issues
- Save more than one layout to the cloud at a time (BETA: best with a max of 5/6 for now)
- Refactored code heavily to make maintenance easier.

v2.0.1 - 14/03/20
- Added fallback connection for those servers who can't connect directly to layoutscloud.com

v2.1 - 27/05/20
- Restyled plugin for a more contemporary feel and to fit in with the SitePresser Brand
- Added ability to add notes to snippets
- Added ability to rename snippets
- Fixed bug in layout naming whereby it needed a description as well if not it would not save
- Fixed snippets view where orange box showed even when no categories were selected

v2.1.1 - 27/06/20
- Fixed minor JS issue with saving a layout name/description
- Fixed issue with the VB integration

*/

//ini_set( 'display_errors', 'on' );
//error_reporting( E_ALL );

define('DU_VERSION', '2.1.1');

define('DU_FILE', trailingslashit(dirname(__FILE__)));
define('DU_BASENAME', plugin_basename(__FILE__));
define('DU_URL', trailingslashit(plugin_dir_url(__FILE__)));
define('DU_IMAGE_URL', DU_URL . 'images/');
define('DU_STYLE_URL', DU_URL . 'includes/styles/');
define('DU_SCRIPT_URL', DU_URL . 'includes/scripts/');

if (isset($_GET['du_debug'])) {
    define('DU_DEBUG', true);
} else {
    define('DU_DEBUG', false);
}

//includes
require_once(DU_FILE . 'includes/admin.php');
require_once(DU_FILE . 'includes/api.php');
require_once(DU_FILE . 'includes/wl.php');
require_once(DU_FILE . 'includes/updates.php');
require_once(DU_FILE . 'includes/help.php');

if (DU_DEBUG) {
    require_once(DU_FILE . 'includes/debug.php');
}

//only returns when du_debug is active. Otherwise nothing (normal operation)
function du_debug($msg)
{
    if (!DU_DEBUG) {
        $msg = '';
    } else {
        $start = '<p>------------------------------------------------------------------------------------------------------------------------------------------------<br />';
        if ($bt = @debug_backtrace()[2]) {
            $start .= '<code><strong>' . $bt['file'] . ' (' . $bt['line'] . ') in function "' . $bt['function'] . '"</strong></code><br />';
            $start .= '------------------------------------------------------------------------------------------------------------------------------------------------</p>';
        }

        $msg = $start . $msg;
    }

    return $msg;
}


//for file based white labelling
if (file_exists(trailingslashit(dirname(__FILE__)) . 'wl.php')) {
    require_once('wl.php');
}

if (get_option('du_use_relay')) {
    add_filter('du_remote_site', 'du_remote_site_use_relay');
}

$du_remote_site = apply_filters('du_remote_site', 'https://layoutscloud.com/');
//$du_remote_site = 'http://wp.dev/';

add_action('plugins_loaded', 'du_init');

//remove_filter( 'et_fb_get_asset_helpers', 'et_fb_get_asset_helpers', 10, 2 );
//add_filter( 'et_fb_get_asset_helpers', 'du_et_fb_get_asset_helpers', 50, 2 ); //tried this but needs work. to add in a later version

function du_init()
{

    if (defined('DU_API_KEY')) {
        if (!get_option('du_api_key')) {
            update_option('du_api_key', DU_API_KEY);
            update_option('du_api_key_active', 1);
        }
    }

    du_get_constants();

    //add_action('wp_enqueue_scripts', 'du_enqueue_scripts');
    add_action('admin_enqueue_scripts', 'du_admin_general_scripts');
    add_action('admin_print_scripts-post-new.php', 'du_admin_scripts');
    add_action('admin_print_scripts-post.php', 'du_admin_scripts');

    if (isset($_GET['et_fb'])) {
        add_action('wp_enqueue_scripts', 'du_admin_scripts');
    }

    add_action('admin_print_scripts', 'du_conditional_admin_scripts');
    add_action('admin_menu', 'du_menu');
    //add_action( 'admin_head', 'du_admin_head' );
    add_action('admin_notices', 'du_enter_key');

    add_filter('post_row_actions', 'du_post_row_actions', 20, 2);
    add_filter('page_row_actions', 'du_post_row_actions', 20, 2);

    add_filter('manage_et_pb_layout_posts_columns', 'du_library_column_headers');
    add_filter('manage_project_posts_columns', 'du_library_column_headers');
    add_filter('manage_page_posts_columns', 'du_library_column_headers');
    add_action('manage_et_pb_layout_posts_custom_column', 'du_library_column', 10, 2);
    add_action('manage_project_posts_custom_column', 'du_library_column', 10, 2);
    add_action('manage_page_posts_custom_column', 'du_library_column', 10, 2);
    //add_filter('et_pb_all_fields_unprocessed_et_pb_section', 'du_add_section_setting', 100);

    add_action('wp_ajax_lc_save_vb_layout', 'du_save_layout', 999);
    add_action('wp_ajax_lc_et_builder_library_get_layout', 'du_load_vb_layout', 999);
    add_filter('et_builder_load_actions', 'du_et_builder_load_actions', 999, 10);
    add_filter('et_builder_library_modal_custom_tabs', 'du_fb_library_add_tab');
    add_filter('et_builder_library_custom_layouts', 'du_fb_library_add_tab_content');

    add_filter('pre_set_site_transient_update_plugins', 'du_check_update');

    //add_filter( 'all_plugins', 'du_all_plugins', 10, 4 );
    add_action('admin_init', 'du_show_changelog');
    add_action('admin_bar_menu', 'du_toolbar_links', 999);

    //bulk actions
    add_filter('bulk_actions-edit-post', 'du_register_bulk_actions');
    add_filter('bulk_actions-edit-page', 'du_register_bulk_actions');
    add_filter('bulk_actions-edit-et_pb_library', 'du_register_bulk_actions');
    add_filter('handle_bulk_actions-edit-post', 'du_bulk_action_handler', 10, 3);
    add_filter('handle_bulk_actions-edit-page', 'du_bulk_action_handler', 10, 3);
    add_filter('handle_bulk_actions-edit-et_pb_library', 'du_bulk_action_handler', 10, 3);
    add_action('admin_notices', 'du_bulk_action_admin_notice');


    add_action('init', 'du_handle_api');

}

function du_remote_site_use_relay($url)
{
    $url = 'https://sean-barton.co.uk/du.php';

    return $url;
}

// Used to update the content of the cached helper js file.
function du_et_fb_get_asset_helpers($content, $post_type)
{
    $helpers = et_fb_get_static_backend_helpers($post_type);

    $helpers['pageCreationOptions']['du'] = array(
        'className' => 'accent-purple',
        'imgSrc' => 'premade.png',
        'imgSrcHover' => 'premade.gif',
        'titleText' => DU_NAME,
        'descriptionText' => 'Simply click the three purple dots at the bottom of the page, the + button and finally the ' . DU_NAME . ' tab.',
        'buttonText' => 'Use ' . DU_NAME,
        'permission' => array('load_layout')
    );

    //print_r( $helpers );

    return sprintf(
        'window.ETBuilderBackend = jQuery.extend(true, %s, window.ETBuilderBackendDynamic)',
        et_fb_remove_site_url_protocol(wp_json_encode($helpers, ET_BUILDER_JSON_ENCODE_OPTIONS))
    );
}

function du_et_builder_load_actions($actions)
{
    $actions[] = 'lc_save_vb_layout';
    $actions[] = 'lc_et_builder_library_get_layout';

    return $actions;
}

function du_fb_library_add_tab($custom_tabs)
{
    $custom_tabs['du'] = DU_NAME;
    $custom_tabs['du_my_cloud'] = __('My Cloud', 'du');

    return $custom_tabs;
}

function du_load_vb_layout()
{
    et_core_security_check('edit_posts', 'et_builder_library_get_layout', 'nonce');

    $id = isset($_POST['id']) ? (int)$_POST['id'] : 0;

    if (empty($id)) {
        wp_send_json_error();
    }

    $result = array();
    $id *= -1; //flip it back so we know what id to ask LC for
    $type = du_get_layout_type($id);

    if ($type == 'core') {
        $imported_layout = du_get_layout($id);
    } else { //user
        $imported_layout = du_get_own_layout($id);
    }

    if ($imported_layout['error_success']) {
        $post = get_post($imported_layout['import_id']);
        $post_content = $post->post_content;
        $post_content = et_fb_process_shortcode(stripslashes($post_content));

        $result['savedShortcode'] = $post_content;
    }

    $response = wp_json_encode(array(
        'success' => $imported_layout['error_success'],
        'data' => $result,
    ));

    $tmp_dir = function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '/tmp';

    $tmp_file = tempnam($tmp_dir, 'et');

    @file_put_contents($tmp_file, $response);

    // Remove any previous buffered content since we're setting `Content-Length` header
    // based on $response value only.
    while (ob_get_level()) {
        ob_end_clean();
    }

    header('Content-Length: ' . @filesize($tmp_file));

    @unlink($tmp_file);

    // Charset has to be explicitly mentioned when it is other than UTF-8.
    @header('Content-Type: application/json; charset=' . esc_attr(get_option('blog_charset')));

    die(et_core_intentionally_unescaped($response, 'html'));
}

function du_fb_library_add_tab_content($custom_tabs = array())
{
    $white_label = get_option('du_white_labelling', array());

    if (!$white_label['disable_dc']) {
        if ($layouts = du_get_cached_layouts()) {
            $prepped_layouts = array();
            $ct_cats = array();
            $ct_sets = array();

            $limit = 5000;
            $i = 0;

            /*$transient = array( 'layouts'    => $layouts,
                                'sets'       => $return['sets'],
                                'categories' => $return['categories']
            );*/

            $used_cats = array();

            foreach ($layouts['layouts'] as $layout) {
                $i++;

                $id = (int)$layout['id'];
                $id *= -1; //so the builder recognises it as LC

                $alayout = new stdClass();
                $alayout->id = $id;
                $alayout->status = 'Published';
                $alayout->name = html_entity_decode($layout['name']);
                $alayout->url = $layout['iframe'];
                $alayout->categories = array_keys($layout['categories']);
                $alayout->category_ids = $layout['categories'];

                $used_cats = array_merge($used_cats, array_keys($layout['categories']));

                $alayout->thumbnail = $layout['image'];
                $alayout->thumbnail_small = $layout['image'];
                $alayout->screenshot = $layout['image'];

                $prepped_layouts[$id] = $alayout;

                if ($i >= $limit) {
                    break;
                }
            }

            /*
            foreach ( $layouts['category_lookup'] as $cat_id => $post_ids ) {
                //if (!in_array($cat_id, $used_cats)) {
                    //continue;
                //}

                $ct_cats[ $cat_id ]          = new stdClass();
                $ct_cats[ $cat_id ]->id      = $cat_id;
                $ct_cats[ $cat_id ]->layouts = $post_ids;
                $ct_cats[ $cat_id ]->slug    = sanitize_title( $layouts['categories'][ $cat_id ] );
                $ct_cats[ $cat_id ]->name    = $layouts['categories'][ $cat_id ];
            }
            foreach ( $layouts['set_lookup'] as $set_id => $post_ids ) {
                $ct_sets[ $set_id ]          = new stdClass();
                $ct_sets[ $set_id ]->category_ids      = $cat_id;
                $ct_sets[ $set_id ]->category_slug      = sanitize_title( $layouts['sets'][ $set_id ] );
                $ct_sets[ $set_id ]->id      = $set_id;
                $ct_sets[ $set_id ]->date      = '2019-05-01';
                $ct_sets[ $set_id ]->layouts = $post_ids;
                $ct_sets[ $set_id ]->screenshot = 'test.png';
                $ct_sets[ $set_id ]->thumbnail = 'test.png';
                $ct_sets[ $set_id ]->description = 'this is a test';
                $ct_sets[ $set_id ]->slug    = sanitize_title( $layouts['sets'][ $set_id ] );
                $ct_sets[ $set_id ]->name    = $layouts['sets'][ $set_id ];
            }
            */

            $custom_tabs['du'] = array(
                'categories' => array(), //$ct_cats,
                'packs' => array(), //$ct_sets,
                'layouts' => $prepped_layouts,
                'options' => array(
                    'content' => array(
                        'title' => array(
                            __('%d Layouts'),
                            __('%d Layout')
                        ),
                    ),
                    'sidebar' => array(), //array(__( 'Find A Layout' )),
                    'list' => array('columns' => array('status' => __('Status'))),
                ),
                'sorted' => array(
                    'categories' => array(), //array_keys( $layouts['categories'] ),
                    'packs' => array(), //$layouts['sets'],
                ),
            );
        }
    }

    ///////////////////////////////////////////////////////////////

    if ($layouts = du_get_my_cloud()) {
        if ($layouts['error_success']) {
            $prepped_layouts = array();

            if (isset($layouts['content']) && is_array($layouts['content'])) {
                if (count($layouts['content'])) {

                    $ct_cats = array();
                    $ct_sets = array();

                    foreach ($layouts['content'] as $layout) {
                        //for white labelling
                        if (isset($white_label['cats']) && count($white_label['cats'])) {
                            $in_cat = false;

                            foreach ($white_label['cats'] as $cat => $ignore) {
                                if (in_array($cat, array_keys($layout['categories']))) {
                                    $in_cat = true;
                                    break;
                                }
                            }

                            if (!$in_cat) {
                                continue; //don't show this one
                            }
                        }

                        $id = (int)$layout['id'];
                        $id *= -1; //so the builder recognises it as LC

                        $alayout = new stdClass();
                        $alayout->id = $id;
                        $alayout->status = 'Published';
                        $alayout->name = html_entity_decode($layout['name']);
                        $alayout->url = $layout['url'];
                        //$alayout->categories   = array_keys( $layout['categories'] );
                        //$alayout->category_ids = $layout['categories'];

                        $alayout->thumbnail = $layout['image'];
                        $alayout->thumbnail_small = $layout['image'];
                        $alayout->screenshot = $layout['image'];

                        $prepped_layouts[$id] = $alayout;

                    }
                }

                $custom_tabs['du_my_cloud'] = array(
                    'categories' => array(), //$ct_cats,
                    'packs' => array(), //$ct_sets,
                    'layouts' => $prepped_layouts,
                    'options' => array(
                        'content' => array(
                            'title' => array(
                                __('%d Layouts'),
                                __('%d Layout')
                            ),
                        ),
                        'sidebar' => array(), //array(__( 'Find A Layout' )),
                        'list' => array('columns' => array('status' => __('Status'))),
                    ),
                    'sorted' => array(
                        'categories' => array(), //array_keys( $layouts['categories'] ),
                        'packs' => array(), //$layouts['sets'],
                    ),
                );

            }
        }
    }

    //$custom_tabs['du'] = '<div class="et-pb-main-settings et-pb-main-settings-full du-tab du-tab-layout">Loading... one moment</div>';

    return $custom_tabs;
}

function du_save_layout()
{

    if (isset($_POST['et_layout_type']) && $_POST['et_layout_type'] == 'layout') {

        $content = et_fb_process_to_shortcode(json_decode(stripslashes($_POST['et_layout_content']), true));

        $areturn = du_save_to_cloud($_POST['et_layout_name'], $content, $_POST['et_layout_type']);

        echo $areturn;
        die(($areturn === true ? '1' : $areturn));

    }
}

function du_library_column_headers($columns)
{
    if (du_has_permission('upload')) {
        $columns['du_cloud'] = __('Exported to ' . DU_NAME, 'layouts-cloud');
    }

    return $columns;
}

function du_library_column($column, $post_id)
{
    switch ($column) {

        case 'du_cloud' :
            echo '<span class="du-imported">' . get_post_meta($post_id, 'du_uploaded_to_cloud', true) . '</span>';
            break;

    }
}

function du_is_divi_by_id($id)
{
    $return = false;
    $divi_post = get_post($id);

    if (get_post_meta($id, '_et_pb_use_builder', true)) {
        $return = true;
    } else if (strpos($divi_post->post_content, '[et_pb') !== false) {
        $return = true;
    }

    return $return;
}

function du_post_row_actions($actions, $post)
{
    $pts = array('et_pb_layout', 'project', 'page');

    if (isset($_GET['post_type']) && in_array($_GET['post_type'], $pts) && du_is_divi_by_id($post->ID)) {

        if (du_has_permission('upload')) {
            $onclick = 'du_save_to_cloud_from_library(' . $post->ID . ');';
            $actions['layouts-cloud-export'] = '<a class="du_link_save_to_cloud" style="cursor: pointer;" onclick="' . $onclick . '">Save to My Cloud</a>';
        }
    }

    return $actions;
}

function du_admin_head()
{
    if (!isset($_GET['page']) || !in_array($_GET['page'], array('du_admin_home', 'layouts_cloud'))) {
        return;
    }

}

function du_toolbar_links($wp_admin_bar)
{
    if (du_has_permission('du_layouts')) {
        $url_root = admin_url('admin.php?page=du_admin_home');
        $types = array(
            'layout' => 'Layouts',
            //'section' => 'Sections',
            //'module'  => 'Modules',
            //'navigation-bar' => 'Navigation Bars',
            //'skin' => 'Site Skins',
        );

        if (du_has_permission('snippets')) {
            $types['snippet'] = 'Code/Text Snippets';
        }

        $args = array(
            'id' => 'divi-cloud',
            'title' => DU_NAME,
            'href' => $url_root,
            'meta' => array(
                'class' => 'divi-cloud',
                'title' => DU_NAME . ' Gallery View'
            )
        );
        $wp_admin_bar->add_node($args);

        foreach ($types as $name => $label) {
            $args = array(
                'id' => 'divi-cloud-' . $name,
                'title' => $label,
                'href' => $url_root . '&layout_type=' . $name,
                'parent' => 'divi-cloud'
            );
            $wp_admin_bar->add_node($args);
        }
    }

}

function du_save_section()
{
    if (!current_user_can('edit_posts')) {
        die(-1);
    }

    if (empty($_POST['et_layout_name'])) {
        die();
    }

    $args = array(
        'layout_type' => isset($_POST['et_layout_type']) ? sanitize_text_field($_POST['et_layout_type']) : 'section',
        'layout_new_cat' => isset($_POST['et_layout_new_cat']) ? sanitize_text_field($_POST['et_layout_new_cat']) : '',
        'columns_layout' => isset($_POST['et_columns_layout']) ? sanitize_text_field($_POST['et_columns_layout']) : '0',
        'module_type' => isset($_POST['et_module_type']) ? sanitize_text_field($_POST['et_module_type']) : 'et_pb_unknown',
        'layout_content' => isset($_POST['et_layout_content']) ? $_POST['et_layout_content'] : '',
        'layout_name' => isset($_POST['et_layout_name']) ? sanitize_text_field($_POST['et_layout_name']) : '',
    );

    //print_r($args);

    //$new_layout_meta = et_pb_submit_layout( $args );
    //die( $new_layout_meta );
}

add_action('wp_ajax_et_pb_save_layout', 'du_save_section', 1, 1);


?>
