From 5bc53c066fe1c311e84a332e700dffa216b08e8f Mon Sep 17 00:00:00 2001
From: Barry Ceelen <b@rryceelen.com>
Date: Mon, 9 Nov 2015 00:04:43 +0100
Subject: [PATCH 1/2] Delete term meta when deleting a term
---
wp-includes/taxonomy-functions.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/wp-includes/taxonomy-functions.php b/wp-includes/taxonomy-functions.php
index 174fe74..e916e44 100644
|
a
|
b
|
function wp_delete_object_term_relationships( $object_id, $taxonomies ) { |
| 2052 | 2052 | * Removes a term from the database. |
| 2053 | 2053 | * |
| 2054 | 2054 | * If the term is a parent of other terms, then the children will be updated to |
| 2055 | | * that term's parent. |
| | 2055 | * that term's parent. Meta fields associated with the term are deleted. |
| 2056 | 2056 | * |
| 2057 | 2057 | * The `$args` 'default' will only override the terms found, if there is only one |
| 2058 | 2058 | * term found. Any other and the found terms are used. |
| … |
… |
function wp_delete_term( $term, $taxonomy, $args = array() ) { |
| 2172 | 2172 | foreach ( $tax_object->object_type as $object_type ) |
| 2173 | 2173 | clean_object_term_cache( $objects, $object_type ); |
| 2174 | 2174 | |
| | 2175 | $term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $tt_id )); |
| | 2176 | foreach ( $term_meta_ids as $mid ) |
| | 2177 | delete_metadata_by_mid( 'term', $mid ); |
| | 2178 | |
| 2175 | 2179 | /** |
| 2176 | 2180 | * Fires immediately before a term taxonomy ID is deleted. |
| 2177 | 2181 | * |
--
2.6.0
From a00a78135ee4ebec2fa8f78c27d2607e19400cf4 Mon Sep 17 00:00:00 2001
From: Barry Ceelen <b@rryceelen.com>
Date: Mon, 9 Nov 2015 00:05:24 +0100
Subject: [PATCH 2/2] Update code comment
---
wp-includes/meta-functions.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wp-includes/meta-functions.php b/wp-includes/meta-functions.php
index be7ad5b..14e8af3 100644
|
a
|
b
|
function metadata_exists( $meta_type, $object_id, $meta_key ) { |
| 558 | 558 | * |
| 559 | 559 | * @global wpdb $wpdb WordPress database abstraction object. |
| 560 | 560 | * |
| 561 | | * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) |
| | 561 | * @param string $meta_type Type of object metadata is for (e.g., comment, post, meta, or user) |
| 562 | 562 | * @param int $meta_id ID for a specific meta row |
| 563 | 563 | * @return object|false Meta object or false. |
| 564 | 564 | */ |
| … |
… |
function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = |
| 692 | 692 | * |
| 693 | 693 | * @global wpdb $wpdb WordPress database abstraction object. |
| 694 | 694 | * |
| 695 | | * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user) |
| | 695 | * @param string $meta_type Type of object metadata is for (e.g., comment, post, term, or user) |
| 696 | 696 | * @param int $meta_id ID for a specific meta row |
| 697 | 697 | * @return bool True on successful delete, false on failure. |
| 698 | 698 | */ |