public function unlinkTranslationFor($objectId, $objectKind) { // Trash the translations' WP_Post first global $wpdb; $this->logger->logQueryStart(); $locales = Strata::i18n()->getLocales(); $app = Strata::app(); foreach ($locales as $locale) { if ($objectKind === "WP_Post" && $locale->isTranslationOfPost($objectId)) { $translation = $locale->getTranslatedPost($objectId); if (!is_null($translation)) { wp_trash_post($translation->ID); } } elseif ($objectKind === "Term" && $locale->hasTermTranslation($objectId)) { $translation = $locale->getTranslatedTerm($objectId); if (!is_null($translation)) { wp_delete_term($translation->term_id); } } } // Then delete all the polyglot references // to that original post. $result = $wpdb->delete($wpdb->prefix . 'polyglot', array("translation_of" => $objectId, "obj_kind" => $objectKind)); $this->logger->logQueryCompletion($wpdb->last_query); return $result; }
/** * @param int $tt_id term taxonomy id of the deleted term * @param string $taxonomy taxonomy of the deleted term */ function delete_term_actions($tt_id, $taxonomy) { $icl_el_type = 'tax_' . $taxonomy; if ($this->sitepress->get_setting('sync_delete_tax') && $this->delete_recursion_flag === false) { // only for translated $lang_details = $this->sitepress->get_element_language_details($tt_id, $icl_el_type); if (empty($lang_details->source_language_code)) { // get translations $trid = $this->sitepress->get_element_trid($tt_id, $icl_el_type); $translations = $this->sitepress->get_element_translations($trid, $icl_el_type); $this->delete_recursion_flag = true; // delete translations remove_filter('get_term', array($this->sitepress, 'get_term_adjust_id'), 1); foreach ($translations as $translation) { if ((int) $translation->element_id !== (int) $tt_id) { wp_delete_term($translation->term_id, $taxonomy); } } add_filter('get_term', array($this->sitepress, 'get_term_adjust_id'), 1, 1); $this->delete_recursion_flag = false; } } $update_args = array('element_id' => $tt_id, 'element_type' => $icl_el_type, 'context' => 'tax'); do_action('wpml_translation_update', array_merge($update_args, array('type' => 'before_delete'))); $this->wpdb->delete($this->wpdb->prefix . 'icl_translations', array('element_type' => $icl_el_type, 'element_id' => $tt_id)); do_action('wpml_translation_update', array_merge($update_args, array('type' => 'after_delete'))); }
public function cleanup($opt = NULL, $cpt = NULL, $tax = NULL) { // Perform security checks. if (self::authorize() == TRUE) { // Remove plugin options from wp_options database table. if ($opt) { foreach ($opt as $option) { delete_option($option); } } // Remove plugin-specific custom post type entries. if ($cpt) { $entries = get_posts(array('post_type' => $cpt, 'numberposts' => -1)); foreach ($entries as $entry) { wp_delete_post($entry->ID, TRUE); } } // Remove plugin-specific custom taxonomy terms. if ($tax) { global $wp_taxonomies; foreach ($tax as $taxonomy) { register_taxonomy($taxonomy['taxonomy'], $taxonomy['object_type']); $terms = get_terms($taxonomy['taxonomy'], array('hide_empty' => 0)); foreach ($terms as $term) { wp_delete_term($term->term_id, $taxonomy['taxonomy']); } delete_option($taxonomy['taxonomy'] . '_children'); unset($wp_taxonomies[$taxonomy['taxonomy']]); } } } }
function uninstall($blog_id = false) { // delete all taxonomy terms register_taxonomy('gn-genre', null); $terms = get_terms('gn-genre', array('hide_empty' => false)); if (is_array($terms)) { foreach ($terms as $term) { wp_delete_term($term->term_id, 'gn-genre'); } } // remove plugin settings delete_option('xmlsf_version'); delete_option('xmlsf_sitemaps'); delete_option('xmlsf_post_types'); delete_option('xmlsf_taxonomies'); delete_option('xmlsf_news_sitemap'); delete_option('xmlsf_ping'); delete_option('xmlsf_robots'); delete_option('xmlsf_urls'); delete_option('xmlsf_custom_sitemaps'); delete_option('xmlsf_domains'); delete_option('xmlsf_news_tags'); // make rewrite rules update at the appropriate time delete_option('rewrite_rules'); // Kilroy was here if ($blog_id) { error_log('XML Sitemap Feeds settings cleared from site ' . $blog_id . '.'); } else { error_log('XML Sitemap Feeds settings cleared before uninstall.'); } }
function deleteData() { global $wpdb; delete_option('asgarosforum_options'); delete_option('asgarosforum_db_version'); // For site options in multisite delete_site_option('asgarosforum_options'); delete_site_option('asgarosforum_db_version'); // Delete user meta data delete_metadata('user', 0, 'asgarosforum_moderator', '', true); delete_metadata('user', 0, 'asgarosforum_banned', '', true); delete_metadata('user', 0, 'asgarosforum_subscription_topic', '', true); delete_metadata('user', 0, 'asgarosforum_subscription_forum', '', true); delete_metadata('user', 0, 'asgarosforum_subscription_global_topics', '', true); delete_metadata('user', 0, 'asgarosforum_unread_cleared', '', true); delete_metadata('user', 0, 'asgarosforum_unread_exclude', '', true); // Delete terms $terms = $wpdb->get_col('SELECT t.term_id FROM ' . $wpdb->terms . ' AS t INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = "asgarosforum-category";'); foreach ($terms as $term) { wp_delete_term($term, 'asgarosforum-category'); } // Drop custom tables $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_forums;"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_threads;"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_posts;"); // Delete uploaded files $upload_dir = wp_upload_dir(); $upload_path = $upload_dir['basedir'] . '/asgarosforum/'; recursiveDelete($upload_path); // Delete themes $theme_path = WP_CONTENT_DIR . '/themes-asgarosforum'; recursiveDelete($theme_path); // Delete data which has been used in old versions of the plugin. delete_metadata('user', 0, 'asgarosforum_lastvisit', '', true); }
/** * @ticket 23326 */ public function test_wp_delete_term_should_invalidate_cache() { global $wpdb; $this->set_up_three_posts_and_tags(); // Prime cache $terms = get_terms('post_tag'); $time1 = wp_cache_get('last_changed', 'terms'); $num_queries = $wpdb->num_queries; // Force last_changed to bump. wp_delete_term($terms[0]->term_id, 'post_tag'); $num_queries = $wpdb->num_queries; $this->assertNotEquals($time1, $time2 = wp_cache_get('last_changed', 'terms')); // last_changed and num_queries should bump after a term is deleted. $terms = get_terms('post_tag'); $this->assertEquals(2, count($terms)); $this->assertEquals($time2, wp_cache_get('last_changed', 'terms')); $this->assertEquals($num_queries + 1, $wpdb->num_queries); $num_queries = $wpdb->num_queries; // Again. last_changed and num_queries should remain the same. $terms = get_terms('post_tag'); $this->assertEquals(2, count($terms)); $this->assertEquals($time2, wp_cache_get('last_changed', 'terms')); $this->assertEquals($num_queries, $wpdb->num_queries); // @todo Repeat with term insert and update. }
/** * Uninstall Simmer. Sad face. * * @since 1.3.0 */ public static function uninstall() { global $wpdb; $on_uninstall = get_option('simmer_on_uninstall', 'delete_settings'); // Check that the user wants everything deleted with the plugin. if ('keep_all' == $on_uninstall) { return; } if ('delete_settings' == $on_uninstall || 'delete_all' == $on_uninstall) { // Delete options $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'simmer_%';"); } if ('delete_all' == $on_uninstall) { // Delete all recipes. $recipe_ids = get_posts(array('post_type' => 'recipe', 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids')); if ($recipe_ids) { foreach ($recipe_ids as $recipe_id) { wp_delete_post($recipe_id, true); } } // Delete all categories. $category_ids = get_terms('recipe_category', array('hide_empty' => false, 'fields' => 'ids')); if (!is_wp_error($category_ids) && !empty($category_ids)) { foreach ($category_ids as $category_id) { wp_delete_term($category_id, 'recipe_category'); } } // Remove the custom DB tables. $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "simmer_recipe_items"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "simmer_recipe_itemmeta"); } }
public function test_wp_insert_delete_term() { $taxonomy = 'wptests_tax'; register_taxonomy($taxonomy, 'post'); // a new unused term $term = rand_str(); $this->assertNull(term_exists($term)); $initial_count = wp_count_terms($taxonomy); $t = wp_insert_term($term, $taxonomy); $this->assertInternalType('array', $t); $this->assertNotWPError($t); $this->assertTrue($t['term_id'] > 0); $this->assertTrue($t['term_taxonomy_id'] > 0); $this->assertEquals($initial_count + 1, wp_count_terms($taxonomy)); // make sure the term exists $this->assertTrue(term_exists($term) > 0); $this->assertTrue(term_exists($t['term_id']) > 0); // now delete it add_filter('delete_term', array($this, 'deleted_term_cb'), 10, 5); $this->assertTrue(wp_delete_term($t['term_id'], $taxonomy)); remove_filter('delete_term', array($this, 'deleted_term_cb'), 10, 5); $this->assertNull(term_exists($term)); $this->assertNull(term_exists($t['term_id'])); $this->assertEquals($initial_count, wp_count_terms($taxonomy)); }
function spg_clean_data() { $easymedia_values = get_option('easy_media_opt'); if (is_array($easymedia_values) && array_key_exists($name, $easymedia_values)) { $keepornot = $easymedia_values['easymedia_disen_databk']; } if ($keepornot != '1') { //$wpdb->query("DELETE FROM `wp_options` WHERE `option_name` LIKE 'emediagallery_%'"); delete_option('easy_media_opt'); // Remove plugin-specific custom post type entries. $posts = get_posts(array('numberposts' => -1, 'post_type' => 'easymediagallery', 'post_status' => 'any')); foreach ($posts as $post) { wp_delete_post($post->ID, true); } // Remove plugin-specific custom taxonomies and terms. $tax = 'emediagallery'; if (is_taxonomy($tax)) { foreach ($tax as $taxonomy) { $terms = get_terms($taxonomy, array('get ' => 'all')); foreach ($terms as $term) { wp_delete_term($term->term_id, $taxonomy); } unset($wp_taxonomies[$taxonomy]); } } } else { } }
/** * Deletes a record from storage. * * @param \WordPress\Data\ModelInterface $model */ public function delete(ModelInterface $model) { if (!$model->term_id || !$model->taxonomy) { throw new \RuntimeException("Term must have 'term_id' and 'taxonomy' fields."); } $result = wp_delete_term($model->term_id, $model->taxonomy); return !is_wp_error($result); }
public function test_delete_term_is_synced() { wp_delete_term($this->term_object['term_id'], $this->taxonomy); $this->client->do_sync(); $terms = $this->get_terms(); $server_terms = $this->server_replica_storage->get_terms($this->taxonomy); $this->assertEquals($terms, $server_terms); }
/** * WP eCommerce Admin AJAX functions * * These are the WPSC Admin AJAX functions * * @package wp-e-commerce * @since 3.7 * * @uses update_option() Updates option in the database given key and value * @uses wp_delete_term() Removes term from the database * @uses fetch_rss() DEPRECATED * @uses wpsc_member_dedeactivate_subscriptions() @todo docs * @uses wpsc_member_deactivate_subscriptions() @todo docs * @uses wpsc_update_purchase_log_status() Updates the status of the logs for a purchase * @uses transaction_results() Main function for creating purchase reports * @uses wpsc_find_purchlog_status_name() Finds name of given status */ function wpsc_admin_ajax() { if (!wpsc_is_store_admin()) { return; } global $wpdb; if (isset($_POST['action']) && $_POST['action'] == 'product-page-order') { $current_order = get_option('wpsc_product_page_order'); $new_order = $_POST['order']; if (isset($new_order["advanced"])) { $current_order["advanced"] = array_unique(explode(',', $new_order["advanced"])); } if (isset($new_order["side"])) { $current_order["side"] = array_unique(explode(',', $new_order["side"])); } update_option('wpsc_product_page_order', $current_order); exit(print_r($order, 1)); } if (isset($_POST['save_image_upload_state']) && $_POST['save_image_upload_state'] == 'true' && is_numeric($_POST['image_upload_state'])) { $upload_state = (int) (bool) $_POST['image_upload_state']; update_option('wpsc_use_flash_uploader', $upload_state); exit("done"); } if (isset($_POST['remove_variation_value']) && $_POST['remove_variation_value'] == "true" && is_numeric($_POST['variation_value_id'])) { $value_id = absint($_GET['variation_value_id']); echo wp_delete_term($value_id, 'wpsc-variation'); exit; } if (isset($_REQUEST['log_state']) && $_REQUEST['log_state'] == "true" && is_numeric($_POST['id']) && is_numeric($_POST['value'])) { $newvalue = $_POST['value']; if ($_REQUEST['suspend'] == 'true') { if ($_REQUEST['value'] == 1 && function_exists('wpsc_member_dedeactivate_subscriptions')) { wpsc_member_dedeactivate_subscriptions($_POST['id']); } elseif (function_exists('wpsc_member_deactivate_subscriptions')) { wpsc_member_deactivate_subscriptions($_POST['id']); } exit; } else { $log_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '%d' LIMIT 1", $_POST['id']), ARRAY_A); if ($newvalue == 2 && function_exists('wpsc_member_activate_subscriptions')) { wpsc_member_activate_subscriptions($_POST['id']); } wpsc_update_purchase_log_status($_POST['id'], $newvalue); if ($newvalue > $log_data['processed'] && $log_data['processed'] < 2) { transaction_results($log_data['sessionid'], false); } $status_name = wpsc_find_purchlog_status_name($purchase['processed']); echo "document.getElementById(\"form_group_" . absint($_POST['id']) . "_text\").innerHTML = '" . $status_name . "';\n"; $year = date("Y"); $month = date("m"); $start_timestamp = mktime(0, 0, 0, $month, 1, $year); $end_timestamp = mktime(0, 0, 0, $month + 1, 0, $year); echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes(wpsc_currency_display(admin_display_total_price($start_timestamp, $end_timestamp))) . "';\n"; echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes(wpsc_currency_display(admin_display_total_price())) . "';\n"; exit; } } }
public static function wpTearDownAfterClass() { foreach (self::$posts as $post_id) { wp_delete_post($post_id, true); } foreach (self::$cats as $cat) { wp_delete_term($cat, 'category'); } }
function remove($group_name) { if (!taxonomy_exists($this->taxonomy)) return FALSE; if ($term = get_term_by('name', $group_name, $this->taxonomy, OBJECT)) { wp_delete_term($term->term_id, $this->taxonomy); } }
function es_type_delete() { $es_type_id = sanitize_text_field($_POST['es_type_id']); global $wpdb; wp_delete_term($es_type_id, 'property_type', array()); $wpdb->delete($wpdb->prefix . 'estatik_manager_types', array('type_id' => $es_type_id)); echo $es_type_id; die; }
/** * Deletes all plugin terms. * * @return void */ private function delete_terms() { $query = "\nSELECT term_id\nFROM {$this->wpdb->term_taxonomy}\nWHERE taxonomy = %s\nLIMIT 500"; $query = $this->wpdb->prepare($query, $this->taxonomy); while ($term_ids = $this->wpdb->get_col($query)) { foreach ($term_ids as $term_id) { wp_delete_term($term_id, $this->taxonomy); } } }
function geoareas_delete_area($taxonomy, $areas) { foreach ($areas as $area) { $tid = get_term_by('slug', $area->slug, $taxonomy); wp_delete_term($tid, $taxonomy); if ($area->children !== NULL) { geoareas_delete_area($taxonomy, $area->children); } } }
/** * Delete coupon type * * @package Jigoshop * @subpackage Jigosgop Coupon Products * @since 0.1 * **/ function jigoshop_del_coupon() { $product_types = array('coupon'); foreach ($product_types as $type) { $term = get_term_by('slug', sanitize_title($type), 'product_type'); if ($term) { wp_delete_term($term->term_id, 'product_type'); } } }
function wp_delete_category($cat_ID) { $cat_ID = (int) $cat_ID; $default = get_option('default_category'); // Don't delete the default cat if ( $cat_ID == $default ) return 0; return wp_delete_term($cat_ID, 'category', array('default' => $default)); }
function wp_delete_category($cat_ID) { $cat_ID = (int) $cat_ID; $default = get_option('default_category'); // Don't delete the default cat if ($cat_ID == $default) { return 0; } return wp_delete_term($cat_ID, 'category', "default={$default}"); }
public function disassociate() { $client = new Lingotek_API(); $prefs = Lingotek_Model::get_prefs(); if ($prefs['delete_document_from_tms']) { $client->delete_document($this->document_id); wp_delete_term($this->term_id, 'post_translations'); } else { wp_delete_term($this->term_id, 'post_translations'); } }
/** * Deletes a category via ajax from the group administrator screen */ function bp_group_documents_delete_category() { $id = $_POST['category_id']; if (ctype_digit($id) && term_exists((int) $id, 'group-documents-category')) { if (wp_delete_term((int) $id, 'group-documents-category')) { die('1'); } else { die('0'); } } }
public function delete($id, $taxonomy, $default = false) { if ($default) { $result = wp_delete_term($id, $taxonomy, array('default' => $default)); } else { $result = wp_delete_term($id, $taxonomy); } do_action('et_delete_term', $result); do_action('et_delete_term_' . $taxonomy, $result); return $result; }
/** * Attributes admin panel * * Shows the created attributes and lets you add new ones. * The added attributes are stored in the database and can be used for layered navigation. */ function woocommerce_attributes() { global $wpdb, $woocommerce; if (isset($_POST['add_new_attribute']) && $_POST['add_new_attribute']) { check_admin_referer('woocommerce-add-new_attribute'); $attribute_name = (string) sanitize_title($_POST['attribute_name']); $attribute_type = (string) $_POST['attribute_type']; $attribute_label = (string) $_POST['attribute_label']; if (!$attribute_label) { $attribute_label = ucwords($attribute_name); } if (!$attribute_name) { $attribute_name = sanitize_title($attribute_label); } if ($attribute_name && strlen($attribute_name) < 30 && $attribute_type && !taxonomy_exists($woocommerce->attribute_taxonomy_name($attribute_name))) { $wpdb->insert($wpdb->prefix . "woocommerce_attribute_taxonomies", array('attribute_name' => $attribute_name, 'attribute_label' => $attribute_label, 'attribute_type' => $attribute_type), array('%s', '%s')); wp_safe_redirect(get_admin_url() . 'admin.php?page=woocommerce_attributes'); exit; } } elseif (isset($_POST['save_attribute']) && $_POST['save_attribute'] && isset($_GET['edit'])) { $edit = absint($_GET['edit']); check_admin_referer('woocommerce-save-attribute_' . $edit); if ($edit > 0) { $attribute_type = $_POST['attribute_type']; $attribute_label = (string) $_POST['attribute_label']; $wpdb->update($wpdb->prefix . "woocommerce_attribute_taxonomies", array('attribute_type' => $attribute_type, 'attribute_label' => $attribute_label), array('attribute_id' => $_GET['edit']), array('%s', '%s')); } wp_safe_redirect(get_admin_url() . 'admin.php?page=woocommerce_attributes'); exit; } elseif (isset($_GET['delete'])) { check_admin_referer('woocommerce-delete-attribute_' . absint($_GET['delete'])); $delete = absint($_GET['delete']); if ($delete > 0) { $att_name = $wpdb->get_var("SELECT attribute_name FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '{$delete}'"); if ($att_name && $wpdb->query("DELETE FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '{$delete}'")) { $taxonomy = $woocommerce->attribute_taxonomy_name($att_name); if (taxonomy_exists($taxonomy)) { $terms = get_terms($taxonomy, 'orderby=name&hide_empty=0'); foreach ($terms as $term) { wp_delete_term($term->term_id, $taxonomy); } } wp_safe_redirect(get_admin_url() . 'admin.php?page=woocommerce_attributes'); exit; } } } if (isset($_GET['edit']) && $_GET['edit'] > 0) { woocommerce_edit_attribute(); } else { woocommerce_add_attribute(); } }
/** * Setup Initial Testing Environment */ function setUp() { global $wpdr; parent::setUp(); //init workflow states foreach (get_terms('workflow_state', array('hide_empty' => false)) as $term) { wp_delete_term($term->term_id, 'workflow_state'); } wp_cache_flush(); $wpdr->initialize_workflow_states(); wp_cache_flush(); }
function jigoshop_save_attributes() { /** @var $wpdb wpdb */ global $wpdb; $options = Jigoshop_Base::get_options(); if (isset($_POST['add_new_attribute']) && $_POST['add_new_attribute']) { check_admin_referer('jigoshop-add-attribute', '_jigoshop_csrf'); $attribute_label = (string) strip_tags(stripslashes($_POST['attribute_label'])); $attribute_name = !$_POST['attribute_name'] ? sanitize_title(sanitize_user($attribute_label, $strict = true)) : sanitize_title(sanitize_user($_POST['attribute_name'], $strict = true)); $attribute_type = (string) $_POST['attribute_type']; if (empty($attribute_name) && empty($attribute_label) || empty($attribute_label)) { print_r('<div id="message" class="error"><p>' . __('Please enter an attribute label.', 'jigoshop') . '</p></div>'); } elseif ($attribute_name && strlen($attribute_name) < 30 && $attribute_type && !taxonomy_exists('pa_' . sanitize_title($attribute_name))) { $wpdb->insert($wpdb->prefix . "jigoshop_attribute_taxonomies", array('attribute_name' => $attribute_name, 'attribute_label' => $attribute_label, 'attribute_type' => $attribute_type), array('%s', '%s')); do_action('jigoshop_attribute_admin_add_after_save', $attribute_name, $attribute_label, $attribute_type); $options->set('jigowatt_update_rewrite_rules', '1'); wp_safe_redirect(get_admin_url() . 'edit.php?post_type=product&page=jigoshop_attributes'); exit; } else { print_r('<div id="message" class="error"><p>' . __('That attribute already exists, no additions were made.', 'jigoshop') . '</p></div>'); } } elseif (isset($_POST['save_attribute']) && $_POST['save_attribute'] && isset($_GET['edit'])) { $edit = absint($_GET['edit']); check_admin_referer('jigoshop-edit-attribute_' . $edit, '_jigoshop_csrf'); if ($edit > 0) { $attribute_type = $_POST['attribute_type']; $attribute_label = (string) strip_tags(stripslashes($_POST['attribute_label'])); $wpdb->update($wpdb->prefix . "jigoshop_attribute_taxonomies", array('attribute_type' => $attribute_type, 'attribute_label' => $attribute_label), array('attribute_id' => $_GET['edit']), array('%s', '%s')); do_action('jigoshop_attribute_admin_edit_after_update', $edit, $attribute_label, $attribute_type); } wp_safe_redirect(get_admin_url() . 'edit.php?post_type=product&page=jigoshop_attributes'); exit; } elseif (isset($_GET['delete'])) { $delete = absint($_GET['delete']); check_admin_referer('jigoshop-delete-attribute_' . $delete); if ($delete > 0) { $att_name = $wpdb->get_var($wpdb->prepare("SELECT attribute_name FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = %d", $delete)); if ($att_name && $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = %d", $delete))) { $taxonomy = 'pa_' . sanitize_title($att_name); // Old taxonomy prefix left in for backwards compatibility if (taxonomy_exists($taxonomy)) { $terms = get_terms($taxonomy, 'orderby=name&hide_empty=0'); foreach ($terms as $term) { wp_delete_term($term->term_id, $taxonomy); } } do_action('jigoshop_attribute_admin_delete_after', $delete, $att_name); wp_safe_redirect(get_admin_url() . 'edit.php?post_type=product&page=jigoshop_attributes'); exit; } } } }
/** * Use this method to prevent excluding something that was not configured by FakerPress * * @todo Improve this to allow better checking * * @param array $items The array of arrays, first level has taxonomy as keys, second level only ids * @return bool */ public static function delete($items) { $deleted = array(); foreach ($items as $taxonomy => $terms) { $deleted[$taxonomy] = array(); foreach ($terms as $term) { $deleted[$taxonomy][$term] = wp_delete_term($term, $taxonomy); } } delete_option('fakerpress.module_flag.term'); return $deleted; }
/** * @ticket 33485 */ public function test_count_property_passed_to_filters_should_reflect_pre_deleted_term() { register_taxonomy('wptests_tax', 'post'); $terms = $this->factory->term->create_many(2, array('taxonomy' => 'wptests_tax')); $p = $this->factory->post->create(); wp_set_object_terms($p, array($terms[0]), 'wptests_tax'); add_action('delete_term', array($this, 'catch_deleted_term'), 10, 4); wp_delete_term($terms[0], 'wptests_tax'); $this->assertEquals(1, $this->deleted_term->count); wp_delete_term($terms[1], 'wptests_tax'); $this->assertEquals(0, $this->deleted_term->count); }
public static function tearDownAfterClass() { foreach (self::$cat_ids as $cat_id) { wp_delete_term($cat_id, 'category'); } foreach (self::$tag_ids as $tag_id) { wp_delete_term($tag_id, 'post_tag'); } foreach (self::$post_ids as $post_id) { wp_delete_post($post_id, true); } self::commit_transaction(); }
function rotary_default_link_cat() { //add custom blogroll category if (!term_exists('Rotary', 'link_category')) { $terms = wp_insert_term('Rotary', 'link_category'); update_option('default_link_category', $terms[0]); wp_delete_term('Blogroll', 'link_category'); } //add custom featured category if (!term_exists('Featured', 'category')) { wp_insert_term('Featured', 'category'); } }