[wp-trac] [WordPress Trac] #36964: Show/hide the tag-cloud on `edit-tags.php` admin pages using a filter

WordPress Trac noreply at wordpress.org
Sat May 28 12:37:47 UTC 2016


#36964: Show/hide the tag-cloud on `edit-tags.php` admin pages using a filter
--------------------------------+-----------------------------
 Reporter:  ramiy               |      Owner:
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Administration      |    Version:
 Severity:  normal              |   Keywords:
  Focuses:  ui, administration  |
--------------------------------+-----------------------------
 The `edit-tags.php` page shows a tag-cloud with "Popular Tags" on non-
 hierarchical taxonomies. There is no way to remove this tag cloud and the
 H2 title from the admin screen.

 This ticket introduces a new boolean filter
 "`show_admin_popular_items_tag_cloud`" that allows you to remove this
 blog-feature.

 ----

 The current code that shows the tag cloud:
 {{{
 if ( ! is_null( $tax->labels->popular_items ) ) {
         if ( current_user_can( $tax->cap->edit_terms ) ) {
                 $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy,
 'post_type' => $post_type, 'echo' => false, 'link' => 'edit' ) );
         } else {
                 $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy,
 'echo' => false ) );
         }

         if ( $tag_cloud ) :
         ?>
 <div class="tagcloud">
 <h2><?php echo $tax->labels->popular_items; ?></h2>
 <?php echo $tag_cloud; unset( $tag_cloud ); ?>
 </div>
 <?php
         endif;
 }
 }}}


 The new code with the proposed filter:

 {{{
 $show_admin_popular_items = ! is_null( $tax->labels->popular_items );

 /**
  * Filters whether to show the popular items tag cloud in the taxonomy
 admin screen.
  *
  * This filter controls the visibility of the popular items tag cloud in
 the
  * taxonomy admin screen.
  *
  * By default, the tag cloud is visible on non-hierarchy taxonomies admin
 pages.
  * You can hide it using `__return_false`.
  *
  * @since 4.6.0
  *
  * @param bool $show_admin_popular_items Whether to show the popular items
 tag cloud.
  */
 if ( apply_filters( 'show_admin_popular_items_tag_cloud',
 $show_admin_popular_items ) ) {
         if ( current_user_can( $tax->cap->edit_terms ) ) {
                 $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy,
 'post_type' => $post_type, 'echo' => false, 'link' => 'edit' ) );
         } else {
                 $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy,
 'echo' => false ) );
         }

         if ( $tag_cloud ) {
 ?>
 <div class="tagcloud">
 <h2><?php echo $tax->labels->popular_items; ?></h2>
 <?php echo $tag_cloud; unset( $tag_cloud ); ?>
 </div>
 <?php
         }
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36964>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list