当前位置: 首页>>代码示例>>PHP>>正文


PHP clean_object_term_cache函数代码示例

本文整理汇总了PHP中clean_object_term_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP clean_object_term_cache函数的具体用法?PHP clean_object_term_cache怎么用?PHP clean_object_term_cache使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了clean_object_term_cache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: synchronize_terms

 /**
  * @param int $original_post_id
  * @param string $lang
  * @param bool $duplicate sets whether missing terms should be created by duplicating the original term
  */
 private function synchronize_terms($original_post_id, $lang, $duplicate)
 {
     global $wpml_post_translations;
     $wpml_post_translations->reload();
     $translated_post_id = $wpml_post_translations->element_id_in($original_post_id, $lang);
     if ((bool) $translated_post_id === true) {
         $taxonomies = get_post_taxonomies($original_post_id);
         foreach ($taxonomies as $tax) {
             $terms_on_original = wp_get_object_terms($original_post_id, $tax);
             if (!$this->sitepress->is_translated_taxonomy($tax)) {
                 if ($this->sitepress->get_setting('sync_post_taxonomies')) {
                     // Taxonomy is not translated so we can just copy from the original
                     foreach ($terms_on_original as $key => $term) {
                         $terms_on_original[$key] = $term->term_id;
                     }
                     wp_set_object_terms($translated_post_id, $terms_on_original, $tax);
                 }
             } else {
                 /** @var int[] $translated_terms translated term_ids */
                 $translated_terms = $this->get_translated_term_ids($terms_on_original, $lang, $tax, $duplicate);
                 wp_set_object_terms($translated_post_id, $translated_terms, $tax);
             }
         }
     }
     clean_object_term_cache($original_post_id, get_post_type($original_post_id));
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:31,代码来源:wpml-term-translation-utils.class.php

示例2: cron_action

 /**
  * WP Cron even for purging object cache in batches
  */
 function cron_action($tt_id, $taxonomy)
 {
     global $wpdb;
     $objects = $wpdb->get_col($wpdb->prepare("SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $tt_id));
     $tax_object = get_taxonomy($taxonomy);
     foreach ($tax_object->object_type as $object_type) {
         clean_object_term_cache($objects, $object_type);
     }
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:12,代码来源:vip-clean-term-cache.php

示例3: synchronize_terms

 /**
  * @param int $original_post_id
  * @param string $lang
  * @param bool $duplicate sets whether missing terms should be created by duplicating the original term
  */
 private function synchronize_terms($original_post_id, $lang, $duplicate)
 {
     global $wpml_post_translations;
     $wpml_post_translations->reload();
     $translated_post_id = $wpml_post_translations->element_id_in($original_post_id, $lang);
     if ((bool) $translated_post_id === true) {
         $taxonomies = get_post_taxonomies($original_post_id);
         foreach ($taxonomies as $tax) {
             $terms_on_original = wp_get_object_terms($original_post_id, $tax);
             /** @var int[] $translated_terms translated term_ids */
             $translated_terms = $this->get_translated_term_ids($terms_on_original, $lang, $tax, $duplicate);
             wp_set_object_terms($translated_post_id, $translated_terms, $tax);
         }
     }
     clean_object_term_cache($original_post_id, get_post_type($original_post_id));
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:21,代码来源:wpml-term-translation-utils.class.php

示例4: wp_set_terms_for_user

/**
 * Save taxonomy terms for a specific user
 *
 * @since 0.1.0
 *
 * @param  int      $user_id
 * @param  string   $taxonomy
 * @param  array    $terms
 * @param  boolean  $bulk
 *
 * @return boolean
 */
function wp_set_terms_for_user($user_id, $taxonomy, $terms = array(), $bulk = false)
{
    // Get the taxonomy
    $tax = get_taxonomy($taxonomy);
    // Make sure the current user can edit the user and assign terms before proceeding.
    if (!current_user_can('edit_user', $user_id) && current_user_can($tax->cap->assign_terms)) {
        return false;
    }
    if (empty($terms) && empty($bulk)) {
        $terms = isset($_POST[$taxonomy]) ? $_POST[$taxonomy] : null;
    }
    // Delete all user terms
    if (is_null($terms) || empty($terms)) {
        wp_delete_object_term_relationships($user_id, $taxonomy);
        // Set the terms
    } else {
        $_terms = array_map('sanitize_key', $terms);
        // Sets the terms for the user
        wp_set_object_terms($user_id, $_terms, $taxonomy, false);
    }
    clean_object_term_cache($user_id, $taxonomy);
}
开发者ID:JustinSainton,项目名称:wp-user-groups,代码行数:34,代码来源:wp-user-groups.php

示例5: save_user_rank_terms

 public function save_user_rank_terms($user_id)
 {
     $tax = get_taxonomy('rank');
     /* Make sure the current user can edit the user and assign terms before proceeding. */
     if (!current_user_can('edit_user', $user_id) && current_user_can($tax->cap->assign_terms)) {
         return false;
     }
     $term = esc_attr($_POST['rank']);
     /* Sets the terms (we're just using a single term) for the user. */
     wp_set_object_terms($user_id, array($term), 'rank', false);
     clean_object_term_cache($user_id, 'rank');
 }
开发者ID:jessor,项目名称:anspress,代码行数:12,代码来源:anspress-ranks.php

示例6: wppb_front_end_register


//.........这里部分代码省略.........
                                            $finalFileName .= $fileName[$i];
                                        }
                                    }
                                    $fileName = $finalFileName;
                                    $target_path = $target_path_original . 'userID_' . $new_user . '_originalAvatar_' . $fileName;
                                    /* when trying to upload file, be sure it's one of the accepted image file-types */
                                    if (($_FILES[$uploadedfile]['type'] == 'image/jpeg' || $_FILES[$uploadedfile]['type'] == 'image/jpg' || $_FILES[$uploadedfile]['type'] == 'image/png' || $_FILES[$uploadedfile]['type'] == 'image/bmp' || $_FILES[$uploadedfile]['type'] == 'image/pjpeg' || $_FILES[$uploadedfile]['type'] == 'image/x-png') && ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0)) {
                                        $wp_filetype = wp_check_filetype(basename($_FILES[$uploadedfile]['name']), null);
                                        $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $fileName, 'post_content' => '', 'post_status' => 'inherit');
                                        $attach_id = wp_insert_attachment($attachment, $target_path);
                                        $upFile = image_downsize($attach_id, 'thumbnail');
                                        $upFile = $upFile[0];
                                        //if file upload succeded
                                        if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) {
                                            add_user_meta($new_user, $value['item_metaName'], $upFile);
                                            wppb_resize_avatar($new_user);
                                            $avatarUpload = 'yes';
                                        } else {
                                            $avatarUpload = 'no';
                                        }
                                    }
                                    if ($_FILES[$uploadedfile]['type'] == '') {
                                        $avatarUpload = 'yes';
                                    }
                                    break;
                            }
                        }
                    }
                    // if admin approval is activated, then block the user untill he gets approved
                    $wppb_generalSettings = get_option('wppb_general_settings', 'not_found');
                    if ($wppb_generalSettings != 'not_found') {
                        if ($wppb_generalSettings['adminApproval'] == 'yes') {
                            wp_set_object_terms($new_user, array('unapproved'), 'user_status', false);
                            clean_object_term_cache($new_user, 'user_status');
                        }
                    }
                    // send an email to the admin, and - if selected - to the user also.
                    $bloginfo = get_bloginfo('name');
                    $sentEmailStatus = wppb_notify_user_registration_email($bloginfo, esc_attr($_POST['user_name']), esc_attr($_POST['email']), $_POST['send_credentials_via_email'], $_POST['passw1'], $wppb_generalSettings['adminApproval']);
                }
            } elseif (is_multisite()) {
                //validate username and email
                $validationRes = wpmu_validate_user_signup($userdata['user_login'], $userdata['user_email']);
                $error = apply_filters('wppb_register_wpmu_registration_error', $validationRes['errors']->get_error_message());
                if (trim($error) != '') {
                } else {
                    $new_user = 'yes';
                    $multisite_message = true;
                    $meta = array('user_pass' => base64_encode($userdata['user_pass']), 'first_name' => $userdata['first_name'], 'last_name' => $userdata['last_name'], 'nickname' => $userdata['nickname'], 'user_url' => $userdata['user_url'], 'aim' => $userdata['aim'], 'yim' => $userdata['yim'], 'jabber' => $userdata['jabber'], 'description' => $userdata['description'], 'role' => $userdata['role']);
                    $meta = wppb_add_custom_field_values($_POST, $meta);
                    wppb_signup_user($userdata['user_login'], $userdata['user_email'], $meta);
                }
            }
        }
    }
    ?>
	<div class="wppb_holder" id="wppb_register">
