-
+ 7FBE4BD45E02AAE52E18D66CFEAA22FCF6067ADF7CAD647BB7652457F07CB635FE7CB999109C25EB8D1212F73B0B27398CA5EE72E24AAA2A54AA204BEE61F113
mp-wp/wp-admin/includes/dashboard.php
(0 . 0)(1 . 840)
32160 <?php
32161 /**
32162 * WordPress Dashboard Widget Administration Panel API
32163 *
32164 * @package WordPress
32165 * @subpackage Administration
32166 */
32167
32168 /**
32169 * Registers dashboard widgets.
32170 *
32171 * handles POST data, sets up filters.
32172 *
32173 * @since unknown
32174 */
32175 function wp_dashboard_setup() {
32176 global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
32177 $wp_dashboard_control_callbacks = array();
32178
32179 $update = false;
32180 $widget_options = get_option( 'dashboard_widget_options' );
32181 if ( !$widget_options || !is_array($widget_options) )
32182 $widget_options = array();
32183
32184 /* Register Widgets and Controls */
32185
32186 // Right Now
32187 wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
32188
32189 // Recent Comments Widget
32190 $recent_comments_title = __( 'Recent Comments' );
32191 wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments' );
32192
32193 // Incoming Links Widget
32194 if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
32195 $update = true;
32196 $widget_options['dashboard_incoming_links'] = array(
32197 'home' => get_option('home'),
32198 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
32199 'url' => 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') ) ),
32200 'items' => isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10,
32201 'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
32202 );
32203 }
32204 wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
32205
32206 // WP Plugins Widget
32207 if ( current_user_can( 'activate_plugins' ) )
32208 wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
32209
32210 // QuickPress Widget
32211 if ( current_user_can('edit_posts') )
32212 wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
32213
32214 // Recent Drafts
32215 if ( current_user_can('edit_posts') )
32216 wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
32217
32218 // Primary feed (Dev Blog) Widget
32219 if ( !isset( $widget_options['dashboard_primary'] ) ) {
32220 $update = true;
32221 $widget_options['dashboard_primary'] = array(
32222 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/development/' ) ),
32223 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/development/feed/' ) ),
32224 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Development Blog' ) ),
32225 'items' => 2,
32226 'show_summary' => 1,
32227 'show_author' => 0,
32228 'show_date' => 1
32229 );
32230 }
32231 wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' );
32232
32233 // Secondary Feed (Planet) Widget
32234 if ( !isset( $widget_options['dashboard_secondary'] ) ) {
32235 $update = true;
32236 $widget_options['dashboard_secondary'] = array(
32237 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
32238 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
32239 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
32240 'items' => 5
32241 );
32242 }
32243 wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
32244
32245 // Hook to register new widgets
32246 do_action( 'wp_dashboard_setup' );
32247
32248 // Filter widget order
32249 $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
32250
32251 foreach ( $dashboard_widgets as $widget_id ) {
32252 $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
32253 wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
32254 }
32255
32256 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
32257 ob_start(); // hack - but the same hack wp-admin/widgets.php uses
32258 wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
32259 ob_end_clean();
32260 wp_redirect( remove_query_arg( 'edit' ) );
32261 exit;
32262 }
32263
32264 if ( $update )
32265 update_option( 'dashboard_widget_options', $widget_options );
32266
32267 do_action('do_meta_boxes', 'dashboard', 'normal', '');
32268 do_action('do_meta_boxes', 'dashboard', 'side', '');
32269 }
32270
32271 function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
32272 global $wp_dashboard_control_callbacks;
32273 if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
32274 $wp_dashboard_control_callbacks[$widget_id] = $control_callback;
32275 if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
32276 list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
32277 $widget_name .= ' <span class="postbox-title-action"><a href="' . clean_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
32278 add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', 'dashboard', 'normal', 'core' );
32279 return;
32280 }
32281 list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
32282 $widget_name .= ' <span class="postbox-title-action"><a href="' . clean_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
32283 }
32284 $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
32285 $location = 'normal';
32286 if ( in_array($widget_id, $side_widgets) )
32287 $location = 'side';
32288 add_meta_box( $widget_id, $widget_name , $callback, 'dashboard', $location, 'core' );
32289 }
32290
32291 function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
32292 echo '<form action="" method="post" class="dashboard-widget-control-form">';
32293 wp_dashboard_trigger_widget_control( $meta_box['id'] );
32294 echo "<p class='submit'><input type='hidden' name='widget_id' value='$meta_box[id]' /><input type='submit' value='" . __( 'Submit' ) . "' /></p>";
32295
32296 echo '</form>';
32297 }
32298
32299 /**
32300 * Displays the dashboard.
32301 *
32302 * @since unknown
32303 */
32304 function wp_dashboard() {
32305 echo "<div id='dashboard-widgets' class='metabox-holder'>\n\n";
32306
32307 echo "<div id='side-info-column' class='inner-sidebar'>\n\n";
32308 $class = do_meta_boxes( 'dashboard', 'side', '' ) ? ' class="has-sidebar"' : '';
32309 echo "</div>\n\n";
32310
32311 echo "<div id='post-body'$class>\n\n";
32312 echo "<div id='dashboard-widgets-main-content' class='has-sidebar-content'>\n\n";
32313 do_meta_boxes( 'dashboard', 'normal', '' );
32314 echo "</div>\n\n";
32315 echo "</div>\n\n";
32316
32317 echo "<form style='display: none' method='get' action=''>\n<p>\n";
32318 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
32319 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
32320 echo "</p>\n</form>\n";
32321
32322 echo "</div>";
32323 }
32324
32325 /* Dashboard Widgets */
32326
32327 function wp_dashboard_right_now() {
32328 $num_posts = wp_count_posts( 'post' );
32329 $num_pages = wp_count_posts( 'page' );
32330
32331 $num_cats = wp_count_terms('category');
32332
32333 $num_tags = wp_count_terms('post_tag');
32334
32335 $num_comm = wp_count_comments( );
32336
32337 echo "\n\t".'<p class="sub">' . __('At a Glance') . '</p>';
32338 echo "\n\t".'<div class="table">'."\n\t".'<table>';
32339 echo "\n\t".'<tr class="first">';
32340
32341 // Posts
32342 $num = number_format_i18n( $num_posts->publish );
32343 if ( current_user_can( 'edit_posts' ) )
32344 $text = "<a href='edit.php'>$num</a>";
32345 else
32346 $text = $num;
32347 echo '<td class="first b b-posts">' . $text . '</td>';
32348 echo '<td class="t posts">' . __ngettext( 'Post', 'Posts', intval($num_posts->publish) ) . '</td>';
32349 /* TODO: Show status breakdown on hover
32350 if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can
32351 $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
32352 }
32353 if ( $can_edit_posts && !empty($num_posts->draft) ) {
32354 $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>';
32355 }
32356 if ( $can_edit_posts && !empty($num_posts->future) ) {
32357 $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>';
32358 }
32359 if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
32360 $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 ) );
32361 } else {
32362 $pending_text = '';
32363 }
32364 */
32365
32366 // Total Comments
32367 $num = number_format_i18n($num_comm->total_comments);
32368 if ( current_user_can( 'moderate_comments' ) )
32369 $num = "<a href='edit-comments.php'>$num</a>";
32370 echo '<td class="b b-comments">'.$num.'</td>';
32371 echo '<td class="last t comments">' . __ngettext( 'Comment', 'Comments', $num_comm->total_comments ) . '</td>';
32372
32373 echo '</tr><tr>';
32374
32375 // Pages
32376 $num = number_format_i18n( $num_pages->publish );
32377 if ( current_user_can( 'edit_pages' ) )
32378 $num = "<a href='edit-pages.php'>$num</a>";
32379 echo '<td class="first b b_pages">'.$num.'</td>';
32380 echo '<td class="t pages">' . __ngettext( 'Page', 'Pages', $num_pages->publish ) . '</td>';
32381
32382 // Approved Comments
32383 $num = number_format_i18n($num_comm->approved);
32384 if ( current_user_can( 'moderate_comments' ) )
32385 $num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
32386 echo '<td class="b b_approved">'.$num.'</td>';
32387 echo '<td class="last t approved">' . __ngettext( 'Approved', 'Approved', $num_comm->approved ) . '</td>';
32388
32389 echo "</tr>\n\t<tr>";
32390
32391 // Categories
32392 $num = number_format_i18n( $num_cats );
32393 if ( current_user_can( 'manage_categories' ) )
32394 $num = "<a href='categories.php'>$num</a>";
32395 echo '<td class="first b b-cats">'.$num.'</td>';
32396 echo '<td class="t cats">' . __ngettext( 'Category', 'Categories', $num_cats ) . '</td>';
32397
32398 // Pending Comments
32399 $num = number_format_i18n($num_comm->moderated);
32400 if ( current_user_can( 'moderate_comments' ) )
32401 $num = "<a href='edit-comments.php?comment_status=moderated'><span class='pending-count'>$num</span></a>";
32402 echo '<td class="b b-waiting">'.$num.'</td>';
32403 echo '<td class="last t waiting">' . __ngettext( 'Pending', 'Pending', $num_comm->moderated ) . '</td>';
32404
32405 echo "</tr>\n\t<tr>";
32406
32407 // Tags
32408 $num = number_format_i18n( $num_tags );
32409 if ( current_user_can( 'manage_categories' ) )
32410 $num = "<a href='edit-tags.php'>$num</a>";
32411 echo '<td class="first b b-tags">'.$num.'</td>';
32412 echo '<td class="t tags">' . __ngettext( 'Tag', 'Tags', $num_tags ) . '</td>';
32413
32414 // Spam Comments
32415 $num = number_format_i18n($num_comm->spam);
32416 if ( current_user_can( 'moderate_comments' ) )
32417 $num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";
32418 echo '<td class="b b-spam">'.$num.'</td>';
32419 echo '<td class="last t spam">' . __ngettext( 'Spam', 'Spam', $num_comm->spam ) . '</td>';
32420
32421 echo "</tr>";
32422 do_action('right_now_table_end');
32423 echo "\n\t</table>\n\t</div>";
32424
32425 echo "\n\t".'<div class="versions">';
32426 $ct = current_theme_info();
32427 $sidebars_widgets = wp_get_sidebars_widgets();
32428 $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ), 0 );
32429 $num = number_format_i18n( $num_widgets );
32430
32431 echo "\n\t<p>";
32432 if ( current_user_can( 'switch_themes' ) ) {
32433 echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
32434 printf(__ngettext('Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $ct->title, $num);
32435 } else {
32436 printf(__ngettext('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $ct->title, $num);
32437 }
32438
32439 echo '</p>';
32440
32441 update_right_now_message();
32442
32443 echo "\n\t".'</div>';
32444 do_action( 'rightnow_end' );
32445 do_action( 'activity_box_end' );
32446 }
32447
32448 function wp_dashboard_quick_press() {
32449 $drafts = false;
32450 if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
32451 $view = get_permalink( $_POST['post_ID'] );
32452 $edit = clean_url( get_edit_post_link( $_POST['post_ID'] ) );
32453 if ( 'post-quickpress-publish' == $_POST['action'] ) {
32454 if ( current_user_can('publish_posts') )
32455 printf( '<div class="message"><p>' . __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( $view ), $edit );
32456 else
32457 printf( '<div class="message"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( add_query_arg( 'preview', 1, $view ) ), $edit );
32458 } else {
32459 printf( '<div class="message"><p>' . __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( add_query_arg( 'preview', 1, $view ) ), $edit );
32460 $drafts_query = new WP_Query( array(
32461 'post_type' => 'post',
32462 'what_to_show' => 'posts',
32463 'post_status' => 'draft',
32464 'author' => $GLOBALS['current_user']->ID,
32465 'posts_per_page' => 1,
32466 'orderby' => 'modified',
32467 'order' => 'DESC'
32468 ) );
32469
32470 if ( $drafts_query->posts )
32471 $drafts =& $drafts_query->posts;
32472 }
32473 printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="tools.php">' . __('Press This') . '</a>' );
32474 $_REQUEST = array(); // hack for get_default_post_to_edit()
32475 }
32476
32477 $post = get_default_post_to_edit();
32478 ?>
32479
32480 <form name="post" action="<?php echo clean_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
32481 <h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4>
32482 <div class="input-text-wrap">
32483 <input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo attribute_escape( $post->post_title ); ?>" />
32484 </div>
32485
32486 <?php if ( current_user_can( 'upload_files' ) ) : ?>
32487 <div id="media-buttons" class="hide-if-no-js">
32488 <?php do_action( 'media_buttons' ); ?>
32489 </div>
32490 <?php endif; ?>
32491
32492 <h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4>
32493 <div class="textarea-wrap">
32494 <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo $post->post_content; ?></textarea>
32495 </div>
32496
32497 <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>
32498
32499 <h4><label for="tags-input"><?php _e('Tags') ?></label></h4>
32500 <div class="input-text-wrap">
32501 <input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
32502 </div>
32503
32504 <p class="submit">
32505 <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
32506 <input type="hidden" name="quickpress_post_ID" value="<?php echo (int) $post->ID; ?>" />
32507 <?php wp_nonce_field('add-post'); ?>
32508 <input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php _e('Save Draft'); ?>" />
32509 <input type="reset" value="<?php _e( 'Cancel' ); ?>" class="cancel" />
32510 <?php if ( current_user_can('publish_posts') ) { ?>
32511 <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php _e('Publish'); ?>" />
32512 <?php } else { ?>
32513 <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php _e('Submit for Review'); ?>" />
32514 <?php } ?>
32515 <br class="clear" />
32516 </p>
32517
32518 </form>
32519
32520 <?php
32521 if ( $drafts )
32522 wp_dashboard_recent_drafts( $drafts );
32523 }
32524
32525 function wp_dashboard_recent_drafts( $drafts = false ) {
32526 if ( !$drafts ) {
32527 $drafts_query = new WP_Query( array(
32528 'post_type' => 'post',
32529 'what_to_show' => 'posts',
32530 'post_status' => 'draft',
32531 'author' => $GLOBALS['current_user']->ID,
32532 'posts_per_page' => 5,
32533 'orderby' => 'modified',
32534 'order' => 'DESC'
32535 ) );
32536 $drafts =& $drafts_query->posts;
32537 }
32538
32539 if ( $drafts && is_array( $drafts ) ) {
32540 $list = array();
32541 foreach ( $drafts as $draft ) {
32542 $url = get_edit_post_link( $draft->ID );
32543 $title = _draft_or_post_title( $draft->ID );
32544 $item = "<h4><a href='$url' title='" . sprintf( __( 'Edit "%s"' ), attribute_escape( $title ) ) . "'>$title</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time( get_option( 'date_format' ), $draft ) . '</abbr></h4>';
32545 if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )
32546 $item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '…' : '' ) . '</p>';
32547 $list[] = $item;
32548 }
32549 ?>
32550 <ul>
32551 <li><?php echo join( "</li>\n<li>", $list ); ?></li>
32552 </ul>
32553 <p class="textright"><a href="edit.php?post_status=draft" class="button"><?php _e('View all'); ?></a></p>
32554 <?php
32555 } else {
32556 _e('There are no drafts at the moment');
32557 }
32558 }
32559
32560 /**
32561 * Display recent comments dashboard widget content.
32562 *
32563 * @since unknown
32564 */
32565 function wp_dashboard_recent_comments() {
32566 global $wpdb;
32567
32568 if ( current_user_can('edit_posts') )
32569 $allowed_states = array('0', '1');
32570 else
32571 $allowed_states = array('1');
32572
32573 // Select all comment types and filter out spam later for better query performance.
32574 $comments = array();
32575 $start = 0;
32576
32577 while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) {
32578
32579 foreach ( $possible as $comment ) {
32580 if ( count( $comments ) >= 5 )
32581 break;
32582 if ( in_array( $comment->comment_approved, $allowed_states ) )
32583 $comments[] = $comment;
32584 }
32585
32586 $start = $start + 50;
32587 }
32588
32589 if ( $comments ) :
32590 ?>
32591
32592 <div id="the-comment-list" class="list:comment">
32593 <?php
32594 foreach ( $comments as $comment )
32595 _wp_dashboard_recent_comments_row( $comment );
32596 ?>
32597
32598 </div>
32599
32600 <?php
32601 if ( current_user_can('edit_posts') ) { ?>
32602 <p class="textright"><a href="edit-comments.php" class="button"><?php _e('View all'); ?></a></p>
32603 <?php }
32604
32605 wp_comment_reply( -1, false, 'dashboard', false );
32606
32607 else :
32608 ?>
32609
32610 <p><?php _e( 'No comments yet.' ); ?></p>
32611
32612 <?php
32613 endif; // $comments;
32614 }
32615
32616 function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
32617 $GLOBALS['comment'] =& $comment;
32618
32619 $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
32620 $comment_post_title = get_the_title( $comment->comment_post_ID );
32621 $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
32622 $comment_link = '<a class="comment-link" href="' . get_comment_link() . '">#</a>';
32623
32624 $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
32625 $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
32626 $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
32627 $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
32628
32629 $actions = array();
32630
32631 $actions_string = '';
32632 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
32633 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
32634 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
32635 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
32636 //$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
32637 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
32638 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . _c( 'Spam|verb' ) . '</a>';
32639 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
32640
32641 $actions = apply_filters( 'comment_row_actions', $actions, $comment );
32642
32643 $i = 0;
32644 foreach ( $actions as $action => $link ) {
32645 ++$i;
32646 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
32647
32648 // Reply and quickedit need a hide-if-no-js span
32649 if ( 'reply' == $action || 'quickedit' == $action )
32650 $action .= ' hide-if-no-js';
32651
32652 $actions_string .= "<span class='$action'>$sep$link</span>";
32653 }
32654 }
32655
32656 ?>
32657
32658 <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
32659 <?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
32660
32661 <?php echo get_avatar( $comment, 50 ); ?>
32662 <h4 class="comment-meta"><?php printf( __( 'From %1$s on %2$s%3$s' ), '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link." ".$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?></h4>
32663
32664 <?php
32665 else :
32666 switch ( $comment->comment_type ) :
32667 case 'pingback' :
32668 $type = __( 'Pingback' );
32669 break;
32670 case 'trackback' :
32671 $type = __( 'Trackback' );
32672 break;
32673 default :
32674 $type = ucwords( $comment->comment_type );
32675 endswitch;
32676 $type = wp_specialchars( $type );
32677 ?>
32678
32679 <h4 class="comment-meta"><?php printf( __( '%1$s on %2$s' ), "<strong>$type</strong>", $comment_post_link ); ?></h4>
32680 <p class="comment-author"><?php comment_author_link(); ?></p>
32681
32682 <?php endif; // comment_type ?>
32683 <blockquote><p><?php comment_excerpt(); ?></p></blockquote>
32684 <p class="row-actions"><?php echo $actions_string; ?></p>
32685
32686 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
32687 <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
32688 <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div>
32689 <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div>
32690 <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div>
32691 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
32692 </div>
32693
32694 </div>
32695 <?php
32696 }
32697
32698 function wp_dashboard_incoming_links() {
32699 wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' );
32700 }
32701
32702 /**
32703 * Display incoming links dashboard widget content.
32704 *
32705 * @since unknown
32706 */
32707 function wp_dashboard_incoming_links_output() {
32708 $widgets = get_option( 'dashboard_widget_options' );
32709 @extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
32710 $rss = @fetch_rss( $url );
32711 if ( isset($rss->items) && 0 < count($rss->items) ) {
32712
32713 echo "<ul>\n";
32714
32715 $rss->items = array_slice($rss->items, 0, $items);
32716 foreach ( $rss->items as $item ) {
32717 $publisher = '';
32718 $site_link = '';
32719 $link = '';
32720 $content = '';
32721 $date = '';
32722 $link = clean_url( strip_tags( $item['link'] ) );
32723
32724 if ( isset( $item['author_uri'] ) )
32725 $site_link = clean_url( strip_tags( $item['author_uri'] ) );
32726
32727 if ( !$publisher = wp_specialchars( strip_tags( isset($item['dc']['publisher']) ? $item['dc']['publisher'] : $item['author_name'] ) ) )
32728 $publisher = __( 'Somebody' );
32729 if ( $site_link )
32730 $publisher = "<a href='$site_link'>$publisher</a>";
32731 else
32732 $publisher = "<strong>$publisher</strong>";
32733
32734 if ( isset($item['description']) )
32735 $content = $item['description'];
32736 elseif ( isset($item['summary']) )
32737 $content = $item['summary'];
32738 elseif ( isset($item['atom_content']) )
32739 $content = $item['atom_content'];
32740 else
32741 $content = __( 'something' );
32742 $content = wp_html_excerpt($content, 50) . ' ...';
32743 if ( $link )
32744 $text = _c( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"|feed_display' );
32745 else
32746 $text = _c( '%1$s linked here saying, "%3$s"|feed_display' );
32747
32748 if ( $show_date ) {
32749 if ( $show_author || $show_summary )
32750 $text .= _c( ' on %4$s|feed_display' );
32751 $date = wp_specialchars( strip_tags( isset($item['pubdate']) ? $item['pubdate'] : $item['published'] ) );
32752 $date = strtotime( $date );
32753 $date = gmdate( get_option( 'date_format' ), $date );
32754 }
32755
32756 echo "\t<li>" . sprintf( _c( "$text|feed_display" ), $publisher, $link, $content, $date ) . "</li>\n";
32757 }
32758
32759 echo "</ul>\n";
32760
32761 } else {
32762 echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "</p>\n";
32763 }
32764 }
32765
32766 function wp_dashboard_incoming_links_control() {
32767 wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) );
32768 }
32769
32770 function wp_dashboard_primary() {
32771 wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' );
32772 }
32773
32774 function wp_dashboard_primary_control() {
32775 wp_dashboard_rss_control( 'dashboard_primary' );
32776 }
32777
32778 /**
32779 * {@internal Missing Short Description}}
32780 *
32781 * @since unknown
32782 *
32783 * @param int $widget_id
32784 */
32785 function wp_dashboard_rss_output( $widget_id ) {
32786 $widgets = get_option( 'dashboard_widget_options' );
32787 echo "<div class='rss-widget'>";
32788 wp_widget_rss_output( $widgets[$widget_id] );
32789 echo "</div>";
32790 }
32791
32792 function wp_dashboard_secondary() {
32793 wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );
32794 }
32795
32796 function wp_dashboard_secondary_control() {
32797 wp_dashboard_rss_control( 'dashboard_secondary' );
32798 }
32799
32800 /**
32801 * Display secondary dashboard RSS widget feed.
32802 *
32803 * @since unknown
32804 *
32805 * @return unknown
32806 */
32807 function wp_dashboard_secondary_output() {
32808 $widgets = get_option( 'dashboard_widget_options' );
32809 @extract( @$widgets['dashboard_secondary'], EXTR_SKIP );
32810 $rss = @fetch_rss( $url );
32811
32812 if ( !isset($rss->items) || 0 == count($rss->items) )
32813 return false;
32814
32815 $rss->items = array_slice($rss->items, 0, $items);
32816
32817 if ( 'http://planet.wordpress.org/' == $rss->channel['link'] ) {
32818 foreach ( array_keys($rss->items) as $i ) {
32819 list($site, $description) = explode( ':', wp_specialchars($rss->items[$i]['title']), 2 );
32820 $rss->items[$i]['dc']['creator'] = trim($site);
32821 $rss->items[$i]['title'] = trim($description);
32822 }
32823 }
32824
32825 echo "<div class='rss-widget'>";
32826 wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
32827 echo "</div>";
32828 }
32829
32830 function wp_dashboard_plugins() {
32831 wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array(
32832 'http://wordpress.org/extend/plugins/rss/browse/popular/',
32833 'http://wordpress.org/extend/plugins/rss/browse/new/',
32834 'http://wordpress.org/extend/plugins/rss/browse/updated/'
32835 ) );
32836 }
32837
32838 /**
32839 * Display plugins most popular, newest plugins, and recently updated widget text.
32840 *
32841 * @since unknown
32842 */
32843 function wp_dashboard_plugins_output() {
32844 $popular = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
32845 $new = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
32846 $updated = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/updated/' );
32847
32848 foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) {
32849 if ( !isset($$feed->items) || 0 == count($$feed->items) )
32850 continue;
32851
32852 $$feed->items = array_slice($$feed->items, 0, 5);
32853 $item_key = array_rand($$feed->items);
32854
32855 // Eliminate some common badly formed plugin descriptions
32856 while ( ( null !== $item_key = array_rand($$feed->items) ) && false !== strpos( $$feed->items[$item_key]['description'], 'Plugin Name:' ) )
32857 unset($$feed->items[$item_key]);
32858
32859 if ( !isset($$feed->items[$item_key]) )
32860 continue;
32861
32862 $item = $$feed->items[$item_key];
32863
32864 // current bbPress feed item titles are: user on "topic title"
32865 if ( preg_match( '/"(.*)"/s', $item['title'], $matches ) )
32866 $title = $matches[1];
32867 else // but let's make it forward compatible if things change
32868 $title = $item['title'];
32869 $title = wp_specialchars( $title );
32870
32871 $description = wp_specialchars( strip_tags(html_entity_decode($item['description'], ENT_QUOTES)) );
32872
32873 list($link, $frag) = explode( '#', $item['link'] );
32874
32875 $link = clean_url($link);
32876 if( preg_match('|/([^/]+?)/?$|', $link, $matches) )
32877 $slug = $matches[1];
32878 else
32879 $slug = '';
32880
32881 $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
32882 '&TB_iframe=true&width=600&height=800';
32883
32884 echo "<h4>$label</h4>\n";
32885 echo "<h5><a href='$link'>$title</a></h5> <span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
32886 echo "<p>$description</p>\n";
32887 }
32888 }
32889
32890 /**
32891 * Checks to see if all of the feed url in $check_urls are cached.
32892 *
32893 * If $check_urls is empty, look for the rss feed url found in the dashboard
32894 * widget optios of $widget_id. If cached, call $callback, a function that
32895 * echoes out output for this widget. If not cache, echo a "Loading..." stub
32896 * which is later replaced by AJAX call (see top of /wp-admin/index.php)
32897 *
32898 * @since unknown
32899 *
32900 * @param int $widget_id
32901 * @param callback $callback
32902 * @param array $check_urls RSS feeds
32903 * @return bool False on failure. True on success.
32904 */
32905 function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
32906 $loading = '<p class="widget-loading">' . __( 'Loading…' ) . '</p>';
32907
32908 if ( empty($check_urls) ) {
32909 $widgets = get_option( 'dashboard_widget_options' );
32910 if ( empty($widgets[$widget_id]['url']) ) {
32911 echo $loading;
32912 return false;
32913 }
32914 $check_urls = array( $widgets[$widget_id]['url'] );
32915 }
32916
32917
32918 require_once( ABSPATH . WPINC . '/rss.php' );
32919 init(); // initialize rss constants
32920
32921 $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
32922
32923 foreach ( $check_urls as $check_url ) {
32924 $status = $cache->check_cache( $check_url );
32925 if ( 'HIT' !== $status ) {
32926 echo $loading;
32927 return false;
32928 }
32929 }
32930
32931 if ( $callback && is_callable( $callback ) ) {
32932 $args = array_slice( func_get_args(), 2 );
32933 array_unshift( $args, $widget_id );
32934 call_user_func_array( $callback, $args );
32935 }
32936
32937 return true;
32938 }
32939
32940 /* Dashboard Widgets Controls */
32941
32942 // Calls widget_control callback
32943 /**
32944 * Calls widget control callback.
32945 *
32946 * @since unknown
32947 *
32948 * @param int $widget_control_id Registered Widget ID.
32949 */
32950 function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
32951 global $wp_dashboard_control_callbacks;
32952
32953 if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) {
32954 call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
32955 }
32956 }
32957
32958 /**
32959 * The RSS dashboard widget control.
32960 *
32961 * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
32962 * from RSS-type widgets.
32963 *
32964 * @since unknown
32965 *
32966 * @param string widget_id
32967 * @param array form_inputs
32968 */
32969 function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
32970 if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
32971 $widget_options = array();
32972
32973 if ( !isset($widget_options[$widget_id]) )
32974 $widget_options[$widget_id] = array();
32975
32976 $number = 1; // Hack to use wp_widget_rss_form()
32977 $widget_options[$widget_id]['number'] = $number;
32978
32979 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
32980 $_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] );
32981 $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
32982 // title is optional. If black, fill it if possible
32983 if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
32984 require_once(ABSPATH . WPINC . '/rss.php');
32985 $rss = fetch_rss($widget_options[$widget_id]['url']);
32986 $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->channel['title']));
32987 }
32988 update_option( 'dashboard_widget_options', $widget_options );
32989 }
32990
32991 wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
32992 }
32993
32994 /**
32995 * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
32996 */
32997 function wp_dashboard_empty() {}
32998
32999 ?>