public function remove_display_flag($flagorflags) { $flagorflags = is_array($flagorflags) ? $flagorflags : array($flagorflags); foreach ($flagorflags as $flag) { wpbdp_array_remove_value($this->display_flags, $flag); } }
public function remove_category($category, $remove_fee = true, $cleanup = false) { global $wpdb; $category_id = intval(is_object($category) ? $category->term_id : $category); if ($remove_fee) { $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}wpbdp_listing_fees WHERE listing_id = %d AND category_id = %d", $this->id, $category_id)); } $listing_terms = wp_get_post_terms($this->id, WPBDP_CATEGORY_TAX, array('fields' => 'ids')); wpbdp_array_remove_value($listing_terms, $category_id); wp_set_post_terms($this->id, $listing_terms, WPBDP_CATEGORY_TAX); if ($cleanup) { // Remove all payment items related to this category. $payment_ids = $wpdb->get_col($wpdb->prepare("SELECT p.id FROM {$wpdb->prefix}wpbdp_payments p WHERE p.listing_id = %d AND\n p.status = %s AND\n EXISTS( SELECT 1 FROM {$wpdb->prefix}wpbdp_payments_items pi WHERE pi.payment_id = p.id\n AND pi.item_type IN (%s, %s) AND pi.rel_id_1 = %d)", $this->id, 'pending', 'fee', 'recurring_fee', $category_id)); foreach ($payment_ids as $pid) { $payment = WPBDP_Payment::get($pid); $items = $payment->get_items(array('item_type' => array('fee', 'recurring_fee'), 'rel_id_1' => $category_id)); foreach ($items as &$item) { $payment->delete_item($item); } $payment->save(); } } }
public function ajax_listing_submit_image_delete() { $res = new WPBDP_Ajax_Response(); $image_id = intval($_REQUEST['image_id']); if (!$image_id) { $res->send_error(); } $state_id = isset($_REQUEST['state_id']) ? $_REQUEST['state_id'] : ''; if ($state_id) { require_once WPBDP_PATH . 'core/view-submit-listing.php'; if (!$state_id) { $res->send_error(); } $state = WPBDP_Listing_Submit_State::get($state_id); if (!$state || !in_array($image_id, $state->images)) { $res->send_error(); } wpbdp_array_remove_value($state->images, $image_id); $state->save(); } wp_delete_attachment($image_id, true); $res->add('imageId', $image_id); $res->send(); }