WordPress.org

Make WordPress Core

Ticket #6196: pjw-wp-filter-manage-posts-2.3.php

File pjw-wp-filter-manage-posts-2.3.php, 2.0 KB (added by westi, 7 years ago)

restrict_manage_post plugin which works for 2.3

Line 
1<?php
2/*
3Plugin Name: PJW WP Filter Manage Posts
4Plugin URI: http://blog.ftwr.co.uk/wordpress/
5Description: Enables you to manage posts by author and other such goodies.
6Author: Peter Westwood
7Version: 0.1
8Author 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
28function 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                <form name="viewuser" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">
35                        <fieldset>
36                                <legend><?php _e('Browse Author&hellip;') ?></legend>
37                                <select name='author'>
38                                <option value=''><?php _e('All') ?></option>
39                                <?php
40                                foreach ($user_result as $user_row) {
41
42                                        if( isset($_GET['author']) && $user_row->user_ID == (int) $_GET['author'] )
43                                                $default = 'selected="selected"';
44                                        else
45                                                $default = null;
46
47                                        echo "<option $default value='$user_row->user_ID'>";
48                                        $user = get_userdata($user_row->user_ID);
49                                        echo $user->display_name;
50                                        echo "</option>\n";
51                                }
52                                ?>
53                                </select>
54                                <input type="submit" name="submit" value="<?php _e('Show Author') ?>" />
55                        </fieldset>
56                </form> <?php 
57        } 
58}
59
60add_action('restrict_manage_posts', 'pjw_wp_filter_manage_posts_by_author');