function subterms_for_softwar e_term term_id tt_id var_dump func_get_a

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function subterms_for_software_term( $term_id, $tt_id ) {
/*var_dump(func_get_args()); die; // Вывод в админке того, какие аргументы передаются функции */
if ( is_admin() && is_tax( 'software-developers' ) ) {
$parent_term = get_term($term_id, $tt_id);
if(!is_wp_error($parent_term)) {
$taxonomy = 'software-developers';
wp_insert_term(
$parent_term->name.' Bonuses',
'software-developers',
array(
'description' => '',
'parent' => $parent_term['term_id'],
'slug' => 'bonuses-'.$parent_term->slug,
)
);
delete_option($taxonomy."_children");
wp_cache_flush();
wp_insert_term(
$parent_term->name.' Bonuses',
'software-developers',
array(
'description' => '',
'parent' => $parent_term['term_id'],
'slug' => 'bonuses-'.$parent_term->slug,
)
);
delete_option($taxonomy."_children");
wp_cache_flush();
}
}
}
add_action( 'create_term', 'subterms_for_software_term', 10, 3 );