Index: wp-admin/includes/dashboard.php
===================================================================
--- wp-admin/includes/dashboard.php (revision 19734)
+++ wp-admin/includes/dashboard.php (working copy)
@@ -75,11 +75,11 @@
wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
// QuickPress Widget
- if ( is_blog_admin() && current_user_can('edit_posts') )
+ if ( is_blog_admin() && current_user_can( 'edit_posts' ) && post_type_exists( 'post' ) )
wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
// Recent Drafts
- if ( is_blog_admin() && current_user_can('edit_posts') )
+ if ( is_blog_admin() && current_user_can( 'edit_posts' ) && post_type_exists( 'post' ) )
wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
// Primary feed (Dev Blog) Widget
@@ -248,13 +248,18 @@
function wp_dashboard_right_now() {
global $wp_registered_sidebars;
- $num_posts = wp_count_posts( 'post' );
- $num_pages = wp_count_posts( 'page' );
+ if ( post_type_exists( 'post' ) )
+ $num_posts = wp_count_posts( 'post' );
- $num_cats = wp_count_terms('category');
+ if ( post_type_exists( 'page' ) )
+ $num_pages = wp_count_posts( 'page' );
- $num_tags = wp_count_terms('post_tag');
+ if ( taxonomy_exists( 'category' ) )
+ $num_cats = wp_count_terms( 'category' );
+ if ( taxonomy_exists( 'post_tag' ) )
+ $num_tags = wp_count_terms( 'post_tag' );
+
$num_comm = wp_count_comments( );
echo "\n\t".'
';
@@ -262,16 +267,18 @@
echo "\n\t".'
';
// Posts
- $num = number_format_i18n( $num_posts->publish );
- $text = _n( 'Post', 'Posts', intval($num_posts->publish) );
- if ( current_user_can( 'edit_posts' ) ) {
- $num = "$num";
- $text = "$text";
+ if ( post_type_exists( 'post' ) ) {
+ $num = number_format_i18n( $num_posts->publish );
+ $text = _n( 'Post', 'Posts', intval($num_posts->publish) );
+ if ( current_user_can( 'edit_posts' ) ) {
+ $num = "$num";
+ $text = "$text";
+ }
+ echo '' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ echo '
';
}
- echo '' . $num . ' | ';
- echo '' . $text . ' | ';
-
- echo '
';
/* TODO: Show status breakdown on hover
if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can
$post_type_texts[] = ''.sprintf( _n( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'';
@@ -290,40 +297,47 @@
*/
// Pages
- $num = number_format_i18n( $num_pages->publish );
- $text = _n( 'Page', 'Pages', $num_pages->publish );
- if ( current_user_can( 'edit_pages' ) ) {
- $num = "$num";
- $text = "$text";
+ if ( post_type_exists( 'page' ) ) {
+ $num = number_format_i18n( $num_pages->publish );
+ $text = _n( 'Page', 'Pages', $num_pages->publish );
+ if ( current_user_can( 'edit_pages' ) ) {
+ $num = "$num";
+ $text = "$text";
+ }
+ echo '' . $num . ' | ';
+ echo '' . $text . ' | ';
+
+ echo '
';
}
- echo '' . $num . ' | ';
- echo '' . $text . ' | ';
- echo '
';
+ // Categories
+ if ( taxonomy_exists( 'category' ) ) {
+ $num = number_format_i18n( $num_cats );
+ $text = _n( 'Category', 'Categories', $num_cats );
+ if ( current_user_can( 'manage_categories' ) ) {
+ $num = "$num";
+ $text = "$text";
+ }
+ echo '' . $num . ' | ';
+ echo '' . $text . ' | ';
- // Categories
- $num = number_format_i18n( $num_cats );
- $text = _n( 'Category', 'Categories', $num_cats );
- if ( current_user_can( 'manage_categories' ) ) {
- $num = "$num";
- $text = "$text";
+ echo '
';
}
- echo '' . $num . ' | ';
- echo '' . $text . ' | ';
- echo '
';
+ // Tags
+ if ( taxonomy_exists( 'post_tag' ) ) {
+ $num = number_format_i18n( $num_tags );
+ $text = _n( 'Tag', 'Tags', $num_tags );
+ if ( current_user_can( 'manage_categories' ) ) {
+ $num = "$num";
+ $text = "$text";
+ }
+ echo '' . $num . ' | ';
+ echo '' . $text . ' | ';
- // Tags
- $num = number_format_i18n( $num_tags );
- $text = _n( 'Tag', 'Tags', $num_tags );
- if ( current_user_can( 'manage_categories' ) ) {
- $num = "$num";
- $text = "$text";
+ echo "
";
}
- echo '
' . $num . ' | ';
- echo '
' . $text . ' | ';
- echo "";
do_action('right_now_content_table_end');
echo "\n\t\n\t
";
@@ -546,10 +560,12 @@
+ post_type, 'post_tag' ) ) : ?>