Changeset 26690
- Timestamp:
- 12/05/2013 09:22:20 PM (11 years ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/dashboard.php
r26617 r26690 45 45 // Activity Widget 46 46 if ( is_blog_admin() ) { 47 wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_ activity' );47 wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); 48 48 } 49 49 … … 344 344 </form> 345 345 <?php 346 $query_args = array(347 'post_type' => 'post', 348 'post_status' => 'draft', 349 'author' => get_current_user_id(), 350 'posts_per_page' => 4, 351 'orderby' => 'modified', 352 'order' => 'DESC' 353 ); 354 $drafts = get_posts( $query_args ); 346 wp_dashboard_recent_drafts(); 347 } 348 349 /** 350 * Show recent drafts of the user on the dashboard. 351 * 352 * @since 2.7.0 353 */ 354 function wp_dashboard_recent_drafts( $drafts = false ) { 355 355 if ( ! $drafts ) { 356 return; 356 $query_args = array( 357 'post_type' => 'post', 358 'post_status' => 'draft', 359 'author' => get_current_user_id(), 360 'posts_per_page' => 4, 361 'orderby' => 'modified', 362 'order' => 'DESC' 363 ); 364 $drafts = get_posts( $query_args ); 365 if ( ! $drafts ) { 366 return; 367 } 357 368 } 358 369 … … 476 487 * @since 3.8.0 477 488 */ 478 function wp_dashboard_ activity() {489 function wp_dashboard_site_activity() { 479 490 480 491 echo '<div id="activity-widget">'; 481 492 482 do_action( 'dashboard_activity_beginning' ); 483 484 $future_posts = dashboard_show_published_posts( array( 493 $future_posts = wp_dashboard_recent_posts( array( 485 494 'display' => 2, 486 495 'max' => 5, … … 490 499 'id' => 'future-posts', 491 500 ) ); 492 $recent_posts = dashboard_show_published_posts( array(501 $recent_posts = wp_dashboard_recent_posts( array( 493 502 'display' => 2, 494 503 'max' => 5, … … 499 508 ) ); 500 509 501 do_action( 'dashboard_activity_middle' ); 502 503 $recent_comments = dashboard_comments(); 510 $recent_comments = wp_dashboard_recent_comments(); 504 511 505 512 if ( !$future_posts && !$recent_posts && !$recent_comments ) { … … 510 517 } 511 518 512 do_action( 'dashboard_activity_end' );513 514 519 echo '</div>'; 515 520 } … … 522 527 * @param array $args 523 528 */ 524 function dashboard_show_published_posts( $args ) { 525 529 function wp_dashboard_recent_posts( $args ) { 526 530 $query_args = array( 527 531 'post_type' => 'post', … … 533 537 'cache_results' => false 534 538 ); 535 $query_args = apply_filters( 'dash_show_published_posts_query_args', $query_args );536 539 $posts = new WP_Query( $query_args ); 537 540 … … 549 552 550 553 $i = 0; 554 $today = date( 'Y-m-d', current_time( 'timestamp' ) ); 555 $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); 556 551 557 while ( $posts->have_posts() ) { 552 558 $posts->the_post(); 559 560 $time = get_the_time( 'U' ); 561 if ( date( 'Y-m-d', $time ) == $today ) { 562 $relative = __( 'Today' ); 563 } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) { 564 $relative = __( 'Tomorrow' ); 565 } else { 566 $relative = date( 'M jS', $time ); 567 } 568 553 569 printf( 554 570 '<li%s><span>%s, %s</span> <a href="%s">%s</a></li>', 555 571 ( $i >= intval ( $args['display'] ) ? ' class="hidden"' : '' ), 556 dashboard_relative_date( get_the_time( 'U' ) ),572 $relative, 557 573 get_the_time(), 558 574 get_edit_post_link(), … … 581 597 * @param int $total_items 582 598 */ 583 function dashboard_comments( $total_items = 5 ) {599 function wp_dashboard_recent_comments( $total_items = 5 ) { 584 600 global $wpdb; 585 601 … … 632 648 633 649 /** 634 * Return relative date for given timestamp.635 *636 * @since 3.8.0637 *638 * @param int $time Unix $timestamp.639 */640 function dashboard_relative_date( $time ) {641 642 $today = date( 'Y-m-d', current_time( 'timestamp' ) );643 $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );644 645 if ( date( 'Y-m-d', $time ) == $today )646 return __( 'Today' );647 648 if ( date( 'Y-m-d', $time ) == $tomorrow )649 return __( 'Tomorrow' );650 651 return date( 'M jS', $time);652 653 }654 655 /**656 650 * Display generic dashboard RSS widget feed. 657 651 * … … 736 730 737 731 /** 732 * The RSS dashboard widget control. 733 * 734 * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data 735 * from RSS-type widgets. 736 * 737 * @since 2.5.0 738 * 739 * @param string $widget_id 740 * @param array $form_inputs 741 */ 742 function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { 743 if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) 744 $widget_options = array(); 745 746 if ( !isset($widget_options[$widget_id]) ) 747 $widget_options[$widget_id] = array(); 748 749 $number = 1; // Hack to use wp_widget_rss_form() 750 $widget_options[$widget_id]['number'] = $number; 751 752 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { 753 $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); 754 $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); 755 $widget_options[$widget_id]['number'] = $number; 756 // title is optional. If black, fill it if possible 757 if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { 758 $rss = fetch_feed($widget_options[$widget_id]['url']); 759 if ( is_wp_error($rss) ) { 760 $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); 761 } else { 762 $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); 763 $rss->__destruct(); 764 unset($rss); 765 } 766 } 767 update_option( 'dashboard_widget_options', $widget_options ); 768 $cache_key = 'dash_' . md5( $widget_id ); 769 delete_transient( $cache_key ); 770 } 771 772 wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); 773 } 774 775 /** 738 776 * WordPress News dashboard widget. 739 777 * … … 745 783 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ), 746 784 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), 747 'title' => '',785 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), 748 786 'items' => 1, 749 787 'show_summary' => 1, … … 754 792 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), 755 793 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), 756 'title' => '',794 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), 757 795 'items' => 3, 758 796 'show_summary' => 0, -
trunk/src/wp-admin/includes/deprecated.php
r26541 r26690 1150 1150 } 1151 1151 /**#@-*/ 1152 1153 /**#@+ 1154 * Deprecated dashboard widget controls. 1155 * 1156 * @since 2.5.0 1157 * @deprecated 3.8.0 1158 */ 1159 function wp_dashboard_incoming_links_output() {} 1160 function wp_dashboard_secondary_output() {} 1161 /**#@-*/ 1162 1163 /**#@+ 1164 * Deprecated dashboard widget controls. 1165 * 1166 * @since 2.7.0 1167 * @deprecated 3.8.0 1168 */ 1169 function wp_dashboard_incoming_links() {} 1170 function wp_dashboard_incoming_links_control() {} 1171 function wp_dashboard_plugins() {} 1172 function wp_dashboard_primary_control() {} 1173 function wp_dashboard_recent_comments_control() {} 1174 function wp_dashboard_secondary() {} 1175 function wp_dashboard_secondary_control() {} 1176 /**#@-*/
Note: See TracChangeset
for help on using the changeset viewer.