本文整理汇总了PHP中wp_delete_term函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_term函数的具体用法?PHP wp_delete_term怎么用?PHP wp_delete_term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_delete_term函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unlinkTranslationFor
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;
}
示例2: delete_term_actions
/**
* @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')));
}
示例3: cleanup
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']]);
}
}
}
}
示例4: uninstall
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.');
}
}
示例5: deleteData
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);
}
示例6: test_wp_delete_term_should_invalidate_cache
/**
* @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.
}
示例7: uninstall
/**
* 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");
}
}
示例8: test_wp_insert_delete_term
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));
}
示例9: spg_clean_data
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 {
}
}
示例10: delete
/**
* 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);
}
示例11: test_delete_term_is_synced
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);
}
示例12: wpsc_admin_ajax
/**
* 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;
}
}
}
示例13: wpTearDownAfterClass
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');
}
}
示例14: remove
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);
}
}
示例15: es_type_delete
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;
}