private function remove_post_meta_for_post_type($post_type, $layout_string)
 {
     $layout_id = explode('layout_', $layout_string);
     $layout_id = isset($layout_id[1]) ? $layout_id[1] : $layout_string;
     $posts = $this->get_all_posts_of_post_type_obj($post_type);
     $layout = get_post($layout_id);
     foreach ($posts->ids as $id) {
         $meta = get_post_meta($id, self::META_KEY, true);
         if ($layout->post_name === $meta) {
             WPDD_Utils::remove_layout_assignment_to_post_object($id, $meta, true);
         }
     }
     $this->remove_track_batched_post_types($post_type, $layout_id);
 }
 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 remove_layout_from_post_db($post_id)
 {
     $meta = get_post_meta($post_id, WPDDL_LAYOUTS_META_KEY, true);
     WPDD_Utils::remove_layout_assignment_to_post_object($post_id, $meta, true);
 }