Skip to:
Content

BuddyPress.org

Changeset 10583


Ignore:
Timestamp:
02/12/2016 09:43:04 PM (6 years ago)
Author:
djpaul
Message:

Tools, Emails: empty email type taxonomy when running the email reinstall tool.

If a 3rd party plugin adds email types which aren't cleared up when that plugin is deactivated, we could end up with orphaned terms which would continue to show up in the email "sitation" metabox. As we hide the email type taxonomy management screen in wp-admin by default, this makes it very hard for the average user to remove those unused distracting terms.

Props modemlooper

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/bp-core-admin-tools.php

    r10581 r10583  
    452452    }
    453453
     454    // Make sure we have no orphaned email type terms.
     455    $email_types = get_terms( bp_get_email_tax_type(), array(
     456        'fields'                 => 'ids',
     457        'hide_empty'             => false,
     458        'update_term_meta_cache' => false,
     459    ) );
     460
     461    if ( $email_types ) {
     462        foreach ( $email_types as $term_id ) {
     463            wp_delete_term( (int) $term_id, bp_get_email_tax_type() );
     464        }
     465    }
     466
    454467    require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
    455468    bp_core_install_emails();
Note: See TracChangeset for help on using the changeset viewer.