| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: PJW WP Filter Manage Posts |
|---|
| 4 | Plugin URI: http://blog.ftwr.co.uk/wordpress/ |
|---|
| 5 | Description: Enables you to manage posts by author and other such goodies. |
|---|
| 6 | Author: Peter Westwood |
|---|
| 7 | Version: 0.11 |
|---|
| 8 | Author URI: http://blog.ftwr.co.uk/ |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | /* Copyright 2006 Peter Westwood (email : peter.westwood@ftwr.co.uk) |
|---|
| 12 | |
|---|
| 13 | This program is free software; you can redistribute it and/or modify |
|---|
| 14 | it under the terms of the GNU General Public License as published by |
|---|
| 15 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 16 | (at your option) any later version. |
|---|
| 17 | |
|---|
| 18 | This program is distributed in the hope that it will be useful, |
|---|
| 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 21 | GNU General Public License for more details. |
|---|
| 22 | |
|---|
| 23 | You should have received a copy of the GNU General Public License |
|---|
| 24 | along with this program; if not, write to the Free Software |
|---|
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 26 | */ |
|---|
| 27 | |
|---|
| 28 | function pjw_wp_filter_manage_posts_by_author() { |
|---|
| 29 | global $wpdb; |
|---|
| 30 | $user_result = $wpdb->get_results("SELECT DISTINCT post_author AS user_ID FROM $wpdb->posts WHERE post_type = 'post'"); |
|---|
| 31 | |
|---|
| 32 | if ( count($user_result) > 1 ) { ?> |
|---|
| 33 | |
|---|
| 34 | <select name='author'> |
|---|
| 35 | <option value=''><?php _e('All authors') ?></option> |
|---|
| 36 | <?php |
|---|
| 37 | foreach ($user_result as $user_row) { |
|---|
| 38 | |
|---|
| 39 | if( isset($_GET['author']) && $user_row->user_ID == (int) $_GET['author'] ) |
|---|
| 40 | $default = 'selected="selected"'; |
|---|
| 41 | else |
|---|
| 42 | $default = null; |
|---|
| 43 | |
|---|
| 44 | echo "<option $default value='$user_row->user_ID'>"; |
|---|
| 45 | $user = get_userdata($user_row->user_ID); |
|---|
| 46 | echo $user->display_name; |
|---|
| 47 | echo "</option>\n"; |
|---|
| 48 | } |
|---|
| 49 | ?> |
|---|
| 50 | </select> |
|---|
| 51 | <?php |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | add_action('restrict_manage_posts', 'pjw_wp_filter_manage_posts_by_author'); |
|---|