function wpddl_save_post($pidd)
 {
     global $wpddlayout;
     if ($_POST && isset($_POST['action']) && $_POST['action'] != 'inline-save') {
         // Don't save in quick edit mode.
         $layout_data = $wpddlayout->post_types_manager->get_layout_to_type_object(get_post_type($pidd));
         $layout_template = isset($_POST['layouts_template']) && $_POST['layouts_template'] ? $_POST['layouts_template'] : null;
         if ($layout_template) {
             $layout_selected = $layout_template;
             if (isset($_POST['page_template']) && $wpddlayout->template_have_layout($_POST['page_template']) === false || $layout_selected == '0') {
                 if (isset($_POST['action']) && $_POST['action'] === 'wcml_update_product') {
                     return;
                 }
                 $wpddlayout->individual_assignment_manager->remove_layout_from_post_db($pidd);
             } else {
                 WPDD_Utils::assign_layout_to_post_object($pidd, $layout_selected, null);
             }
         } elseif (!empty($layout_data->layout_id) && is_null($layout_template)) {
             if (isset($_POST['action']) && $_POST['action'] === 'wcml_update_product') {
                 return;
             }
             WPDD_Utils::remove_layout_assignment_to_post_object($pidd, '', true);
         } else {
             // when we set a non-layout template after a layout has been set
             $meta = get_post_meta($pidd, WPDDL_LAYOUTS_META_KEY, true);
             if ($meta) {
                 if (isset($_POST['action']) && $_POST['action'] === 'wcml_update_product') {
                     return;
                 }
                 WPDD_Utils::remove_layout_assignment_to_post_object($pidd, $meta, false);
             }
         }
     }
 }
 public function update_single_post_layout($slug, $post_id, $post_type, $template = false)
 {
     $tpl = $template ? $template : $this->get_layout_template_for_post_type($post_type);
     $ret = WPDD_Utils::assign_layout_to_post_object($post_id, $slug, $tpl, get_post_meta($post_id, self::META_KEY, true));
     return $ret;
 }