Make WordPress Core

Ticket #42486: 42486v2.diff

File 42486v2.diff, 910 bytes (added by seanchayes, 7 years ago)

Refreshed patch and updated display logic based on the comments in this ticket

  • src/wp-admin/includes/menu.php

    diff --git a/src/wp-admin/includes/menu.php b/src/wp-admin/includes/menu.php
    index cea9c758f1..4d720f2626 100644
    a b foreach ( $menu as $id => $data ) { 
    185185}
    186186unset( $id, $data, $subs, $first_sub );
    187187
     188// Hide the tools page if it's going to be empty.
     189$manage_taxonomies = false;
     190if ( current_user_can( 'import' ) ) {
     191        $cats = get_taxonomy('category');
     192        $tags = get_taxonomy('post_tag');
     193        if ( current_user_can($cats->cap->manage_terms) || current_user_can($tags->cap->manage_terms) ) {
     194                $manage_taxonomies = true;
     195        }
     196}
     197if ( ! isset( $submenu['tools.php'] ) && ! $manage_taxonomies && ! has_action( 'tool_box' ) ) {
     198        foreach ( $menu as $i => $data ) {
     199                if ( 'tools.php' == $data[2] ) {
     200                        unset( $menu[ $i ] );
     201                        break;
     202                }
     203        }
     204        unset( $data );
     205}
     206
    188207/**
    189208 * @param string $add
    190209 * @param string $class