| @@ -145,56 +145,33 @@ | ||
| 145 | 145 | public static function deleted_post( $post_id, $post ) { |
| 146 | 146 | if ( BuilderFns::$post_type_tb !== $post->post_type ) { |
| 147 | 147 | return; |
| 148 | 148 | } |
| 149 | + $options = BuilderFns::option_name_for_specific_product_set_default( $post_id ); | |
| 149 | 150 | |
| 150 | - $options = BuilderFns::option_name_for_specific_product_set_default( $post_id ); | |
| 151 | - TemplateSettings::instance()->delete_option( $options ); | |
| 151 | + if ( TemplateSettings::instance()->get_option( $options ) ) { | |
| 152 | + TemplateSettings::instance()->delete_option( $options ); | |
| 153 | + } | |
| 152 | 154 | |
| 153 | 155 | $template_options = BuilderFns::option_name_by_template_id( $post_id ); |
| 154 | - TemplateSettings::instance()->delete_option( $template_options ); | |
| 156 | + if ( TemplateSettings::instance()->get_option( $template_options ) ) { | |
| 157 | + TemplateSettings::instance()->delete_option( $template_options ); | |
| 158 | + } | |
| 155 | 159 | |
| 156 | 160 | $archive_options = BuilderFns::archive_option_name_by_template_id( $post_id ); |
| 157 | - TemplateSettings::instance()->delete_option( $archive_options ); | |
| 161 | + if ( TemplateSettings::instance()->get_option( $archive_options ) ) { | |
| 162 | + TemplateSettings::instance()->delete_option( $archive_options ); | |
| 163 | + } | |
| 158 | 164 | |
| 159 | 165 | $category_options = BuilderFns::option_name_for_specific_category_set_default( $post_id ); |
| 160 | - TemplateSettings::instance()->delete_option( $category_options ); | |
| 166 | + if ( TemplateSettings::instance()->get_option( $category_options ) ) { | |
| 167 | + TemplateSettings::instance()->delete_option( $category_options ); | |
| 168 | + } | |
| 161 | 169 | |
| 162 | 170 | $selected_category_options = BuilderFns::archive_option_name_by_template_id( $post_id ); |
| 163 | - TemplateSettings::instance()->delete_option( $selected_category_options ); | |
| 164 | - | |
| 165 | - // Delete Data From Options. | |
| 166 | - $options_product_selected_cat = BuilderFns::option_name_product_page_selected_cat( $post_id ); | |
| 167 | - $cat_list = TemplateSettings::instance()->get_option( $options_product_selected_cat ); | |
| 168 | - if ( ! empty( $cat_list ) ) { | |
| 169 | - foreach ( $cat_list as $old_slug ) { | |
| 170 | - $OldcatList = get_term_by( 'slug', $old_slug, 'product_cat' ); | |
| 171 | - if ( ! empty( $OldcatList ) && ! is_wp_error( $OldcatList ) ) { | |
| 172 | - delete_term_meta( $OldcatList->term_id, BuilderFns::$categories_product_page_template, $post_id ); | |
| 173 | - } | |
| 174 | - } | |
| 171 | + if ( TemplateSettings::instance()->get_option( $selected_category_options ) ) { | |
| 172 | + TemplateSettings::instance()->delete_option( $selected_category_options ); | |
| 175 | 173 | } |
| 176 | - TemplateSettings::instance()->delete_option( $options_product_selected_cat ); | |
| 177 | - | |
| 178 | - $set_default_option = BuilderFns::option_name_product_page_specific_cat_set_default( $post_id ); | |
| 179 | - TemplateSettings::instance()->delete_option( $set_default_option ); | |
| 180 | - | |
| 181 | - // Tags Remove. | |
| 182 | - $options_product_selected_tag = BuilderFns::option_name_product_page_selected_tag( $post_id ); | |
| 183 | - $tag_list = TemplateSettings::instance()->get_option( $options_product_selected_tag ); | |
| 184 | - if ( ! empty( $tag_list ) ) { | |
| 185 | - foreach ( $tag_list as $old_slug ) { | |
| 186 | - $OldTagList = get_term_by( 'slug', $old_slug, 'product_tag' ); | |
| 187 | - if ( ! empty( $OldTagList ) && ! is_wp_error( $OldTagList ) ) { | |
| 188 | - delete_term_meta( $OldTagList->term_id, BuilderFns::$tags_product_page_template, $post_id ); | |
| 189 | - } | |
| 190 | - } | |
| 191 | - } | |
| 192 | - TemplateSettings::instance()->delete_option( $options_product_selected_tag ); | |
| 193 | - | |
| 194 | - // Tag Set Default Option. | |
| 195 | - $tag_set_default_option = BuilderFns::option_name_product_page_specific_tag_set_default( $post_id ); | |
| 196 | - TemplateSettings::instance()->delete_option( $tag_set_default_option ); | |
| 197 | 174 | |
| 198 | 175 | global $wpdb; |
| 199 | 176 | // Prepare and execute the SQL query. |
| 200 | 177 | $sql = $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", BuilderFns::$view_template_for_products_meta, $post_id ); |