Ticket #42486: 42486.2.diff
File 42486.2.diff, 2.6 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/menu.php
185 185 } 186 186 unset( $id, $data, $subs, $first_sub ); 187 187 188 // Hide the tools page if it's going to be empty. 189 $manage_taxonomies = false; 190 if ( current_user_can( 'import' ) ) { 191 $cats = get_taxonomy( 'category' ); 192 $tags = get_taxonomy( 'post_tag' ); 193 194 if ( current_user_can($cats->cap->manage_terms) || current_user_can($tags->cap->manage_terms) ) { 195 $manage_taxonomies = true; 196 add_action( 'tool_box', 'tool_box_categories_tags_converter', 1 ); 197 } 198 } 199 200 if ( ! isset( $submenu['tools.php'] ) && ! $manage_taxonomies && ! has_action( 'tool_box' ) ) { 201 foreach ( $menu as $i => $data ) { 202 if ( 'tools.php' == $data[2] ) { 203 unset( $menu[ $i ] ); 204 break; 205 } 206 } 207 unset( $data ); 208 } 209 188 210 /** 211 * Display the tool box card for the Categories and Tags Converter. 212 * 213 * @since 4.9.6 214 */ 215 function tool_box_categories_tags_converter() { 216 ?> 217 <div class="card"> 218 <h2 class="title"><?php _e( 'Categories and Tags Converter' ) ?></h2> 219 <p><?php printf( __('If you want to convert your categories to tags (or vice versa), use the <a href="%s">Categories and Tags Converter</a> available from the Import screen.'), 'import.php' ); ?></p> 220 </div> 221 <?php 222 } 223 224 /** 189 225 * @param string $add 190 226 * @param string $class 191 227 * @return string -
src/wp-admin/tools.php
29 29 ?> 30 30 <div class="wrap"> 31 31 <h1><?php echo esc_html( $title ); ?></h1> 32 <?php33 if ( current_user_can( 'import' ) ) :34 $cats = get_taxonomy('category');35 $tags = get_taxonomy('post_tag');36 if ( current_user_can($cats->cap->manage_terms) || current_user_can($tags->cap->manage_terms) ) : ?>37 <div class="card">38 <h2 class="title"><?php _e( 'Categories and Tags Converter' ) ?></h2>39 <p><?php printf( __('If you want to convert your categories to tags (or vice versa), use the <a href="%s">Categories and Tags Converter</a> available from the Import screen.'), 'import.php' ); ?></p>40 </div>41 <?php42 endif;43 endif;44 32 45 /** 46 * Fires at the end of the Tools Administration screen. 47 * 48 * @since 2.8.0 49 */ 50 do_action( 'tool_box' ); 33 <?php if ( ! has_action( 'tool_box' ) ) { ?> 34 <p><?php _e( 'Sorry, but there are no tools that you can access.' ); ?></p> 35 <?php 36 } else { 37 /** 38 * Fires at the end of the Tools Administration screen. 39 * 40 * @since 2.8.0 41 */ 42 do_action( 'tool_box' ); 43 } 51 44 ?> 52 45 </div> 53 46 <?php