Make WordPress Core


Ignore:
Timestamp:
03/10/2008 10:59:57 PM (19 years ago)
Author:
ryan
Message:

Add cap checks to dash. Props mdawaffe. fixes #5858

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/index.php

    r7202 r7217  
    4040
    4141<div id="rightnow">
    42 <h3 class="reallynow"><span><?php _e('Right Now'); ?></span> <a href="post-new.php" class="rbutton"><strong><?php _e('Write a New Post'); ?></strong></a> <a href="page-new.php" class="rbutton"><?php _e('Write a New Page'); ?></a><br class="clear" /></h3>
     42<h3 class="reallynow">
     43        <span><?php _e('Right Now'); ?></span>
     44
     45<?php if ( $can_edit_posts = current_user_can( 'edit_posts' ) ) : ?>
     46        <a href="post-new.php" class="rbutton"><strong><?php _e('Write a New Post'); ?></strong></a>
     47<?php endif; if ( $can_edit_pages = current_user_can( 'edit_pages' ) ) : ?>
     48        <a href="page-new.php" class="rbutton"><?php _e('Write a New Page'); ?></a>
     49<?php endif; ?>
     50        <br class="clear" />
     51</h3>
    4352
    4453<?php
     
    5261$post_type_texts = array();
    5362
    54 if ( !empty($num_posts->publish) ) {
    55         $post_type_texts[] = '<a href="edit.php">'.sprintf( __ngettext( '%s post', '%s posts', $num_posts->publish ), number_format_i18n( $num_posts->publish ) ).'</a>';
     63if ( !empty($num_posts->publish) ) { // with feeds, anyone can tell how many posts there are.  Just unlink if !current_user_can
     64        $post_text = sprintf( __ngettext( '%s post', '%s posts', $num_posts->publish ), number_format_i18n( $num_posts->publish ) );
     65        $post_type_texts[] = $can_edit_posts ? "<a href='edit.php'>$post_text</a>" : $post_text;
    5666}
    57 if ( !empty($num_pages->publish) ) {
     67if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds.  Don't show if !current_user_can
    5868        $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
    5969}
    60 if ( !empty($num_posts->draft) ) {
     70if ( $can_edit_posts && !empty($num_posts->draft) ) {
    6171        $post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>';
    6272}
    63 if ( !empty($num_posts->future) ) {
     73if ( $can_edit_posts && !empty($num_posts->future) ) {
    6474        $post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';
    6575}
    6676
    67 $cats_text = '<a href="categories.php">'.sprintf( __ngettext( '%s category', '%s categories', $num_cats ), number_format_i18n( $num_cats ) ).'</a>';
    68 $tags_text = '<a href="edit-tags.php">'.sprintf( __ngettext( '%s tag', '%s tags', $num_tags ), number_format_i18n( $num_tags ) ).'</a>';
     77$cats_text = sprintf( __ngettext( '%s category', '%s categories', $num_cats ), number_format_i18n( $num_cats ) );
     78$tags_text = sprintf( __ngettext( '%s tag', '%s tags', $num_tags ), number_format_i18n( $num_tags ) );
     79if ( current_user_can( 'manage_categories' ) ) {
     80        $cats_text = "<a href='categories.php'>$cats_text</a>";
     81        $tags_text = "<a href='edit-tags.php'>$tags_text</a>";
     82}
    6983
    7084$post_type_text = implode(', ', $post_type_texts);
     
    8094$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ) );
    8195$widgets_text = sprintf( __ngettext( '%d widget', '%d widgets', $num_widgets ), $num_widgets );
     96if ( $can_switch_themes = current_user_can( 'switch_themes' ) )
     97        $widgets_text = "<a href='widgets.php'>$widgets_text</a>";
    8298?>
    83 <p><?php printf( __( 'You use the %1$s theme with %2$s.' ), $ct->title, "<a href='widgets.php'>$widgets_text</a>" ); ?> <a href="themes.php" class="button"><?php _e('Change Theme'); ?></a> <?php printf( __( "This is WordPress version %s." ), $GLOBALS['wp_version'] ); ?></p>
     99<p>
     100        <?php printf( __( 'You are using %1$s theme with %2$s.' ), $ct->title, $widgets_text ); ?>
     101        <?php if ( $can_switch_themes ) : ?>
     102                <a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a>
     103        <?php endif; ?>
     104        <?php printf( __( "This is WordPress version %s." ), $GLOBALS['wp_version'] ); ?>
     105</p>
     106
    84107<?php do_action( 'rightnow_end' ); ?>
    85108<?php do_action( 'activity_box_end' ); ?>
Note: See TracChangeset for help on using the changeset viewer.