可以为特定函数调用添加筛选器,如下所示:
add_filter( \'set_object_terms\', \'checkNewTerm\', 10, 6 );
function checkNewTerm( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) {
// Do stuff, ie. compare count of $tt_ids and $old_tt_ids
}
wp_set_object_terms($id, array($migrate_case), \'pa_case\');
remove_filter( \'set_object_terms\', \'checkNewTerm\', 10, 6 );