Make WordPress Core

Changeset 10813


Ignore:
Timestamp:
03/18/2009 09:06:49 PM (16 years ago)
Author:
westi
Message:

Allow wp_delete_term users to force all objects to have a new term applied. Allow for category merging use-case. Fixes #9355.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r10810 r10813  
    10601060 * The $args 'default' will only override the terms found, if there is only one
    10611061 * term found. Any other and the found terms are used.
    1062  *
     1062 *
     1063 * The $args 'force_default' will force the term supplied as default to be
     1064 * assigned even if the object was not going to be termless
    10631065 * @package WordPress
    10641066 * @subpackage Taxonomy
     
    11111113    foreach ( (array) $objects as $object ) {
    11121114        $terms = wp_get_object_terms($object, $taxonomy, 'fields=ids');
    1113         if ( 1 == count($terms) && isset($default) )
     1115        if ( 1 == count($terms) && isset($default) ) {
    11141116            $terms = array($default);
    1115         else
     1117        } else {
    11161118            $terms = array_diff($terms, array($term));
     1119            if (isset($default) && isset($force_default) && $force_default)
     1120                $terms = array_merge($terms, array($default));
     1121        }
    11171122        $terms = array_map('intval', $terms);
    11181123        wp_set_object_terms($object, $terms, $taxonomy);
Note: See TracChangeset for help on using the changeset viewer.