Elementor\TemplateLibrary\Source_Local::save_item PHP Method

save_item() public method

public save_item ( $template_data )
    public function save_item($template_data)
    {
        if (!empty($template_data['type']) && !in_array($template_data['type'], self::get_template_types())) {
            return new \WP_Error('save_error', 'The specified template type doesn\'t exists');
        }
        $post_id = wp_insert_post(['post_title' => !empty($template_data['title']) ? $template_data['title'] : __('(no title)', 'elementor'), 'post_status' => 'publish', 'post_type' => self::CPT]);
        if (is_wp_error($post_id)) {
            return $post_id;
        }
        Plugin::instance()->db->save_editor($post_id, $template_data['data']);
        Plugin::instance()->db->set_edit_mode($post_id);
        update_post_meta($post_id, self::TYPE_META_KEY, $template_data['type']);
        wp_set_object_terms($post_id, $template_data['type'], self::TAXONOMY_TYPE_SLUG);
        return $post_id;
    }