Make WordPress Core


Ignore:
Timestamp:
12/19/2004 12:10:10 AM (20 years ago)
Author:
saxmatt
Message:

First pass at dashboard. Hat tip: Jesuit.

File:
1 edited

Legend:

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

    r1947 r1976  
    11<?php
     2require_once('admin.php');
     3$title = __('Dashboard');
     4require_once('admin-header.php');
    25
    3 require('../wp-config.php');
    4 auth_redirect();
     6$today = current_time('mysql');
     7?>
    58
     9<div class="wrap">
     10<div id="zeitgeist">
     11<h2><?php _e('Latest Activity'); ?></h2>
     12<?php
     13if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
     14?>
     15<div>
     16<h3><?php _e('Posts'); ?></h3>
     17<ul>
     18<?php
     19foreach ($recentposts as $post) {
     20    if ($post->post_title == '')
     21        $post->post_title = sprintf(__('Post #%s'), $post->ID);
     22    echo "<li><a href='post.php?action=edit&amp;post=$post->ID'>";
     23    the_title();
     24    echo '</a></li>';
     25}
     26?>
     27</ul>
     28</div>
     29<?php endif; ?>
     30
     31<?php
     32if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt > '$today'") ) :
     33?>
     34<div>
     35<h3><?php _e('Scheduled Entries:') ?></h3>
     36<ul>
     37<?php
     38foreach ($scheduled as $post) {
     39    if ($post->post_title == '')
     40        $post->post_title = sprintf(__('Post #%s'), $post->ID);
     41    echo "<li><a href='post.php?action=edit&amp;post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a> in " . human_time_diff( time(), strtotime($post->post_date) )  . "</li>";
     42}
     43?>
     44</ul>
     45</div>
     46<?php endif; ?>
     47
     48<?php
     49if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT 5") ) :
     50?>
     51<div>
     52<h3><?php _e('Comments'); ?></h3>
     53<ul>
     54<?php
     55foreach ($comments as $comment) {
     56    echo '<li>' . sprintf('%s on %s', get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
     57    edit_comment_link(__("Edit"), ' <small>(', ')</small>');
     58    echo '</li>';
     59}
     60?>
     61</ul>
     62<?php
     63if ( $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_approved = '0'") ) :
     64?>
     65<p><a href="moderation.php"><?php echo sprintf(__('There are comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></p>
     66<?php endif; ?>
     67</div>
     68
     69<?php endif; ?>
     70
     71<div>
     72<h3><?php _e('Blog Stats'); ?></h3>
     73<?php
     74$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
     75if (0 < $numposts) $numposts = number_format($numposts);
     76
     77$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
     78if (0 < $numcomms) $numcomms = number_format($numcomms);
     79
     80$numcats = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
     81if (0 < $numcats) $numcats = number_format($numcats);
     82?>
     83<p>There are currently <?php echo $numposts ?> <a href="edit.php" title="posts">posts</a> and <?php echo $numcomms ?> <a href="edit-comments.php" title="Comments">comments</a>, contained within <?php echo $numcats ?> <a href="categories.php" title="categories">categories</a>.</p>
     84</div>
     85
     86</div>
     87
     88<h2><?php _e('Dashboard'); ?></h2>
     89<br clear="all" />
     90</div>
     91<div class="wrap">
     92<p>
     93        <strong>
     94        <?php _e('Your Drafts:') ?>
     95        </strong>
     96<br />
     97        <?php
    698get_currentuserinfo();
    7 
    8 if (0 == $user_level) {
    9     $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php';
    10 } else {
    11     $redirect_to = get_settings('siteurl') . '/wp-admin/post.php';
    12 }
    13 header ("Location: $redirect_to");
     99$drafts = $wpdb->get_results("SELECT ID, post_title FROM $tableposts WHERE post_status = 'draft' AND post_author = $user_ID");
     100if ($drafts) {
     101    ?>
     102    <?php
     103    $i = 0;
     104    foreach ($drafts as $draft) {
     105        if (0 != $i)
     106            echo ', ';
     107        $draft->post_title = stripslashes($draft->post_title);
     108        if ($draft->post_title == '')
     109            $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
     110        echo "<a href='post.php?action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
     111        ++$i;
     112        }
     113        }else{
     114         echo ('No Entries found.');
     115         }
     116        ?>
     117    </p>
     118        </div>
     119<?php
     120require('./admin-footer.php');
    14121?>
Note: See TracChangeset for help on using the changeset viewer.