1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Register Exclusive Taxonomies |
---|
4 | Description: Registers exclusive radio and dropdown taxonomies |
---|
5 | Author: Benjamin Balter |
---|
6 | Version: 1.0 |
---|
7 | Author URI: http://ben.balter.com/ |
---|
8 | */ |
---|
9 | |
---|
10 | function bb_register_cts() { |
---|
11 | |
---|
12 | register_taxonomy( 'dropdown', 'post', array( 'input' => 'dropdown', 'label' => 'Dropdown' ) ); |
---|
13 | register_taxonomy( 'radio', 'post', array( 'input' => 'radio', 'label' => 'Radio' ) ); |
---|
14 | |
---|
15 | $terms = get_terms( 'dropdown', array( 'hide_empty' => false ) ); |
---|
16 | if ( empty( $terms ) ) { |
---|
17 | wp_insert_term( 'Radio1', 'radio' ); |
---|
18 | wp_insert_term( 'Radio2', 'radio' ); |
---|
19 | wp_insert_term( 'Radio3', 'radio' ); |
---|
20 | wp_insert_term( 'Dropdown1', 'dropdown' ); |
---|
21 | wp_insert_term( 'Dropdown2', 'dropdown' ); |
---|
22 | wp_insert_term( 'Dropdown3', 'dropdown' ); |
---|
23 | } |
---|
24 | |
---|
25 | } |
---|
26 | |
---|
27 | add_action( 'init', 'bb_register_cts' ); |
---|