Make WordPress Core

Ticket #19239: 19239.diff

File 19239.diff, 8.2 KB (added by ericmann, 12 years ago)

Initial Patch

  • wp-admin/css/wp-admin.css

     
    65176517        word-wrap: break-word;
    65186518}
    65196519
     6520/* Newsfeed Widget */
     6521#dashboard_wp_newsfeed .wp-official {
     6522        height: 16px;
     6523        width: 16px;
     6524        margin-right: 8px;
     6525        display: inline-block;
     6526        background: url(../images/wp-logo-vs.png) no-repeat center center;
     6527        position: relative;
     6528        top: 3px;
     6529}
     6530
     6531#dashboard_wp_newsfeed h4 {
     6532        font-weight: bold;
     6533        padding-bottom: 0.5em;
     6534        border-bottom: 1px solid #333;
     6535}
     6536
    65206537/* Browser Nag */
    65216538#dashboard_browser_nag a.update-browser-link {
    65226539        font-size: 1.2em;
     
    85128529        .customize-loading #customize-container {
    85138530                background-image: url(../images/wpspin_light-2x.gif);
    85148531        }
     8532
     8533        #dashboard_wp_newsfeed .wp-official {
     8534            background-image: url(../images/wp-logo-vs-2x.png);
     8535            background-size: 16px 16px;
     8536    }
    85158537}
    85168538
    85178539/* =Localized CSS
  • wp-admin/includes/ajax-actions.php

     
    194194                case 'dashboard_incoming_links' :
    195195                        wp_dashboard_incoming_links();
    196196                        break;
    197                 case 'dashboard_primary' :
    198                         wp_dashboard_primary();
     197                case 'dashboard_wp_newsfeed':
     198                        wp_dashboard_newsfeed();
    199199                        break;
    200                 case 'dashboard_secondary' :
    201                         wp_dashboard_secondary();
    202                         break;
    203200                case 'dashboard_plugins' :
    204201                        wp_dashboard_plugins();
    205202                        break;
  • wp-admin/includes/dashboard.php

     
    8282        if ( is_blog_admin() && current_user_can('edit_posts') )
    8383                wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
    8484
    85         // Primary feed (Dev Blog) Widget
    86         if ( !isset( $widget_options['dashboard_primary'] ) ) {
    87                 $update = true;
    88                 $widget_options['dashboard_primary'] = array(
    89                         'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ),
    90                         'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
    91                         'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
    92                         'items' => 2,
    93                         'show_summary' => 1,
    94                         'show_author' => 0,
    95                         'show_date' => 1,
    96                 );
    97         }
    98         wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' );
     85        // WordPress Feed Widget
     86        wp_add_dashboard_widget( 'dashboard_wp_newsfeed', __( 'WordPress News' ), 'wp_dashboard_newsfeed' );
    9987
    100         // Secondary Feed (Planet) Widget
    101         if ( !isset( $widget_options['dashboard_secondary'] ) ) {
    102                 $update = true;
    103                 $widget_options['dashboard_secondary'] = array(
    104                         'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
    105                         'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
    106                         'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
    107                         'items' => 5,
    108                         'show_summary' => 0,
    109                         'show_author' => 0,
    110                         'show_date' => 0,
    111                 );
    112         }
    113         wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
    114 
    11588        // Hook to register new widgets
    11689        // Filter widget order
    11790        if ( is_network_admin() ) {
     
    860833        wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) );
    861834}
    862835
    863 function wp_dashboard_primary() {
    864         wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' );
    865 }
    866 
    867 function wp_dashboard_primary_control() {
    868         wp_dashboard_rss_control( 'dashboard_primary' );
    869 }
    870 
    871836/**
    872837 * {@internal Missing Short Description}}
    873838 *
     
    882847        echo "</div>";
    883848}
    884849
    885 function wp_dashboard_secondary() {
    886         wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );
     850/**
     851 * Display (cached) dashboard widget for WordPress news and Planet WordPress
     852 *
     853 * @since 3.6.0
     854 */
     855function wp_dashboard_newsfeed() {
     856        wp_dashboard_cached_rss_widget(
     857                'wp_dashboard_newsfeed',
     858                'wp_dashboard_newsfeed_output',
     859                array(
     860                     'http://wordpress.org/news/feed/',
     861                     'http://planet.wordpress.org/feed/'
     862                )
     863        );
    887864}
    888865
    889 function wp_dashboard_secondary_control() {
    890         wp_dashboard_rss_control( 'dashboard_secondary' );
     866/**
     867 * Display options for the newsfeed widget.
     868 *
     869 * @since 3.6.0
     870 */
     871function wp_dashboard_newsfeed_control() {
     872
    891873}
    892874
    893875/**
    894  * Display secondary dashboard RSS widget feed.
     876 * Actual (uncached) output of the newsfeed widget.
    895877 *
    896  * @since 2.5.0
    897  *
    898  * @return unknown
     878 * @since 3.6.0
    899879 */
    900 function wp_dashboard_secondary_output() {
    901         $widgets = get_option( 'dashboard_widget_options' );
    902         @extract( @$widgets['dashboard_secondary'], EXTR_SKIP );
    903         $rss = @fetch_feed( $url );
     880function wp_dashboard_newsfeed_output() {
     881        $official = fetch_feed( 'http://wordpress.org/news/feed/' );
     882        $planet = fetch_feed( 'http://planet.wordpress.org/feed/' );
    904883
    905         if ( is_wp_error($rss) ) {
    906                 if ( is_admin() || current_user_can('manage_options') ) {
    907                         echo '<div class="rss-widget"><p>';
    908                         printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
    909                         echo '</p></div>';
     884        foreach( array( 'official' => __( 'WordPress.org Official Blog' ), 'planet' => __( 'Planet WordPress' ) ) as $feed => $label ) {
     885                if ( is_wp_error( $$feed ) || ! $$feed->get_item_quantity() )
     886                        continue;
     887                switch( $feed ) {
     888                        case 'official':
     889                                $items = $$feed->get_items( 0, 2 );
     890                                break;
     891                        default:
     892                                $items = $$feed->get_items( 0, 5 );
    910893                }
    911         } elseif ( !$rss->get_item_quantity() ) {
    912                 $rss->__destruct();
    913                 unset($rss);
    914                 return false;
    915         } else {
    916                 echo '<div class="rss-widget">';
    917                 wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
    918                 echo '</div>';
    919                 $rss->__destruct();
    920                 unset($rss);
     894
     895                echo "<h4>";
     896
     897                if ( 'official' == $feed ) {
     898                        echo '<span class="wp-official"></span>';
     899                }
     900
     901                echo "$label</h4>";
     902                echo "<ul>";
     903
     904                foreach( $items as $item ) {
     905                        $link = $item->get_link();
     906                        $title = $item->get_title();
     907                        $description = $item->get_description();
     908                        $date = 'official' == $feed ? $item->get_date( 'U' ) : '';
     909
     910                        // Filter title
     911                        $title = esc_attr( strip_tags( $title ) );
     912                        if ( empty( $title ) ) {
     913                                $title = __( 'Untitled' );
     914                        }
     915
     916                        // Filter description
     917                        $description = str_replace( array( "\n", "\r" ), ' ', esc_attr( strip_tags( @html_entity_decode( $description, ENT_QUOTES, get_option( 'blog_charset' ) ) ) ) );
     918                        $description = wp_html_excerpt( $description, 360 );
     919
     920                        // Append ellipsis. Change existing [...] to [&hellip;].
     921                        if ( '[...]' == substr( $description, -5 ) ) {
     922                                $description = substr( $description, 0, -5 ) . '[&hellip;]';
     923                        } elseif ( '[&hellip;]' != substr( $description, -10 ) ) {
     924                                $description .= ' [&hellip;]';
     925                        }
     926                        $description = esc_html( $description );
     927
     928                        // Filter summary
     929                        if ( 'official' == $feed ) {
     930                                $summary = "<div class='rssSummary'>$description</div>";
     931                        } else {
     932                                $summary = '';
     933                        }
     934
     935                        // Filter date
     936                        if ( '' !== $date ) {
     937                                $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
     938                        }
     939
     940                        if ( '' === $link ) {
     941                                echo "<li>$title{$date}{$summary}</li>";
     942                        } else {
     943                                echo "<li><a class='rsswidget' href='$link' title='$description'>$title</a>{$date}{$summary}</li>";
     944                        }
     945                }
     946
     947                echo "</ul>";
     948
     949                $$feed->__destruct();
     950                unset( $$feed );
    921951        }
    922952}
    923953
  • wp-admin/js/dashboard.js

     
    3030        // These widgets are sometimes populated via ajax
    3131        ajaxWidgets = [
    3232                'dashboard_incoming_links',
    33                 'dashboard_primary',
    34                 'dashboard_secondary',
    35                 'dashboard_plugins'
     33                'dashboard_plugins',
     34                'dashboard_wp_newsfeed'
    3635        ];
    3736
    3837        ajaxPopulateWidgets = function(el) {