| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: Test taxonomies |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | add_action('init', 'ttaxes_init'); |
|---|
| 7 | add_action('activate_' . plugin_basename(__FILE__), 'ttaxes_activate'); |
|---|
| 8 | |
|---|
| 9 | function ttaxes_activate() { |
|---|
| 10 | ttaxes_init(); |
|---|
| 11 | $GLOBALS['wp_rewrite']->flush_rules(); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | function ttaxes_init() { |
|---|
| 15 | global $wp_rewrite; |
|---|
| 16 | |
|---|
| 17 | // create new taxonomies |
|---|
| 18 | register_taxonomy( |
|---|
| 19 | 'things', |
|---|
| 20 | array('attachment:image', 'attachment:video', 'attachment:audio', 'post', 'page'), |
|---|
| 21 | array( |
|---|
| 22 | 'label' => __('Things'), |
|---|
| 23 | 'template' => __('Things: %l.'), |
|---|
| 24 | 'helps' => __('Separate with commas.'), |
|---|
| 25 | 'sort' => true, |
|---|
| 26 | 'args' => array('orderby' => 'term_order'), |
|---|
| 27 | 'rewrite' => array('slug' => 'thing'), |
|---|
| 28 | ) |
|---|
| 29 | ); |
|---|
| 30 | |
|---|
| 31 | register_taxonomy( |
|---|
| 32 | 'other_things', |
|---|
| 33 | array('attachment:image', 'attachment:video', 'attachment:audio', 'post', 'page'), |
|---|
| 34 | array( |
|---|
| 35 | 'label' => __('More things'), |
|---|
| 36 | 'template' => __('something: %l.'), |
|---|
| 37 | 'helps' => __('Separate with commas.'), |
|---|
| 38 | 'rewrite' => array('slug' => 'something'), |
|---|
| 39 | ) |
|---|
| 40 | ); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | |
|---|