| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 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 |
<form name="viewuser" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;"> |
|---|
| 35 |
<fieldset> |
|---|
| 36 |
<legend><?php _e('Browse Author…') ?></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 |
|
|---|
| 60 |
add_action('restrict_manage_posts', 'pjw_wp_filter_manage_posts_by_author'); |
|---|
| 61 |
|
|---|