WordPress.org

Make WordPress Core

Changeset 26690


Ignore:
Timestamp:
12/05/2013 09:22:20 PM (8 years ago)
Author:
nacin
Message:

Dashboard backwards compatibility updates.

  • Restore missing wp_dashboard_rss_control() helper.
  • Restore all original 3.7 functions, deprecating many, reusing others.
  • Rename and remove functions so as not to clash with the original dash plugin.
  • Filter cleanup/restoration.

see #25824, #26334.

Location:
trunk/src/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/dashboard.php

    r26617 r26690  
    4545    // Activity Widget
    4646    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' );
    4848    }
    4949
     
    344344    </form>
    345345    <?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 */
     354function wp_dashboard_recent_drafts( $drafts = false ) {
    355355    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        }
    357368    }
    358369
     
    476487 * @since 3.8.0
    477488 */
    478 function wp_dashboard_activity() {
     489function wp_dashboard_site_activity() {
    479490
    480491    echo '<div id="activity-widget">';
    481492
    482     do_action( 'dashboard_activity_beginning' );
    483 
    484     $future_posts = dashboard_show_published_posts( array(
     493    $future_posts = wp_dashboard_recent_posts( array(
    485494        'display' => 2,
    486495        'max'     => 5,
     
    490499        'id'      => 'future-posts',
    491500    ) );
    492     $recent_posts = dashboard_show_published_posts( array(
     501    $recent_posts = wp_dashboard_recent_posts( array(
    493502        'display' => 2,
    494503        'max'     => 5,
     
    499508    ) );
    500509
    501     do_action( 'dashboard_activity_middle' );
    502 
    503     $recent_comments = dashboard_comments();
     510    $recent_comments = wp_dashboard_recent_comments();
    504511
    505512    if ( !$future_posts && !$recent_posts && !$recent_comments ) {
     
    510517    }
    511518
    512     do_action( 'dashboard_activity_end' );
    513 
    514519    echo '</div>';
    515520}
     
    522527 * @param array $args
    523528 */
    524 function dashboard_show_published_posts( $args ) {
    525 
     529function wp_dashboard_recent_posts( $args ) {
    526530    $query_args = array(
    527531        'post_type'      => 'post',
     
    533537        'cache_results'  => false
    534538    );
    535     $query_args = apply_filters( 'dash_show_published_posts_query_args', $query_args );
    536539    $posts = new WP_Query( $query_args );
    537540
     
    549552
    550553        $i = 0;
     554        $today    = date( 'Y-m-d', current_time( 'timestamp' ) );
     555        $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
     556
    551557        while ( $posts->have_posts() ) {
    552558            $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
    553569            printf(
    554570                '<li%s><span>%s, %s</span> <a href="%s">%s</a></li>',
    555571                ( $i >= intval ( $args['display'] ) ? ' class="hidden"' : '' ),
    556                 dashboard_relative_date( get_the_time( 'U' ) ),
     572                $relative,
    557573                get_the_time(),
    558574                get_edit_post_link(),
     
    581597 * @param int $total_items
    582598 */
    583 function dashboard_comments( $total_items = 5 ) {
     599function wp_dashboard_recent_comments( $total_items = 5 ) {
    584600    global $wpdb;
    585601
     
    632648
    633649/**
    634  * Return relative date for given timestamp.
    635  *
    636  * @since 3.8.0
    637  *
    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 /**
    656650 * Display generic dashboard RSS widget feed.
    657651 *
     
    736730
    737731/**
     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 */
     742function 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/**
    738776 * WordPress News dashboard widget.
    739777 *
     
    745783            'link'         => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ),
    746784            'url'          => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
    747             'title'        => '',
     785            'title'        => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
    748786            'items'        => 1,
    749787            'show_summary' => 1,
     
    754792            'link'         => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
    755793            'url'          => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
    756             'title'        => '',
     794            'title'        => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
    757795            'items'        => 3,
    758796            'show_summary' => 0,
  • trunk/src/wp-admin/includes/deprecated.php

    r26541 r26690  
    11501150}
    11511151/**#@-*/
     1152
     1153/**#@+
     1154 * Deprecated dashboard widget controls.
     1155 *
     1156 * @since 2.5.0
     1157 * @deprecated 3.8.0
     1158 */
     1159function wp_dashboard_incoming_links_output() {}
     1160function wp_dashboard_secondary_output() {}
     1161/**#@-*/
     1162
     1163/**#@+
     1164 * Deprecated dashboard widget controls.
     1165 *
     1166 * @since 2.7.0
     1167 * @deprecated 3.8.0
     1168 */
     1169function wp_dashboard_incoming_links() {}
     1170function wp_dashboard_incoming_links_control() {}
     1171function wp_dashboard_plugins() {}
     1172function wp_dashboard_primary_control() {}
     1173function wp_dashboard_recent_comments_control() {}
     1174function wp_dashboard_secondary() {}
     1175function wp_dashboard_secondary_control() {}
     1176/**#@-*/
Note: See TracChangeset for help on using the changeset viewer.