To avoid monolithic commits I'm going to be bringing this in piece by piece. No need to file bug about lack of styling, it's on purpose right now. Trunk will be hit with the oogly stick for 2-3 days. This brings in structure for new dashboard.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2007-12-20 20:23:30 +00:00
parent 7f722d1f90
commit ff4b271a82
2 changed files with 91 additions and 71 deletions

View File

@ -9,12 +9,12 @@ switch ( $_GET['jax'] ) {
case 'incominglinks' :
$rss_feed = apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) );
$more_link = apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) );
$rss = @fetch_rss( $rss_feed );
if ( isset($rss->items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results
?>
<h3><?php _e('Incoming Links'); ?> <cite><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('More &raquo;'); ?></a></cite></h3>
<ul>
<?php
$rss->items = array_slice($rss->items, 0, 10);
@ -24,19 +24,21 @@ foreach ($rss->items as $item ) {
<?php } ?>
</ul>
<?php
} else {
?>
<p><?php _e('No incoming links found... yet.'); ?></p>
<?php
}
break;
case 'devnews' :
$rss = @fetch_rss(apply_filters( 'dashboard_primary_feed', 'http://wordpress.org/development/feed/' ));
if ( isset($rss->items) && 0 != count($rss->items) ) {
?>
<h3><?php echo apply_filters( 'dashboard_primary_title', __('WordPress Development Blog') ); ?></h3>
<?php
$rss->items = array_slice($rss->items, 0, 3);
$rss->items = array_slice($rss->items, 0, 2);
foreach ($rss->items as $item ) {
?>
<h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4>
<h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> <?php gmdate( 'Y/m/d', strtotime( $item['pubdate'] ) ); ?></h4>
<p><?php echo $item['description']; ?></p>
<?php
}

View File

@ -7,7 +7,7 @@ function index_js() {
jQuery(function() {
jQuery('#incominglinks').load('index-extra.php?jax=incominglinks');
jQuery('#devnews').load('index-extra.php?jax=devnews');
jQuery('#planetnews').load('index-extra.php?jax=planetnews');
// jQuery('#planetnews').load('index-extra.php?jax=planetnews');
});
</script>
<?php
@ -25,12 +25,61 @@ $today = current_time('mysql', 1);
<div class="wrap">
<h2><?php _e('Welcome to WordPress'); ?></h2>
<h2><?php _e('Dashboard'); ?></h2>
<div id="zeitgeist">
<h2><?php _e('Latest Activity'); ?></h2>
<div id="rightnow">
<h3><?php _e('Right Now'); ?> <a href="post-new.php"><?php _e('Write a New Page'); ?></a> <a href="page-new.php"><?php _e('Write a New Post'); ?></a></h3>
<div id="incominglinks"></div>
<?php
// I'm not sure how to internationalize this, Nikolay?
$num_posts = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'" );
$num_pages = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish'" );
$num_drafts = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft'" );
$num_future = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'future'" );
$num_comments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
$num_cats = wp_count_terms('category');
$num_tags = wp_count_terms('post_tag');
$sentence = 'You have ';
if ( $num_posts )
$sentence .= '<a href="edit.php">' . number_format( $num_posts ) . ' posts</a>, ';
if ( $num_pages )
$sentence .= '<a href="edit-pages.php">' . number_format( $num_pages ) . ' pages</a>, ';
if ( $num_drafts )
$sentence .= '<a href="edit.php?post_status=draft">' . number_format( $num_drafts ) . ' drafts</a>, ';
if ( $num_future )
$sentence .= '<a href="edit.php?post_status=future">' . number_format( $num_future ) . ' scheduled posts</a>, ';
// There is always a category
$sentence .= 'contained within <a href="categories.php">' . number_format( $num_cats ) . ' categories</a> and ' . number_format( $num_tags ) . ' tags.';
?>
<p><?php echo $sentence; ?></p>
<?php
$ct = current_theme_info();
$sidebars_widgets = wp_get_sidebars_widgets();
$num_widgets = count( $sidebar_widgets );
?>
<p>You use the <?php echo $ct->title; ?> theme with <a href='widgets.php'><?php echo $num_widgets; ?> widgets</a>. <a href="themes.php">Change Theme</a>. You're using BetaPress TODO.</p>
<?php do_action( 'rightnow_end' ); ?>
<?php do_action( 'activity_box_end' ); ?>
</div>
<div id="dashboard-widgets">
<div class="dashboard-widget">
<div class="dashboard-widget-edit"><a href="">See All</a> | <a href="">Edit</a></div>
<h3>Recent Comments</h3>
<?php
$comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5");
@ -38,8 +87,6 @@ $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE commen
if ( $comments || $numcomments ) :
?>
<div>
<h3><?php printf( __( 'Comments <a href="%s" title="More comments&#8230;">&raquo;</a>' ), 'edit-comments.php' ); ?></h3>
<?php if ( $numcomments ) : ?>
<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s) &raquo;'), number_format_i18n($numcomments) ); ?></a></strong></p>
@ -56,14 +103,27 @@ foreach ($comments as $comment) {
}
?>
</ul>
</div>
<?php endif; ?>
</div>
<div class="dashboard-widget">
<?php
if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
$more_link = apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) );
?>
<div>
<h3><?php printf( __( 'Posts <a href="%s" title="More posts&#8230;">&raquo;</a>' ), 'edit.php' ); ?></h3>
<div class="dashboard-widget-edit"><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('See All'); ?></a> | <a href="">Edit</a></div>
<h3>Incoming Links</h3>
<div id="incominglinks"></div>
</div>
<div class="dashboard-widget">
<?php
$recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5");
?>
<div class="dashboard-widget-edit"><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('See All'); ?></a> | <a href="">Edit</a></div>
<h3>Recent Posts</h3>
<ul>
<?php
foreach ($recentposts as $post) {
@ -76,62 +136,20 @@ foreach ($recentposts as $post) {
?>
</ul>
</div>
<?php endif; ?>
<?php
if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'future' ORDER BY post_date ASC") ) :
?>
<div>
<h3><?php _e('Scheduled Entries:') ?></h3>
<ul>
<?php
foreach ($scheduled as $post) {
if ($post->post_title == '')
$post->post_title = sprintf(__('Post #%s'), $post->ID);
echo "<li>" . sprintf(__('%1$s in %2$s'), "<a href='post.php?action=edit&amp;post=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a>", human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt. ' GMT') )) . "</li>";
}
?>
</ul>
</div>
<?php endif; ?>
<div>
<h3><?php _e('Blog Stats'); ?></h3>
<?php
$numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
$numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
$numcats = wp_count_terms('category');
$numtags = wp_count_terms('post_tag');
$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format_i18n($numposts), 'edit.php');
$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format_i18n($numcomms), 'edit-comments.php');
$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format_i18n($numcats), 'categories.php');
$tag_str = sprintf(__ngettext('%1$s tag', '%1$s tags', $numtags), number_format_i18n($numtags));
?>
<p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s and %4$s.'), $post_str, $comm_str, $cat_str, $tag_str); ?></p>
</div>
<?php do_action('activity_box_end'); ?>
</div>
<p><?php _e('Use these links to get started:'); ?></p>
<ul>
<?php if ( current_user_can('edit_posts') ) : ?>
<li><a href="post-new.php"><?php _e('Write a post'); ?></a></li>
<?php endif; ?>
<li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li>
<?php if ( current_user_can('manage_links') ) : ?>
<li><a href="link-add.php"><?php _e('Add a link to your blogroll'); ?></a></li>
<?php endif; ?>
<?php if ( current_user_can('switch_themes') ) : ?>
<li><a href="themes.php"><?php _e('Change your site&#8217;s look or theme'); ?></a></li>
<?php endif; ?>
</ul>
<p><?php _e("Need help with WordPress? Please see our <a href='http://codex.wordpress.org/'>documentation</a> or visit the <a href='http://wordpress.org/support/'>support forums</a>."); ?></p>
<div class="dashboard-widget">
<div class="dashboard-widget-edit"><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('See All'); ?></a> | <a href="">Edit</a> | <a href="">RSS</a></div>
<h3><?php echo apply_filters( 'dashboard_primary_title', __('Blog') ); ?></h3>
<div id="devnews"></div>
</div>
<?php do_action( 'dashboard_widgets' ); ?>
<p><a href="">Customize this page</a>.</p>
</div>
<div id="planetnews"></div>