<?php 
    if (is_user_logged_in() && !current_user_can('create_users')) {
        global $user_ID;
        $login = get_userdata($user_ID);
        if ($login->display_name == '') {
            $login->display_name = $login->user_login;
        }
        $registerFilterArray['loginLogoutError'] = '
				<p class="log-in-out alert">' . __('You are logged in as', 'profilebuilder') . ' <a href="' . get_author_posts_url($login->ID) . '" title="' . $login->display_name . '">' . $login->display_name . '</a>. ' . __('You don\'t need another account.', 'profilebuilder') . ' <a href="' . wp_logout_url(get_permalink()) . '" title="' . __('Log out of this account.', 'profilebuilder') . '">' . __('Logout', 'profilebuilder') . '  &raquo;</a></p><!-- .log-in-out .alert -->';
开发者ID:par-orillonsoft,项目名称:elearning-wordpress,代码行数:67,代码来源:wppb.register.php

示例7: wp_update_term


//.........这里部分代码省略.........
    if (!is_wp_error($_term_id)) {
        $term_id = $_term_id;
    }
    /**
     * Fires immediately before the given terms are edited.
     *
     * @since 2.9.0
     *
     * @param int    $term_id  Term ID.
     * @param string $taxonomy Taxonomy slug.
     */
    do_action('edit_terms', $term_id, $taxonomy);
    $wpdb->update($wpdb->terms, compact('name', 'slug', 'term_group'), compact('term_id'));
    if (empty($slug)) {
        $slug = sanitize_title($name, $term_id);
        $wpdb->update($wpdb->terms, compact('slug'), compact('term_id'));
    }
    /**
     * Fires immediately after the given terms are edited.
     *
     * @since 2.9.0
     *
     * @param int    $term_id  Term ID
     * @param string $taxonomy Taxonomy slug.
     */
    do_action('edited_terms', $term_id, $taxonomy);
    /**
     * Fires immediate before a term-taxonomy relationship is updated.
     *
     * @since 2.9.0
     *
     * @param int    $tt_id    Term taxonomy ID.
     * @param string $taxonomy Taxonomy slug.
     */
    do_action('edit_term_taxonomy', $tt_id, $taxonomy);
    $wpdb->update($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent'), array('term_taxonomy_id' => $tt_id));
    /**
     * Fires immediately after a term-taxonomy relationship is updated.
     *
     * @since 2.9.0
     *
     * @param int    $tt_id    Term taxonomy ID.
     * @param string $taxonomy Taxonomy slug.
     */
    do_action('edited_term_taxonomy', $tt_id, $taxonomy);
    // Clean the relationship caches for all object types using this term.
    $objects = $wpdb->get_col($wpdb->prepare("SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $tt_id));
    $tax_object = get_taxonomy($taxonomy);
    foreach ($tax_object->object_type as $object_type) {
        clean_object_term_cache($objects, $object_type);
    }
    /**
     * Fires after a term has been updated, but before the term cache has been cleaned.
     *
     * @since 2.3.0
     *
     * @param int    $term_id  Term ID.
     * @param int    $tt_id    Term taxonomy ID.
     * @param string $taxonomy Taxonomy slug.
     */
    do_action("edit_term", $term_id, $tt_id, $taxonomy);
    /**
     * Fires after a term in a specific taxonomy has been updated, but before the term
     * cache has been cleaned.
     *
     * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
     *
     * @since 2.3.0
     *
     * @param int $term_id Term ID.
     * @param int $tt_id   Term taxonomy ID.
     */
    do_action("edit_{$taxonomy}", $term_id, $tt_id);
    /** This filter is documented in wp-includes/taxonomy-functions.php */
    $term_id = apply_filters('term_id_filter', $term_id, $tt_id);
    clean_term_cache($term_id, $taxonomy);
    /**
     * Fires after a term has been updated, and the term cache has been cleaned.
     *
     * @since 2.3.0
     *
     * @param int    $term_id  Term ID.
     * @param int    $tt_id    Term taxonomy ID.
     * @param string $taxonomy Taxonomy slug.
     */
    do_action("edited_term", $term_id, $tt_id, $taxonomy);
    /**
     * Fires after a term for a specific taxonomy has been updated, and the term
     * cache has been cleaned.
     *
     * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
     *
     * @since 2.3.0
     *
     * @param int $term_id Term ID.
     * @param int $tt_id   Term taxonomy ID.
     */
    do_action("edited_{$taxonomy}", $term_id, $tt_id);
    return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
}
开发者ID:n8maninger,项目名称:WordPress,代码行数:101,代码来源:taxonomy-functions.php

示例8: wp_delete_term


//.........这里部分代码省略.........
        /**
         * Fires immediately before a term to delete's children are reassigned a parent.
         *
         * @since 2.9.0
         *
         * @param array $edit_tt_ids An array of term taxonomy IDs for the given term.
         */
        do_action('edit_term_taxonomies', $edit_tt_ids);
        $wpdb->update($wpdb->term_taxonomy, compact('parent'), array('parent' => $term_obj->term_id) + compact('taxonomy'));
        // Clean the cache for all child terms.
        $edit_term_ids = wp_list_pluck($edit_ids, 'term_id');
        clean_term_cache($edit_term_ids, $taxonomy);
        /**
         * Fires immediately after a term to delete's children are reassigned a parent.
         *
         * @since 2.9.0
         *
         * @param array $edit_tt_ids An array of term taxonomy IDs for the given term.
         */
        do_action('edited_term_taxonomies', $edit_tt_ids);
    }
    // Get the term before deleting it or its term relationships so we can pass to actions below.
    $deleted_term = get_term($term, $taxonomy);
    $object_ids = (array) $wpdb->get_col($wpdb->prepare("SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $tt_id));
    foreach ($object_ids as $object_id) {
        $terms = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
        if (1 == count($terms) && isset($default)) {
            $terms = array($default);
        } else {
            $terms = array_diff($terms, array($term));
            if (isset($default) && isset($force_default) && $force_default) {
                $terms = array_merge($terms, array($default));
            }
        }
        $terms = array_map('intval', $terms);
        wp_set_object_terms($object_id, $terms, $taxonomy);
    }
    // Clean the relationship caches for all object types using this term.
    $tax_object = get_taxonomy($taxonomy);
    foreach ($tax_object->object_type as $object_type) {
        clean_object_term_cache($object_ids, $object_type);
    }
    $term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->termmeta} WHERE term_id = %d ", $term));
    foreach ($term_meta_ids as $mid) {
        delete_metadata_by_mid('term', $mid);
    }
    /**
     * Fires immediately before a term taxonomy ID is deleted.
     *
     * @since 2.9.0
     *
     * @param int $tt_id Term taxonomy ID.
     */
    do_action('delete_term_taxonomy', $tt_id);
    $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $tt_id));
    /**
     * Fires immediately after a term taxonomy ID is deleted.
     *
     * @since 2.9.0
     *
     * @param int $tt_id Term taxonomy ID.
     */
    do_action('deleted_term_taxonomy', $tt_id);
    // Delete the term if no taxonomies use it.
    if (!$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_taxonomy} WHERE term_id = %d", $term))) {
        $wpdb->delete($wpdb->terms, array('term_id' => $term));
    }
    clean_term_cache($term, $taxonomy);
    /**
     * Fires after a term is deleted from the database and the cache is cleaned.
     *
     * @since 2.5.0
     * @since 4.5.0 Introduced the `$object_ids` argument.
     *
     * @param int     $term         Term ID.
     * @param int     $tt_id        Term taxonomy ID.
     * @param string  $taxonomy     Taxonomy slug.
     * @param mixed   $deleted_term Copy of the already-deleted term, in the form specified
     *                              by the parent function. WP_Error otherwise.
     * @param array   $object_ids   List of term object IDs.
     */
    do_action('delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids);
    /**
     * Fires after a term in a specific taxonomy is deleted.
     *
     * The dynamic portion of the hook name, `$taxonomy`, refers to the specific
     * taxonomy the term belonged to.
     *
     * @since 2.3.0
     * @since 4.5.0 Introduced the `$object_ids` argument.
     *
     * @param int     $term         Term ID.
     * @param int     $tt_id        Term taxonomy ID.
     * @param mixed   $deleted_term Copy of the already-deleted term, in the form specified
     *                              by the parent function. WP_Error otherwise.
     * @param array   $object_ids   List of term object IDs.
     */
    do_action("delete_{$taxonomy}", $term, $tt_id, $deleted_term, $object_ids);
    return true;
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:101,代码来源:taxonomy.php

示例9: process_posts


//.........这里部分代码省略.........
                    $cfrows = explode(';', trim($this->values[COL_POST_CUSTOM_FIELD]));
                    //if( !(1 === count($cfrows) && '' == reset($cfrows)) ) {
                    if ('' != reset($cfrows)) {
                        $valstr = '';
                        foreach ($cfrows as $cf) {
                            list($meta_key, $meta_value) = explode('=', $cf, 2);
                            if (!WC2_Utils::is_blank($meta_key)) {
                                update_post_meta($post_id, $this->convert_encoding($meta_key), $this->convert_encoding($meta_value));
                            }
                        }
                    }
                    $wc2_item->clear_column();
                    //Item data set
                    $col = $start_col;
                    foreach ($item_base_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_value($key, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    foreach ($item_meta_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_value($key, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    //SKU data set
                    $col = $sku_start_col;
                    foreach ($item_sku_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    foreach ($item_sku_meta_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    if ($mode == 'add') {
                        $wc2_item->add_item_data();
                    } elseif ($mode == 'upd') {
                        $wc2_item->update_item_data();
                    }
                } else {
                    //sku登録のみの行
                    $sku_id++;
                    //SKU data set
                    $col = $sku_start_col;
                    foreach ($item_sku_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    foreach ($item_sku_meta_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    $item_id = $wc2_item->get_item_id_by_post_id($post_id);
                    $sku_data = $wc2_item->get_item_sku_data($item_id, $sku_id);
                    if (0 == $wc2_item->count_sku_data($sku_id)) {
                        if (0 < $sku_id and '' != $wc2_item->get_the_item_sku_code($sku_id)) {
                            $res = $wc2_item->add_item_sku_data($sku_id, $wc2_item->get_item_sku_data($item_id, $sku_id));
                            if (false === $res) {
                                break;
                            }
                        }
                    } else {
                        $res = $wc2_item->update_item_sku_data($sku_id, $wc2_item->get_item_sku_data($item_id, $sku_id));
                        if (false === $res) {
                            break;
                        }
                    }
                }
                if ('' != $this->get_log_line()) {
                    $this->create_log();
                }
                //登録成功数加算
                $this->success += 1;
                $pre_item_code = $this->values[COL_ITEM_CODE];
                clean_post_cache($post_id);
                wp_cache_delete($post_id, 'posts');
                wp_cache_delete($post_id, 'post_meta');
                clean_object_term_cache($post_id, 'post');
                //進捗加算
                $this->progress_add();
            }
            wp_import_cleanup($this->id);
            $this->false = $this->data_rows - $this->success;
            echo '<h3>' . __('All Done.', 'wc2') . '</h3>
				  <h3>' . sprintf(__('Success %d failure %d', 'wc2'), $this->success, $this->false) . '</h3>';
            if (0 < strlen($this->log)) {
                WC2_Utils::wc2_log($this->log, "import_item.log");
                echo str_replace("\n", "<br />", $this->log);
            }
        }
开发者ID:nanbu-collne,项目名称:test2,代码行数:101,代码来源:class-item-import.php

示例10: wp_delete_term

/**
 * Removes a term from the database.
 *
 * If the term is a parent of other terms, then the children will be updated to
 * that term's parent.
 *
 * The $args 'default' will only override the terms found, if there is only one
 * term found. Any other and the found terms are used.
 *
 * The $args 'force_default' will force the term supplied as default to be
 * assigned even if the object was not going to be termless
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 *
 * @uses $wpdb
 * @uses do_action() Calls both 'delete_term' and 'delete_$taxonomy' action
 *	hooks, passing term object, term id. 'delete_term' gets an additional
 *	parameter with the $taxonomy parameter.
 *
 * @param int $term Term ID
 * @param string $taxonomy Taxonomy Name
 * @param array|string $args Optional. Change 'default' term id and override found term ids.
 * @return bool|WP_Error Returns false if not term; true if completes delete action.
 */
function wp_delete_term( $term, $taxonomy, $args = array() ) {
	global $wpdb;

	$term = (int) $term;

	if ( ! $ids = term_exists($term, $taxonomy) )
		return false;
	if ( is_wp_error( $ids ) )
		return $ids;

	$tt_id = $ids['term_taxonomy_id'];

	$defaults = array();

	if ( 'category' == $taxonomy ) {
		$defaults['default'] = get_option( 'default_category' );
		if ( $defaults['default'] == $term )
			return 0; // Don't delete the default category
	}

	$args = wp_parse_args($args, $defaults);
	extract($args, EXTR_SKIP);

	if ( isset( $default ) ) {
		$default = (int) $default;
		if ( ! term_exists($default, $taxonomy) )
			unset($default);
	}

	// Update children to point to new parent
	if ( is_taxonomy_hierarchical($taxonomy) ) {
		$term_obj = get_term($term, $taxonomy);
		if ( is_wp_error( $term_obj ) )
			return $term_obj;
		$parent = $term_obj->parent;

		$edit_tt_ids = $wpdb->get_col( "SELECT `term_taxonomy_id` FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
		do_action( 'edit_term_taxonomies', $edit_tt_ids );
		$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
		do_action( 'edited_term_taxonomies', $edit_tt_ids );
	}

	$objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );

	foreach ( (array) $objects as $object ) {
		$terms = wp_get_object_terms($object, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
		if ( 1 == count($terms) && isset($default) ) {
			$terms = array($default);
		} else {
			$terms = array_diff($terms, array($term));
			if (isset($default) && isset($force_default) && $force_default)
				$terms = array_merge($terms, array($default));
		}
		$terms = array_map('intval', $terms);
		wp_set_object_terms($object, $terms, $taxonomy);
	}

	// Clean the relationship caches for all object types using this term
	$tax_object = get_taxonomy( $taxonomy );
	foreach ( $tax_object->object_type as $object_type )
		clean_object_term_cache( $objects, $object_type );

	// Get the object before deletion so we can pass to actions below
	$deleted_term = get_term( $term, $taxonomy );

	do_action( 'delete_term_taxonomy', $tt_id );
	$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
	do_action( 'deleted_term_taxonomy', $tt_id );

	// Delete the term if no taxonomies use it.
	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
		$wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) );

	clean_term_cache($term, $taxonomy);

//.........这里部分代码省略.........
开发者ID:pauEscarcia,项目名称:AIMM,代码行数:101,代码来源:TAXONOMY.PHP

示例11: clean_term_cache

 /**
  * When the term cache is cleaned, clean the object term cache too
  *
  * @since 2.0
  *
  * @param array  $ids      An array of term IDs.
  * @param string $taxonomy Taxonomy slug.
  */
 function clean_term_cache($ids)
 {
     clean_object_term_cache($ids, 'term');
 }
开发者ID:JoryHogeveen,项目名称:polylang,代码行数:12,代码来源:translated-term.php

示例12: wppb_update_user_status_on_admin_registration

function wppb_update_user_status_on_admin_registration($user_id)
{
    wp_set_object_terms($user_id, array('unapproved'), 'user_status', false);
    clean_object_term_cache($user_id, 'user_status');
}
开发者ID:serker72,项目名称:T3S,代码行数:5,代码来源:admin.approval.php

示例13: rename_tags

 /**
  * Rename tags
  */
 function rename_tags($old = '', $new = '')
 {
     $return_value = array('status' => 'ok', 'message' => '');
     if (trim(str_replace(',', '', stripslashes($new))) == '') {
         $return_value['message'] = __('No new tag specified!', 'nggallery');
         $return_value['status'] = 'error';
         return $return_value;
     }
     // String to array
     $old_tags = explode(',', $old);
     $new_tags = explode(',', $new);
     // Remove empty element and trim
     $old_tags = array_filter($old_tags, 'nggtags_delete_empty_element');
     $new_tags = array_filter($new_tags, 'nggtags_delete_empty_element');
     // If old/new tag are empty => exit !
     if (empty($old_tags) || empty($new_tags)) {
         $return_value['message'] = __('No new/old valid tag specified!', 'nggallery');
         $return_value['status'] = 'error';
         return $return_value;
     }
     $counter = 0;
     if (count($old_tags) == count($new_tags)) {
         // Rename only
         foreach ((array) $old_tags as $i => $old_tag) {
             $new_name = $new_tags[$i];
             // Get term by name
             $term = get_term_by('name', $old_tag, 'ngg_tag');
             if (!$term) {
                 continue;
             }
             // Get objects from term ID
             $objects_id = get_objects_in_term($term->term_id, 'ngg_tag', array('fields' => 'all_with_object_id'));
             // Delete old term
             wp_delete_term($term->term_id, 'ngg_tag');
             // Set objects to new term ! (Append no replace)
             foreach ((array) $objects_id as $object_id) {
                 wp_set_object_terms($object_id, $new_name, 'ngg_tag', true);
             }
             // Clean cache
             clean_object_term_cache($objects_id, 'ngg_tag');
             clean_term_cache($term->term_id, 'ngg_tag');
             // Increment
             $counter++;
         }
         if ($counter == 0) {
             $return_value['message'] = __('No tag renamed.', 'nggallery');
         } else {
             $return_value['message'] = sprintf(__('Renamed tag(s) &laquo;%1$s&raquo; to &laquo;%2$s&raquo;', 'nggallery'), $old, $new);
         }
     } elseif (count($new_tags) == 1) {
         // Merge
         // Set new tag
         $new_tag = $new_tags[0];
         if (empty($new_tag)) {
             $return_value['message'] = __('No valid new tag.', 'nggallery');
             $return_value['status'] = 'error';
             return $return_value;
         }
         // Get terms ID from old terms names
         $terms_id = array();
         foreach ((array) $old_tags as $old_tag) {
             $term = get_term_by('name', addslashes($old_tag), 'ngg_tag');
             $terms_id[] = (int) $term->term_id;
         }
         // Get objects from terms ID
         $objects_id = get_objects_in_term($terms_id, 'ngg_tag', array('fields' => 'all_with_object_id'));
         // No objects ? exit !
         if (!$objects_id) {
             $return_value['message'] = __('No objects (post/page) found for specified old tags.', 'nggallery');
             $return_value['status'] = 'error';
             return $return_value;
         }
         // Delete old terms
         foreach ((array) $terms_id as $term_id) {
             wp_delete_term($term_id, 'ngg_tag');
         }
         // Set objects to new term ! (Append no replace)
         foreach ((array) $objects_id as $object_id) {
             wp_set_object_terms($object_id, $new_tag, 'ngg_tag', true);
             $counter++;
         }
         // Test if term is also a category
         if (term_exists($new_tag, 'category')) {
             // Edit the slug to use the new term
             $slug = sanitize_title($new_tag);
             nggTags::edit_tag_slug($new_tag, $slug);
             unset($slug);
         }
         // Clean cache
         clean_object_term_cache($objects_id, 'ngg_tag');
         clean_term_cache($terms_id, 'ngg_tag');
         if ($counter == 0) {
             $return_value['message'] = __('No tag merged.', 'nggallery');
         } else {
             $return_value['message'] = sprintf(__('Merge tag(s) &laquo;%1$s&raquo; to &laquo;%2$s&raquo;. %3$s objects edited.', 'nggallery'), $old, $new, $counter);
         }
     } else {
//.........这里部分代码省略.........
开发者ID:ayoayco,项目名称:upbeat,代码行数:101,代码来源:tags.php

示例14: clean_post_cache

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * clean_post_cache() will call itself recursively for each child post.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @package WordPress
 * @subpackage Cache
 * @since 2.0.0
 *
 * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any).
 *
 * @param int $id The Post ID in the cache to clean
 */
function clean_post_cache($id) {
	global $_wp_suspend_cache_invalidation, $wpdb;

	if ( !empty($_wp_suspend_cache_invalidation) )
		return;

	$id = (int) $id;

	wp_cache_delete($id, 'posts');
	wp_cache_delete($id, 'post_meta');

	clean_object_term_cache($id, 'post');

	wp_cache_delete( 'wp_get_archives', 'general' );

	do_action('clean_post_cache', $id);

	if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) {
		foreach( $children as $cid )
			clean_post_cache( $cid );
	}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:41,代码来源:post.php

示例15: uni_copy_calendar_event

 /**
  *   uni_copy_calendar_event
  */
 public function uni_copy_calendar_event()
 {
     $aResult = $this->_r();
     $iCopyDateString = !empty($_POST['uni_input_copy_to']) ? esc_sql($_POST['uni_input_copy_to']) : '';
     $iEventId = esc_sql($_POST['uni_event_id']);
     $iCalId = esc_sql($_POST['uni_cal_id']);
     $sNonce = esc_sql($_POST['uni_auth_nonce']);
     $sAntiCheat = esc_sql($_POST['cheaters_always_disable_js']);
     if (empty($sAntiCheat) || $sAntiCheat != 'true_bro' || !wp_verify_nonce($_POST['uni_auth_nonce'], 'uni_authenticate_nonce')) {
         wp_send_json($aResult);
     }
     if (!empty($iCopyDateString) && !empty($iEventId) && !empty($iCalId)) {
         // data of current event
         $oEvent = get_post($iEventId);
         $aPostCustom = get_post_custom($iEventId);
         $iEventTitle = get_the_title($iEventId);
         $sEventContent = $oEvent->post_content;
         $aEventCats = wp_get_post_terms($iEventId, 'uni_calendar_event_cat');
         if (!empty($aEventCats) && !is_wp_error($aEventCats)) {
             $iEventCatId = $aEventCats[0]->term_id;
         }
         $iDelta = $aPostCustom['_uni_event_timestamp_end'][0] - $aPostCustom['_uni_event_timestamp_start'][0];
         // creating of the new event
         $iNewPostId = wp_insert_post(array('post_type' => 'uni_calendar_event', 'post_title' => $iEventTitle, 'post_content' => $sEventContent, 'post_status' => 'publish'));
         if ($iNewPostId != 0) {
             update_post_meta($iNewPostId, '_uni_event_parent_calendar', $iCalId);
             $iCopyDateTimestamp = strtotime($iCopyDateString);
             update_post_meta($iNewPostId, '_uni_event_timestamp_start', $iCopyDateTimestamp);
             update_post_meta($iNewPostId, '_uni_event_timestamp_end', $iCopyDateTimestamp + $iDelta);
             update_post_meta($iNewPostId, '_uni_event_user_id', $aPostCustom['_uni_event_user_id'][0]);
             if (!empty($iEventCatId)) {
                 $iEventCatId = intval($iEventCatId);
                 wp_set_object_terms($iNewPostId, $iEventCatId, 'uni_calendar_event_cat', false);
                 clean_object_term_cache($iNewPostId, 'uni_calendar_event_cat');
             }
             $aResult['status'] = 'success';
             $aResult['message'] = sprintf(__('%s Success! %s', 'uni-calendar'), '<div class="notice is-dismissible"><p>', '</p></div>');
             $aResult['refetch'] = 'yes';
             //$aResult['redirect']    = add_query_arg( array( 'page' => 'uni-events-calendars', 'action' => 'edit-events', 'cal_id' => $iCalId, 'uni_auth_nonce' => wp_create_nonce('uni_authenticate_nonce') ), admin_url('admin.php') );
         } else {
             $aResult['message'] = sprintf(__('%s Error: event not created! %s', 'uni-calendar'), '<div class="notice is-dismissible"><p>', '</p></div>');
         }
     } else {
         $aResult['message'] = sprintf(__('%s Something went wrong(( %s', 'uni-calendar'), '<div class="notice is-dismissible"><p>', '</p></div>');
     }
     wp_send_json($aResult);
 }
开发者ID:primus1989,项目名称:https---github.com-DataDesignSystems-drishtiq,代码行数:50,代码来源:uni-events-calendar-ajax.php


注:本文中的clean_object_term_cache函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。