Make WordPress Core

Ticket #42486: 42486.5.diff

File 42486.5.diff, 1.8 KB (added by audrasjb, 7 years ago)

Fixes inline comment message

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

    diff --git a/src/wp-admin/includes/menu.php b/src/wp-admin/includes/menu.php
    index cea9c75..11736f0 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
  • src/wp-admin/tools.php

    diff --git a/src/wp-admin/tools.php b/src/wp-admin/tools.php
    index b61d71f..140ebfc 100644
    a b if ( current_user_can($cats->cap->manage_terms) || current_user_can($tags->cap-> 
    4242endif;
    4343endif;
    4444
     45// Display a message in the tools page if it's going to be empty.
     46$manage_taxonomies = false;
     47if ( current_user_can( 'import' ) ) {
     48        $cats = get_taxonomy( 'category' );
     49        $tags = get_taxonomy( 'post_tag' );
     50        if ( current_user_can( $cats->cap->manage_terms ) || current_user_can( $tags->cap->manage_terms ) ) {
     51                $manage_taxonomies = true;
     52        }
     53}
     54if ( ! isset( $submenu['tools.php'] ) && ! $manage_taxonomies && ! has_action( 'tool_box' ) ) {
     55        ?>
     56        <p><?php _e( 'Sorry, nothing you can access right now.' ); ?></p>
     57        <?php
     58}
     59
    4560/**
    4661 * Fires at the end of the Tools Administration screen.
    4762 *