Make WordPress Core

Ticket #3120: show-only-authors-hide-empty-cats.diff

File show-only-authors-hide-empty-cats.diff, 1.6 KB (added by westi, 20 years ago)

Add ability to filter by author and hide-empty cats

  • wp-admin/edit.php

     
    115115<form name="viewcat" action="" method="get" style="float: left; width: 30em; margin-bottom: 1em;">
    116116        <fieldset>
    117117        <legend><?php _e('Browse Category&hellip;') ?></legend>
    118         <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=0&hierarchical=1&show_count=1&selected='.$cat);?>
     118        <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
    119119        <input type="submit" name="submit" value="<?php _e('Show Category') ?>"  />
    120120        </fieldset>
    121121</form>
    122122
     123<?php $user_result = $wpdb->get_results("SELECT DISTINCT post_author AS user_ID FROM $wpdb->posts WHERE post_type = 'post'");
     124
     125if ( count($user_result) > 1 ) { ?>
     126
     127<form name="viewuser" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">
     128        <fieldset>
     129        <legend><?php _e('Browse Author&hellip;') ?></legend>
     130    <select name='author'>
     131        <option value=''><?php _e('All') ?></option>
     132        <?php
     133                foreach ($user_result as $user_row) {
     134
     135                        if( isset($_GET['author']) && $user_row->user_ID == (int) $_GET['author'] )
     136                                $default = 'selected="selected"';
     137                        else
     138                                $default = null;
     139
     140                        echo "<option $default value='$user_row->user_ID'>";
     141                        $user = get_userdata($user_row->user_ID);
     142                        echo $user->display_name;
     143                        echo "</option>\n";
     144                }
     145        ?>
     146        </select>
     147                <input type="submit" name="submit" value="<?php _e('Show Author') ?>" />
     148        </fieldset>
     149</form>
     150
     151<?php } ?>
     152
    123153<br style="clear:both;" />
    124154
    125155<?php