home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-admin / index.php < prev    next >
Encoding:
PHP Script  |  2008-06-28  |  5.9 KB  |  146 lines

  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. wp_enqueue_script( 'jquery' );
  30. wp_admin_css( 'dashboard' );
  31.  
  32. $title = __('Dashboard');
  33. $parent_file = 'index.php';
  34. require_once('admin-header.php');
  35.  
  36. $today = current_time('mysql', 1);
  37. ?>
  38.  
  39. <div class="wrap">
  40.  
  41. <h2><?php _e('Dashboard'); ?></h2>
  42.  
  43. <div id="rightnow">
  44. <h3 class="reallynow">
  45.     <span><?php _e('Right Now'); ?></span>
  46.  
  47. <?php if ( $can_edit_posts = current_user_can( 'edit_posts' ) ) : ?>
  48.     <a href="post-new.php" class="rbutton"><strong><?php _e('Write a New Post'); ?></strong></a>
  49. <?php endif; if ( $can_edit_pages = current_user_can( 'edit_pages' ) ) : ?>
  50.     <a href="page-new.php" class="rbutton"><?php _e('Write a New Page'); ?></a>
  51. <?php endif; ?>
  52.     <br class="clear" />
  53. </h3>
  54.  
  55. <?php
  56. $num_posts = wp_count_posts( 'post' );
  57. $num_pages = wp_count_posts( 'page' );
  58.  
  59. $num_cats  = wp_count_terms('category');
  60.  
  61. $num_tags = wp_count_terms('post_tag');
  62.  
  63. $num_comm = get_comment_count( );
  64.  
  65. $post_type_texts = array();
  66.  
  67. if ( !empty($num_posts->publish) ) { // with feeds, anyone can tell how many posts there are.  Just unlink if !current_user_can
  68.     $post_text = sprintf( __ngettext( '%s post', '%s posts', $num_posts->publish ), number_format_i18n( $num_posts->publish ) );
  69.     $post_type_texts[] = $can_edit_posts ? "<a href='edit.php'>$post_text</a>" : $post_text;
  70. }
  71. if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds.  Don't show if !current_user_can
  72.     $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
  73. }
  74. if ( $can_edit_posts && !empty($num_posts->draft) ) {
  75.     $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>';
  76. }
  77. if ( $can_edit_posts && !empty($num_posts->future) ) {
  78.     $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>';
  79. }
  80.  
  81. if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
  82.     $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 ) );
  83. } else {
  84.     $pending_text = '';
  85. }
  86.  
  87. $cats_text = sprintf( __ngettext( '%s category', '%s categories', $num_cats ), number_format_i18n( $num_cats ) );
  88. $tags_text = sprintf( __ngettext( '%s tag', '%s tags', $num_tags ), number_format_i18n( $num_tags ) );
  89. if ( current_user_can( 'manage_categories' ) ) {
  90.     $cats_text = "<a href='categories.php'>$cats_text</a>";
  91.     $tags_text = "<a href='edit-tags.php'>$tags_text</a>";
  92. }
  93.  
  94. $total_comments = sprintf( __ngettext( '%1$s total', '%1$s total', $num_comm['total_comments'] ), number_format_i18n($num_comm['total_comments']) );
  95. $approved_comments = sprintf( __ngettext( '%1$s approved', '%1$s approved', $num_comm['approved'] ), number_format_i18n($num_comm['approved']) );
  96. $spam_comments = sprintf( __ngettext( '%1$s spam', '%1$s spam', $num_comm['spam'] ), number_format_i18n($num_comm['spam']) );
  97. $moderated_comments = sprintf( __ngettext( '%1$s awaiting moderation', '%1$s awaiting moderation', $num_comm['awaiting_moderation'] ), number_format_i18n($num_comm['awaiting_moderation']) );
  98.  
  99. if( current_user_can( 'moderate_comments' ) ) {
  100.     $total_comments = "<a href='edit-comments.php'>{$total_comments}</a>";
  101.     $approved_comments = "<a href='edit-comments.php?comment_status=approved'>{$approved_comments}</a>";
  102.     $moderated_comments = "<a href='edit-comments.php?comment_status=moderated'>{$moderated_comments}</a>";
  103. }
  104.  
  105. $comm_text = sprintf( __ngettext( 'You have %1$s comment, %2$s, %3$s and %4$s.', 'You have %1$s comments, %2$s, %3$s and %4$s.', $num_comm['total_comments'] ), $total_comments, $approved_comments, $spam_comments, $moderated_comments );
  106.  
  107. $post_type_text = implode(', ', $post_type_texts);
  108.  
  109. // There is always a category
  110. $sentence = sprintf( __( 'You have %1$s, contained within %2$s and %3$s. %4$s %5$s' ), $post_type_text, $cats_text, $tags_text, $pending_text, $comm_text );
  111. $sentence = apply_filters( 'dashboard_count_sentence', $sentence, $post_type_text, $cats_text, $tags_text, $pending_text, $comm_text );
  112.  
  113. ?>
  114. <p class="youhave"><?php echo $sentence; ?></p>
  115. <?php
  116. $ct = current_theme_info();
  117. $sidebars_widgets = wp_get_sidebars_widgets();
  118. $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ), 0 );
  119. $widgets_text = sprintf( __ngettext( '%d widget', '%d widgets', $num_widgets ), $num_widgets );
  120. if ( $can_switch_themes = current_user_can( 'switch_themes' ) )
  121.     $widgets_text = "<a href='widgets.php'>$widgets_text</a>";
  122. ?>
  123. <p class="youare">
  124.     <?php printf( __( 'You are using the %1$s theme with %2$s.' ), $ct->title, $widgets_text ); ?>
  125.     <?php if ( $can_switch_themes ) : ?>
  126.         <a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a>
  127.     <?php endif; ?>
  128.     <?php update_right_now_message(); ?>
  129. </p>
  130. <?php do_action( 'rightnow_end' ); ?>
  131. <?php do_action( 'activity_box_end' ); ?>
  132. </div><!-- rightnow -->
  133.  
  134. <br class="clear" />
  135.  
  136. <div id="dashboard-widgets-wrap">
  137.  
  138. <?php wp_dashboard(); ?>
  139.  
  140.  
  141. </div><!-- dashboard-widgets-wrap -->
  142.  
  143. </div><!-- wrap -->
  144.  
  145. <?php require('./admin-footer.php'); ?>
  146.