WordPress Source Read the puzzle: If no taxonomy, assume tt_ids

Source: Internet
Author: User
In the next reading WordPress source, a lot of harvest. In the following function, "If no taxonomy, assume Tt_ids" why? A contradiction, huh? Is it empty, where does the term_id? is both empty and how do I choose from table term_taxonomy?
Please master pointing twos send by.
/**
* Would remove all of the term IDs from the cache.
*
* @since 2.3.0
* @uses $wpdb
*
* @param int|array $ids Single or list of the term IDs
* @param string $taxonomy Can be empty and would assume tt_ids, else would use a for context.
* @param bool $clean _taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true.
*/
function Clean_term_cache ($ids, $taxonomy = ", $clean _taxonomy = True) {
Global $wpdb;

if (!is_array ($ids))
$ids = Array ($ids);

$taxonomies = Array ();
If No taxonomy, assume tt_ids.
if (empty ($taxonomy)) {
$tt _ids = Array_map (' intval ', $ids);
$tt _ids = Implode (', ', $tt _ids);
$terms = $wpdb->get_results ("Select term_id, taxonomy from $wpdb->term_taxonomy WHERE
term_taxonomy_id in ($tt _ids) ");
$ids = Array ();
foreach ((array) $terms as $term) {
$taxonomies [] = $term->taxonomy;
$ids [] = $term->term_id;
Wp_cache_delete ($term->term_id, $term->taxonomy);
}
$taxonomies = Array_unique ($taxonomies);
} else {
$taxonomies = Array ($taxonomy);
foreach ($taxonomies as $taxonomy) {
foreach ($ids as $id) {
Wp_cache_delete ($id, $taxonomy);
}
}
}

foreach ($taxonomies as $taxonomy) {
if ($clean _taxonomy) {
Wp_cache_delete (' All_ids ', $taxonomy);
Wp_cache_delete (' Get ', $taxonomy);
Delete_option ("{$taxonomy}_children");
Regenerate {$taxonomy}_children
_get_term_hierarchy ($taxonomy);
}

/**
* Fires once after each taxonomy's term cache have been cleaned.
*
* @since 2.5.0
*
* @param array $ids An array of term IDs.
* @param string $taxonomy taxonomy slug.
*/
Do_action (' Clean_term_cache ', $ids, $taxonomy);
}

Wp_cache_set (' last_changed ', Microtime (), ' terms ');
}


Reply to discussion (solution)

If no taxonomy, assume tt_ids--if the parameter taxonomy is empty, we assume that the parameter ID is tt_ids----term_taxonomy table
term_taxonomy_id. Otherwise, it is considered term_id.

If $taxonomy (category name) is empty
The category name corresponding to the $ids (class number)

Because the subsequent search is based on the classification name

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.