Changeset 13084
- Timestamp:
- 02/13/2010 04:39:39 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/dashboard.php
r13057 r13084 29 29 30 30 // Recent Comments Widget 31 if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) { 32 $update = true; 33 $widget_options['dashboard_recent_comments'] = array( 34 'items' => 5, 35 ); 36 } 31 37 $recent_comments_title = __( 'Recent Comments' ); 32 wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments' );38 wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' ); 33 39 34 40 // Incoming Links Widget … … 483 489 $start = 0; 484 490 491 $widgets = get_option( 'dashboard_widget_options' ); 492 if ( isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) ) 493 $total_items = (int) $widgets['dashboard_recent_comments']['items']; 494 else 495 $total_items = 5; 496 485 497 while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { 486 498 487 499 foreach ( $possible as $comment ) { 488 if ( count( $comments ) >= 5)500 if ( count( $comments ) >= $total_items ) 489 501 break; 490 502 if ( in_array( $comment->comment_approved, $allowed_states ) ) … … 616 628 } 617 629 630 /** 631 * The recent comments dashboard widget control. 632 * 633 * @since 3.0.0 634 */ 635 function wp_dashboard_recent_comments_control() { 636 if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) 637 $widget_options = array(); 638 639 if ( !isset($widget_options['dashboard_recent_comments']) ) 640 $widget_options['dashboard_recent_comments'] = array(); 641 642 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-recent-comments']) ) { 643 $number = (int) stripslashes($_POST['widget-recent-comments']['items']); 644 if ( $number < 1 || $number > 15 ) 645 $number = 5; 646 $widget_options['dashboard_recent_comments']['items'] = $number; 647 update_option( 'dashboard_widget_options', $widget_options ); 648 } 649 650 $number = isset( $widget_options['dashboard_recent_comments']['items'] ) ? (int) $widget_options['dashboard_recent_comments']['items'] : ''; 651 652 echo '<p><label for="comments-number">' . __('Number of comments to show:') . '</label>'; 653 echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . $number . '" size="3" /> <small>' . __( '(at most 15)' ) . '</p>'; 654 } 655 618 656 function wp_dashboard_incoming_links() { 619 657 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
Note: See TracChangeset
for help on using the changeset viewer.