]> scripts.mit.edu Git - autoinstallsdev/wordpress.git/blob - wp-admin/index.php
Wordpress 2.5.1
[autoinstallsdev/wordpress.git] / wp-admin / index.php
1 <?php
2
3 require_once('admin.php');
4
5 require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
6
7 wp_dashboard_setup();
8
9 function index_js() {
10 ?>
11 <script type="text/javascript">
12 jQuery(function($) {
13         var ajaxWidgets = {
14                 dashboard_incoming_links: 'incominglinks',
15                 dashboard_primary: 'devnews',
16                 dashboard_secondary: 'planetnews',
17                 dashboard_plugins: 'plugins'
18         };
19         $.each( ajaxWidgets, function(i,a) {
20                 var e = jQuery('#' + i + ' div.dashboard-widget-content').not('.dashboard-widget-control').find('.widget-loading');
21                 if ( e.size() ) { e.parent().load('index-extra.php?jax=' + a); }
22         } );
23 });
24 </script>
25 <?php
26 }
27 add_action( 'admin_head', 'index_js' );
28
29 function index_css() {
30         wp_admin_css( 'css/dashboard' );
31 }
32 add_action( 'admin_head', 'index_css' );
33
34 wp_enqueue_script( 'jquery' );
35
36 $title = __('Dashboard');
37 $parent_file = 'index.php';
38 require_once('admin-header.php');
39
40 $today = current_time('mysql', 1);
41 ?>
42
43 <div class="wrap">
44
45 <h2><?php _e('Dashboard'); ?></h2>
46
47 <div id="rightnow">
48 <h3 class="reallynow">
49         <span><?php _e('Right Now'); ?></span>
50
51 <?php if ( $can_edit_posts = current_user_can( 'edit_posts' ) ) : ?>
52         <a href="post-new.php" class="rbutton"><strong><?php _e('Write a New Post'); ?></strong></a>
53 <?php endif; if ( $can_edit_pages = current_user_can( 'edit_pages' ) ) : ?>
54         <a href="page-new.php" class="rbutton"><?php _e('Write a New Page'); ?></a>
55 <?php endif; ?>
56         <br class="clear" />
57 </h3>
58
59 <?php
60 $num_posts = wp_count_posts( 'post' );
61 $num_pages = wp_count_posts( 'page' );
62
63 $num_cats  = wp_count_terms('category');
64
65 $num_tags = wp_count_terms('post_tag');
66
67 $post_type_texts = array();
68
69 if ( !empty($num_posts->publish) ) { // with feeds, anyone can tell how many posts there are.  Just unlink if !current_user_can
70         $post_text = sprintf( __ngettext( '%s post', '%s posts', $num_posts->publish ), number_format_i18n( $num_posts->publish ) );
71         $post_type_texts[] = $can_edit_posts ? "<a href='edit.php'>$post_text</a>" : $post_text;
72 }
73 if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds.  Don't show if !current_user_can
74         $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
75 }
76 if ( $can_edit_posts && !empty($num_posts->draft) ) {
77         $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>';
78 }
79 if ( $can_edit_posts && !empty($num_posts->future) ) {
80         $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>';
81 }
82
83 if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
84         $pending_text = sprintf( __ngettext( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) );
85 } else {
86         $pending_text = '';
87 }
88
89 $cats_text = sprintf( __ngettext( '%s category', '%s categories', $num_cats ), number_format_i18n( $num_cats ) );
90 $tags_text = sprintf( __ngettext( '%s tag', '%s tags', $num_tags ), number_format_i18n( $num_tags ) );
91 if ( current_user_can( 'manage_categories' ) ) {
92         $cats_text = "<a href='categories.php'>$cats_text</a>";
93         $tags_text = "<a href='edit-tags.php'>$tags_text</a>";
94 }
95
96 $post_type_text = implode(', ', $post_type_texts);
97
98 // There is always a category
99 $sentence = sprintf( __( 'You have %1$s, contained within %2$s and %3$s. %4$s' ), $post_type_text, $cats_text, $tags_text, $pending_text );
100 $sentence = apply_filters( 'dashboard_count_sentence', $sentence, $post_type_text, $cats_text, $tags_text, $pending_text );
101
102 ?>
103 <p class="youhave"><?php echo $sentence; ?></p>
104 <?php
105 $ct = current_theme_info();
106 $sidebars_widgets = wp_get_sidebars_widgets();
107 $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ) );
108 $widgets_text = sprintf( __ngettext( '%d widget', '%d widgets', $num_widgets ), $num_widgets );
109 if ( $can_switch_themes = current_user_can( 'switch_themes' ) )
110         $widgets_text = "<a href='widgets.php'>$widgets_text</a>";
111 ?>
112 <p class="youare">
113         <?php printf( __( 'You are using %1$s theme with %2$s.' ), $ct->title, $widgets_text ); ?>
114         <?php if ( $can_switch_themes ) : ?>
115                 <a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a>
116         <?php endif; ?>
117         <?php update_right_now_message(); ?>
118 </p>
119
120 <?php do_action( 'rightnow_end' ); ?>
121 <?php do_action( 'activity_box_end' ); ?>
122 </div><!-- rightnow -->
123
124 <br class="clear" />
125
126 <div id="dashboard-widgets-wrap">
127
128 <?php wp_dashboard(); ?>
129
130
131 </div><!-- dashboard-widgets-wrap -->
132
133 </div><!-- wrap -->
134
135 <?php require('./admin-footer.php'); ?>