Advertisement
Guest User

Tag Groups fix

a guest
Sep 4th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1.  
  2. function tg_add_taxonomy_columns( $columns )
  3. {
  4.  
  5.     global $wp;
  6.  
  7.     $new_order = (isset( $_GET['order'] ) && $_GET['order'] == 'asc' && isset( $_GET['orderby'] ) && $_GET['orderby'] == 'term_group') ? 'desc' : 'asc';
  8.  
  9.     $screen = get_current_screen();
  10.    
  11.     if ( !empty( $screen )) {
  12.    
  13.         $taxonomy = $screen->taxonomy;
  14.  
  15.         $link = add_query_arg( array('orderby' => 'term_group', 'order' => $new_order, 'taxonomy' => $taxonomy), admin_url( "edit-tags.php" . $wp->request ) );
  16.  
  17.         $link_escaped = esc_url( $link );
  18.  
  19.         $columns['term_group'] = '<a href="' . $link_escaped . '"><span>' . __( 'Tag Group', 'tag-groups' ) . '</span><span class="sorting-indicator"></span></a>';
  20.  
  21.       }  else {
  22.  
  23.         $columns['term_group'] = '';
  24.  
  25.       }
  26.      
  27.     return $columns;
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement