Пример #1
0
function layotter_ajax_save_new_template()
{
    $post_data = layotter_get_angular_post_data();
    // type and field values are required
    if (isset($post_data['type']) and is_string($post_data['type'])) {
        if (isset($post_data['values'])) {
            $values = $post_data['values'];
        } else {
            $values = array();
        }
        $element = Layotter::create_element($post_data['type'], $values);
        if ($element) {
            $template = Layotter_Templates::save($element);
            echo json_encode($template->to_array());
        }
    }
    die;
    // required by Wordpress after any AJAX call
}