Make WordPress Core

Ticket #9582: my_posts_filter.patch

File my_posts_filter.patch, 2.6 KB (added by scribu, 17 years ago)

adds the "My Posts" filter

  • home/cristi/svn/wp/wp-admin/edit.php

     
    8282$parent_file = 'edit.php';
    8383wp_enqueue_script('inline-edit-post');
    8484
    85 list($post_stati, $avail_post_stati) = wp_edit_posts_query();
    86 
    8785require_once('admin-header.php');
    8886
    8987if ( !isset( $_GET['paged'] ) )
     
    137135<ul class="subsubsub">
    138136<?php
    139137if ( empty($locked_post_status) ) :
    140 $status_links = array();
     138$post_filters = array();
    141139$num_posts = wp_count_posts( 'post', 'readable' );
    142140$total_posts = array_sum( (array) $num_posts );
    143 $class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
    144 $status_links[] = "<li><a href='edit.php' $class>" . sprintf( _n( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>';
     141$class = ( count( $_GET ) <= 1 ) ? ' class="current"' : '';
     142$post_filters[] = "<a href='edit.php' $class>" . sprintf( _n( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>';
    145143
     144global $user_ID, $wpdb;
     145$class = ( $_GET['author'] == $user_ID ) ? ' class="current"' : '';
     146$my_posts_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_author = $user_ID");
     147$post_filters[] = "<a href='edit.php?author=$user_ID' $class>" . __('My posts') . sprintf(' <span class="count">(%s)</span></a>', number_format_i18n($my_posts_count) );
    146148
     149list($post_stati, $avail_post_stati) = wp_edit_posts_query();
    147150foreach ( $post_stati as $status => $label ) {
    148151        $class = '';
    149152
     
    155158        if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
    156159                $class = ' class="current"';
    157160
    158         $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
     161        $post_filters[] = "<a href='edit.php?post_status=$status' $class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
    159162}
    160 echo implode( " |</li>\n", $status_links ) . '</li>';
    161 unset( $status_links );
     163
     164$post_filters = apply_filters('edit_posts_filters', $post_filters);
     165
     166foreach ( $post_filters as $i => $post_filter ) {
     167        $post_filters[$i] = '<li>' . $post_filter;
     168}
     169
     170echo implode( " |</li>\n", $post_filters ) . '</li>';
     171unset( $post_filters );
    162172endif;
    163173?>
    164174</ul>