コード例 #1
0
ファイル: ajax.php プロジェクト: hingst/layotter
function layotter_ajax_update_template()
{
    $post_data = layotter_get_angular_post_data();
    // type and field values are required
    if (isset($post_data['template_id']) and is_int($post_data['template_id'])) {
        $id = $post_data['template_id'];
        $template = Layotter_Templates::get($id);
        if ($template) {
            $values = Layotter_ACF::unwrap_post_values();
            $element = Layotter::create_element($template['type'], $values);
            if ($element) {
                $element->set_template_id($id);
                Layotter_Templates::update($id, $element->get_template_data());
                echo json_encode($element->to_array());
            }
        }
    }
    die;
    // required by Wordpress after any AJAX call
}