Taxonomy: Retain default term option when unregistering taxos.

No longer delete the default term option in `unregister_taxonomy()` to improve database performance.

Since taxonomies are registered at runtime and can't be unregistered unless they're already registered, prior to this 
change the option was created and deleted on each request.

Deleting the option should occur on a one-time opperation such as plugin deactivation.

Follow up to [48480].

Props dlh.
Fixes #54472.


git-svn-id: https://develop.svn.wordpress.org/trunk@53669 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2022-07-06 05:09:22 +00:00
parent ccbdd73187
commit 5b5c74b904
2 changed files with 0 additions and 8 deletions

View File

@ -580,11 +580,6 @@ function unregister_taxonomy( $taxonomy ) {
$taxonomy_object->remove_rewrite_rules();
$taxonomy_object->remove_hooks();
// Remove custom taxonomy default term option.
if ( ! empty( $taxonomy_object->default_term ) ) {
delete_option( 'default_term_' . $taxonomy_object->name );
}
// Remove the taxonomy.
unset( $wp_taxonomies[ $taxonomy ] );

View File

@ -1044,9 +1044,6 @@ class Tests_Taxonomy extends WP_UnitTestCase {
wp_set_object_terms( $post_id, array(), $tax );
$term = wp_get_post_terms( $post_id, $tax );
$this->assertSame( array(), $term );
unregister_taxonomy( $tax );
$this->assertSame( get_option( 'default_term_' . $tax ), false );
}
/**