Make WordPress Core

Ticket #8243: 8243.diff

File 8243.diff, 1.5 KB (added by sillybean, 12 years ago)

Support all post types in Recent Drafts dashboard widget

  • wp-admin/includes/dashboard.php

     
    573573function wp_dashboard_recent_drafts( $drafts = false ) {
    574574        if ( !$drafts ) {
    575575                $drafts_query = new WP_Query( array(
    576                         'post_type' => 'post',
     576                        'post_type' => 'any',
    577577                        'post_status' => 'draft',
    578578                        'author' => $GLOBALS['current_user']->ID,
    579579                        'posts_per_page' => 5,
     
    597597        <ul>
    598598                <li><?php echo join( "</li>\n<li>", $list ); ?></li>
    599599        </ul>
    600         <p class="textright"><a href="edit.php?post_status=draft" ><?php _e('View all'); ?></a></p>
     600        <p class="textright">
     601        <?php
     602            $post_types = get_post_types( array( 'public' => true ), 'objects' );
     603            foreach ( $post_types as $post_type ) {
     604                if ( $post_type->name != 'attachment' ) {
     605                    $editurl = add_query_arg( array( 'post_status' => 'draft' ), admin_url( 'edit.php' ) );
     606                    if ( 'post' !== $post_type->name )
     607                        $editurl = add_query_arg( array( 'post_type' => $post_type->name ), $editurl );
     608                    $linklist[] = '<a href="'.$editurl.'">' . esc_html( $post_type->labels->name ) . '</a> ';
     609                }
     610            }
     611        ?>
     612        <?php
     613        $sep = _x( ' | ', 'list separator' );
     614        printf( 'View all draft %s', join( $sep, $linklist ) );
     615        ?>
     616        </p>
    601617<?php
    602618        } else {
    603619                _e('There are no drafts at the moment');