Make WordPress Core

Ticket #45166: 45166.diff

File 45166.diff, 768 bytes (added by ediamin, 6 years ago)

Proposed changes in wp_delete_term function

  • src/wp-includes/taxonomy.php

    diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php
    index 7a278323af..6d7d06121d 100644
    a b function wp_delete_term( $term, $taxonomy, $args = array() ) { 
    18041804
    18051805        $defaults = array();
    18061806
    1807         if ( 'category' == $taxonomy ) {
    1808                 $defaults['default'] = get_option( 'default_category' );
    1809                 if ( $defaults['default'] == $term ) {
    1810                         return 0; // Don't delete the default category
    1811                 }
     1807        $default_term = get_option( "default_{$taxonomy}" );
     1808
     1809        if ( $default_term && $default_term == $term ) {
     1810                return 0; // Don't delete the default category
     1811        } else if ( $default_term ) {
     1812                $defaults['default'] = $default_term;
    18121813        }
    18131814
    18141815        $args = wp_parse_args( $args, $defaults );