| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Adds submenus for taxonomies. |
|---|
| 5 | * |
|---|
| 6 | * @access private |
|---|
| 7 | * @since 3.1.0 |
|---|
| 8 | */ |
|---|
| 9 | function _add_taxonomy_submenus() { |
|---|
| 10 | foreach ( get_taxonomies( array( 'show_ui' => true ) ) as $tax ) { |
|---|
| 11 | $tax_obj = get_taxonomy( $tax ); |
|---|
| 12 | // Submenus only. |
|---|
| 13 | if ( ! $tax_obj->show_in_menu || true === $tax_obj->show_in_menu ) |
|---|
| 14 | continue; |
|---|
| 15 | add_submenu_page( $tax_obj->show_in_menu, $tax_obj->label, $ptype_obj->label, $ptype_obj->cap->manage_terms, "edit-tags.php?taxonomy=$tax" ); |
|---|
| 16 | } |
|---|
| 17 | } |
|---|
| 18 | add_action( 'admin_menu', '_add_taxonomy_submenus' ); |
|---|
| 19 | |
|---|
| 20 | /** |
|---|
| 21 | * Add taxonomies to parent page. |
|---|
| 22 | * |
|---|
| 23 | * @param string $parent_file Original menu parent. |
|---|
| 24 | * @return string $parent_file Modified menu parent. |
|---|
| 25 | */ |
|---|
| 26 | function fix_tax_page( $parent_file = '' ) { |
|---|
| 27 | global $pagenow; |
|---|
| 28 | |
|---|
| 29 | $taxonomies = get_taxonomies( array( 'show_ui' => true ) ); |
|---|
| 30 | // Submenus only. |
|---|
| 31 | if ( ! empty( $_GET[ 'taxonomy' ] ) && in_array( $_GET[ 'taxonomy' ], $taxonomies ) && $pagenow == 'edit-tags.php' ) { |
|---|
| 32 | $tax = get_taxonomy( $_GET[ 'taxonomy' ] ); |
|---|
| 33 | if ( isset( $tax->show_in_menu ) && true !== $tax->show_in_menu ) |
|---|
| 34 | $parent_file = $tax->show_in_menu; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | return $parent_file; |
|---|
| 38 | } |
|---|
| 39 | add_action( 'parent_file', array( &$this, 'fix_tax_page' ) ); |
|---|