WordPress.org

Make WordPress Core

Ticket #9674: 9674.diff

File 9674.diff, 23.3 KB (added by ryan, 9 years ago)
  • wp-includes/taxonomy.php

     
    190190        }
    191191
    192192        $args['name'] = $taxonomy;
    193         $args['object_type'] = $object_type;
     193        $args['object_type'] = (array) $object_type;
    194194        $wp_taxonomies[$taxonomy] = (object) $args;
    195195}
    196196
     197/**
     198 * Add an already registered taxonomy to a post type.
     199 *
     200 * @package WordPress
     201 * @subpackage Taxonomy
     202 * @since 2.9.0
     203 * @uses $wp_taxonomies Modifies taxonomy object
     204 *
     205 * @param string $taxonomy Name of taxonomy object
     206 * @param array|string $object_type Name of the post type
     207 * @return bool True if successful, false if not
     208 */
     209function register_taxonomy_for_post_type( $taxonomy, $post_type) {
     210        global $wp_taxonomies;
     211
     212        if ( !isset($wp_taxonomies[$taxonomy]) )
     213                return false;
     214
     215        if ( ! get_post_type_object($post_type) )
     216                return false;
     217
     218        $wp_taxonomies[$taxonomy]->object_type[] = $post_type;
     219
     220        return true;
     221}
     222
    197223//
    198224// Term API
    199225//
  • wp-includes/post.php

     
    1515 * Creates the initial post types when 'init' action is fired.
    1616 */
    1717function create_initial_post_types() {
    18         register_post_type( 'post', array('exclude_from_search' => false) );
    19         register_post_type( 'page', array('exclude_from_search' => false) );
    20         register_post_type( 'attachment', array('exclude_from_search' => false) );
    21         register_post_type( 'revision', array('exclude_from_search' => true) );
     18        register_post_type( 'post', array('label' => __('Posts'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false) );
     19        register_post_type( 'page', array('label' => __('Pages'),'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'page.php?post=%d', 'capability_type' => 'page', 'hierarchical' => true) );
     20        register_post_type( 'attachment', array('label' => __('Media'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'media.php?attachment_id=%d', 'capability_type' => 'post', 'hierarchical' => false) );
     21        register_post_type( 'revision', array('label' => __('Revisions'),'exclude_from_search' => true, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', 'hierarchical' => false) );
    2222}
    2323add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
    2424
     
    423423}
    424424
    425425/**
     426 * Retrieve a post type object by name
     427 *
     428 * @package WordPress
     429 * @subpackage Post
     430 * @since 2.9.0
     431 * @uses $wp_post_types
     432 * @see register_post_type
     433 * @see get_post_types
     434 *
     435 * @param string $post_type The name of a registered post type
     436 * @return object A post type object
     437 */
     438function get_post_type_object( $post_type ) {
     439        global $wp_post_types;
     440
     441        if ( empty($wp_post_types[$post_type]) )
     442                return null;
     443
     444        return $wp_post_types[$post_type];
     445}
     446
     447/**
    426448 * Get a list of all registered post type objects.
    427449 *
    428450 * @package WordPress
     
    451473                                $post_types[] = $post_type->name;
    452474                        else
    453475                                $post_types[] = $post_type;
    454                 } elseif ( array_intersect((array) $post_type, $args) ) {
     476                } elseif ( array_intersect_assoc((array) $post_type, $args) ) {
    455477                        if ( $do_names )
    456478                                $post_types[] = $post_type->name;
    457479                        else
     
    472494 *
    473495 * Optional $args contents:
    474496 *
     497 * label - A descriptibe name for the post type marked for translation. Defaults to $post_type.
     498 * public - Whether posts of this type should be shown in the admin UI. Defaults to true.
    475499 * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true.
     500 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
     501 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post".
     502 * hierarchical - Whether the post type is hierarchical. Defaults to false.
    476503 *
    477504 * @package WordPress
    478505 * @subpackage Post
     
    488515        if (!is_array($wp_post_types))
    489516                $wp_post_types = array();
    490517
    491         $defaults = array('exclude_from_search' => true);
     518        // Args prefixed with an underscore are reserved for internal use.
     519        $defaults = array('label' => false, 'exclude_from_search' => true, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false);
    492520        $args = wp_parse_args($args, $defaults);
     521        $args = (object) $args;
    493522
    494523        $post_type = sanitize_user($post_type, true);
    495         $args['name'] = $post_type;
    496         $wp_post_types[$post_type] = (object) $args;
     524        $args->name = $post_type;
     525
     526        if ( false === $args->label )
     527                $args->label = $post_type;
     528
     529        if ( empty($args->capability_type) ) {
     530                $args->edit_cap = '';
     531                $args->read_cap = '';
     532        } else {
     533                $args->edit_cap = 'edit_' . $args->capability_type;
     534                $args->read_cap = 'read_' . $args->capability_type;
     535        }
     536
     537        if ( !$args->_builtin && $args->public )
     538                $args->_show = true;
     539
     540        $wp_post_types[$post_type] = $args;
     541
     542        return $args;
    497543}
    498544
    499545/**
     
    9921038
    9931039        $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
    9941040        if ( 'readable' == $perm && is_user_logged_in() ) {
    995                 if ( !current_user_can("read_private_{$type}s") ) {
     1041                $post_type_object = get_post_type_object($type);
     1042                if ( !current_user_can("read_private_{$post_type_object->capability_type}s") ) {
    9961043                        $cache_key .= '_' . $perm . '_' . $user->ID;
    9971044                        $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))";
    9981045                }
  • wp-includes/query.php

     
    20702070                                $q['orderby'] = "$wpdb->posts.post_date ".$q['order'];
    20712071                }
    20722072
    2073                 $post_type_cap = $post_type;
     2073                $post_type_object = get_post_type_object ( $post_type );
     2074                if ( !empty($post_type_object) )
     2075                        $post_type_cap = $post_type_object->capability_type;
     2076                else
     2077                        $post_type_cap = $post_type;
    20742078
    20752079                $exclude_post_types = '';
    20762080                foreach ( get_post_types( array('exclude_from_search' => true) ) as $_wp_post_type )
  • wp-includes/link-template.php

     
    675675                return;
    676676
    677677        if ( 'display' == $context )
    678                 $action = 'action=edit&';
     678                $action = '&action=edit';
    679679        else
    680                 $action = 'action=edit&';
     680                $action = '&action=edit';
    681681
    682         switch ( $post->post_type ) :
    683         case 'page' :
    684                 if ( !current_user_can( 'edit_page', $post->ID ) )
    685                         return;
    686                 $file = 'page';
    687                 $var  = 'post';
    688                 break;
    689         case 'attachment' :
    690                 if ( !current_user_can( 'edit_post', $post->ID ) )
    691                         return;
    692                 $file = 'media';
    693                 $var  = 'attachment_id';
    694                 break;
    695         case 'revision' :
    696                 if ( !current_user_can( 'edit_post', $post->ID ) )
    697                         return;
    698                 $file = 'revision';
    699                 $var  = 'revision';
    700                 $action = '';
    701                 break;
    702         default :
    703                 if ( !current_user_can( 'edit_post', $post->ID ) )
    704                         return apply_filters( 'get_edit_post_link', '', $post->ID, $context );;
    705                 $file = 'post';
    706                 $var  = 'post';
    707                 break;
    708         endswitch;
     682        $post_type = get_post_type_object($post->post_type);
    709683
    710         return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context );
     684        if ( !$post_type )
     685                return;
     686
     687        if ( !current_user_can( $post_type->edit_cap, $post->ID ) )
     688                return;
     689
     690        return apply_filters( 'get_edit_post_link', admin_url( sprintf("$post_type->_edit_link$action", $post->ID) ), $post->ID, $context );
    711691}
    712692
    713693/**
  • wp-includes/capabilities.php

     
    774774                $author_data = get_userdata( $user_id );
    775775                //echo "post ID: {$args[0]}<br />";
    776776                $post = get_post( $args[0] );
    777                 if ( 'page' == $post->post_type ) {
    778                         $args = array_merge( array( 'delete_page', $user_id ), $args );
     777                $post_type = get_post_type_object( $post->post_type );
     778                if ( $post_type && 'post' != $post_type->capability_type ) {
     779                        $args = array_merge( array( 'delete_' . $post_type->capability_type, $user_id ), $args );
    779780                        return call_user_func_array( 'map_meta_cap', $args );
    780781                }
    781782                $post_author_data = get_userdata( $post->post_author );
     
    836837                $author_data = get_userdata( $user_id );
    837838                //echo "post ID: {$args[0]}<br />";
    838839                $post = get_post( $args[0] );
    839                 if ( 'page' == $post->post_type ) {
    840                         $args = array_merge( array( 'edit_page', $user_id ), $args );
     840                $post_type = get_post_type_object( $post->post_type );
     841                if ( $post_type && 'post' != $post_type->capability_type ) {
     842                        $args = array_merge( array( 'edit_' . $post_type->capability_type, $user_id ), $args );
    841843                        return call_user_func_array( 'map_meta_cap', $args );
    842844                }
    843845                $post_author_data = get_userdata( $post->post_author );
     
    894896                break;
    895897        case 'read_post':
    896898                $post = get_post( $args[0] );
    897                 if ( 'page' == $post->post_type ) {
    898                         $args = array_merge( array( 'read_page', $user_id ), $args );
     899                $post_type = get_post_type_object( $post->post_type );
     900                if ( $post_type && 'post' != $post_type->capability_type ) {
     901                        $args = array_merge( array( 'read_' . $post_type->capability_type, $user_id ), $args );
    899902                        return call_user_func_array( 'map_meta_cap', $args );
    900903                }
    901904
  • wp-admin/menu-header.php

     
    4545                if ( !empty($submenu[$item[2]]) )
    4646                        $class[] = 'wp-has-submenu';
    4747
    48                 if ( ( $parent_file && $item[2] == $parent_file ) || strcmp($self, $item[2]) == 0 ) {
     48                if ( ( $parent_file && $item[2] == $parent_file ) || ( false === strpos($parent_file, '?') && strcmp($self, $item[2]) == 0 ) ) {
    4949                        if ( !empty($submenu[$item[2]]) )
    5050                                $class[] = 'wp-has-current-submenu wp-menu-open';
    5151                        else
  • wp-admin/admin-ajax.php

     
    11201120        if ( 'page' == $_POST['post_type'] ) {
    11211121                $post[] = get_post($_POST['post_ID']);
    11221122                page_rows($post);
    1123         } elseif ( 'post' == $_POST['post_type'] ) {
     1123        } elseif ( 'post' == $_POST['post_type'] || in_array($_POST['post_type'], get_post_types( array('_show' => true) ) ) ) {
    11241124                $mode = $_POST['post_view'];
    11251125                $post[] = get_post($_POST['post_ID']);
    11261126                post_rows($post);
  • wp-admin/post-new.php

     
    99/** Load WordPress Administration Bootstrap */
    1010require_once('admin.php');
    1111$title = __('Add New Post');
     12if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )
     13        $post_type = $_GET['post_type'];
     14else
     15        $post_type = 'post';
    1216$parent_file = 'edit.php';
     17$submenu_file = 'post-new.php';
     18if ( 'post' != $post_type ) {
     19        $parent_file = "edit.php?post_type=$post_type";
     20        $submenu_file = "post-new.php?post_type=$post_type";
     21}
    1322$editing = true;
    1423wp_enqueue_script('autosave');
    1524wp_enqueue_script('post');
     
    3544
    3645// Show post form.
    3746$post = get_default_post_to_edit();
     47$post->post_type = $post_type;
    3848include('edit-form-advanced.php');
    3949
    4050include('admin-footer.php');
  • wp-admin/includes/plugin.php

     
    742742                        $parent = $_wp_real_parent_file[$parent];
    743743                return $parent;
    744744        }
    745 /*
     745
     746        /*
    746747        if ( !empty ( $parent_file ) ) {
    747748                if ( isset( $_wp_real_parent_file[$parent_file] ) )
    748749                        $parent_file = $_wp_real_parent_file[$parent_file];
    749750
    750751                return $parent_file;
    751752        }
    752 */
     753        */
    753754
    754755        if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
    755756                foreach ( (array)$menu as $parent_menu ) {
     
    779780                foreach ( $submenu[$parent] as $submenu_array ) {
    780781                        if ( isset( $_wp_real_parent_file[$parent] ) )
    781782                                $parent = $_wp_real_parent_file[$parent];
    782                         if ( $submenu_array[2] == $pagenow ) {
     783                        if ( $submenu_array[2] == $pagenow && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
    783784                                $parent_file = $parent;
    784785                                return $parent;
    785786                        } else
  • wp-admin/includes/post.php

     
    826826                $orderby = 'date';
    827827        }
    828828
     829        $post_type_q = 'post_type=post';
     830
     831        if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types( array('_show' => true) ) ) )
     832                $post_type_q = 'post_type=' . $q['post_type'];
     833
    829834        $posts_per_page = get_user_option('edit_per_page');
    830835        if ( empty($posts_per_page) )
    831836                $posts_per_page = 15;
    832837        $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page);
    833838
    834         wp("post_type=post&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");
     839        wp("$post_type_q$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");
    835840
    836841        return array($post_stati, $avail_post_stati);
    837842}
  • wp-admin/includes/meta-boxes.php

     
    1313        global $action;
    1414
    1515        $post_type = $post->post_type;
    16         $can_publish = current_user_can("publish_${post_type}s");
     16        $post_type_object = get_post_type_object($post_type);
     17        $type_cap = $post_type_object->capability_type;
     18        $can_publish = current_user_can("publish_${type_cap}s");
    1719?>
    1820<div class="submitbox" id="submitpost">
    1921
     
    184186<?php do_action('post_submitbox_start'); ?>
    185187<div id="delete-action">
    186188<?php
    187 if ( current_user_can("delete_${post_type}", $post->ID) ) { ?>
     189if ( current_user_can("delete_${type_cap}", $post->ID) ) { ?>
    188190<?php $delete_url = add_query_arg( array('action'=>'trash', 'post'=>$post->ID) ); ?>
    189191<a class="submitdelete deletion<?php if ( 'edit' != $action ) { echo " hidden"; } ?>" href="<?php echo wp_nonce_url($delete_url, "trash-${post_type}_" . $post->ID); ?>"><?php _e('Move to Trash'); ?></a>
    190192<?php } ?>
  • wp-admin/post.php

     
    130130        if ( 'trash' == $post->post_status )
    131131                wp_die( __('You can&#8217;t edit this post because it is in the Trash. Please restore it and try again.') );
    132132
    133         if ( 'post' != $post->post_type ) {
     133        if ( !in_array( $post->post_type, get_post_types() ) )
     134                wp_die( __('Unknown post type.') );
     135
     136        if ( 'post' != $post->post_type && in_array( $post->post_type, get_post_types( array('builtin' => true) ) ) ) {
    134137                wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
    135138                exit();
    136139        }
    137140
     141        $post_type = $post->post_type;
     142        if ( 'post' != $post_type ) {
     143                $parent_file = "edit.php?post_type=$post_type";
     144                $submenu_file = "edit.php?post_type=$post_type";
     145        }
     146
    138147        wp_enqueue_script('post');
    139148        if ( user_can_richedit() )
    140149                wp_enqueue_script('editor');
  • wp-admin/edit-form-advanced.php

     
    8888add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core');
    8989
    9090// all tag-style post taxonomies
    91 foreach ( get_object_taxonomies('post') as $tax_name ) {
     91foreach ( get_object_taxonomies($post_type) as $tax_name ) {
    9292        if ( !is_taxonomy_hierarchical($tax_name) ) {
    9393                $taxonomy = get_taxonomy($tax_name);
    9494                $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;
     
    9797        }
    9898}
    9999
    100 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
     100if ( 'post' == $post_type )
     101        add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
    101102add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low');
    102103add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
    103104add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');
     
    151152<input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" />
    152153<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" />
    153154<input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
    154 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post->post_type) ?>" />
     155<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post_type) ?>" />
    155156<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" />
    156157<input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
    157158<?php
  • wp-admin/menu.php

     
    6565
    6666$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
    6767
     68foreach ( (array) get_post_types( array('_show' => true) ) as $ptype ) {
     69        $_wp_last_object_menu++;
     70        $ptype_obj = get_post_type_object($ptype);
     71        $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), 'edit_' . $ptype_obj->capability_type . 's', "edit.php?post_type=$ptype", '', 'menu-top', 'menu-posts', 'div');
     72        $submenu["edit.php?post_type=$ptype"][5]  = array( __('Edit'), 'edit_posts',  "edit.php?post_type=$ptype");
     73        /* translators: add new custom post type */
     74        $submenu["edit.php?post_type=$ptype"][10]  = array( _x('Add New', 'post'), 'edit_posts', "post-new.php?post_type=$ptype" );
     75
     76        $i = 15;
     77        foreach ( $wp_taxonomies as $tax ) {
     78                if ( $tax->hierarchical || ! in_array($ptype, (array) $tax->object_type, true) )
     79                        continue;
     80
     81                $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
     82                ++$i;
     83        }
     84}
     85unset($ptype, $ptype_obj);
     86
    6887$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );
    6988
    7089$menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top', 'menu-appearance', 'div' );
  • wp-admin/edit.php

     
    2020        unset( $_redirect );
    2121}
    2222
     23if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )
     24        $post_type = $_GET['post_type'];
     25else
     26        $post_type = 'post';
     27
     28$parent_file = 'edit.php';
     29$submenu_file = 'edit.php';
     30$post_new_file = 'post-new.php';
     31if ( 'post' != $post_type ) {
     32        $parent_file = "edit.php?post_type=$post_type";
     33        $submenu_file = "edit.php?post_type=$post_type";
     34        $post_new_file = "post-new.php?post_type=$post_type";
     35}
     36
    2337// Handle bulk actions
    2438if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
    2539        check_admin_referer('bulk-posts');
    2640        $sendback = wp_get_referer();
    2741
    2842        if ( strpos($sendback, 'post.php') !== false )
    29                 $sendback = admin_url('post-new.php');
     43                $sendback = admin_url($post_new_file);
    3044
    3145        if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
    3246                $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
    33                 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = %s", $post_status ) );
     47                $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
    3448                $doaction = 'delete';
    3549        } elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post']) ) {
    3650                $post_ids = array_map( 'intval', (array) $_GET['post'] );
     
    109123
    110124if ( empty($title) )
    111125        $title = __('Edit Posts');
    112 $parent_file = 'edit.php';
     126
    113127wp_enqueue_script('inline-edit-post');
    114128
    115129$user_posts = false;
    116130if ( !current_user_can('edit_others_posts') ) {
    117         $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = 'post' AND post_status != 'trash' AND post_author = %d", $current_user->ID) );
     131        $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = 'p%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) );
    118132        $user_posts = true;
    119133        if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) )
    120134                $_GET['author'] = $current_user->ID;
     
    134148
    135149<div class="wrap">
    136150<?php screen_icon(); ?>
    137 <h2><?php echo esc_html( $title ); ?> <a href="post-new.php" class="button add-new-h2"><?php esc_html_e('Add New'); ?></a> <?php
     151<h2><?php echo esc_html( $title ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php esc_html_e('Add New'); ?></a> <?php
    138152if ( isset($_GET['s']) && $_GET['s'] )
    139153        printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
    140154</h2>
     
    187201<?php
    188202if ( empty($locked_post_status) ) :
    189203$status_links = array();
    190 $num_posts = wp_count_posts( 'post', 'readable' );
     204$num_posts = wp_count_posts( $post_type, 'readable' );
    191205$class = '';
    192206$allposts = '';
    193207
     
    214228        if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
    215229                $class = ' class="current"';
    216230
    217         $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>';
     231        $status_links[] = "<li><a href='edit.php?post_status=$status&amp;post_type=$post_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
    218232}
    219233echo implode( " |</li>\n", $status_links ) . '</li>';
    220234unset( $status_links );
     
    229243</p>
    230244
    231245<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" />
     246<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
    232247<input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
    233248
    234249<?php if ( have_posts() ) { ?>
     
    264279
    265280<?php // view filters
    266281if ( !is_singular() ) {
    267 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
     282$arc_query = $wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = %s ORDER BY post_date DESC", $post_type);
    268283
    269284$arc_result = $wpdb->get_results( $arc_query );
    270285