Make WordPress Core

Ticket #19239: 19239.4.refresh.diff

File 19239.4.refresh.diff, 11.2 KB (added by lessbloat, 12 years ago)
  • wp-admin/includes/ajax-actions.php

     
    209209                case 'dashboard_incoming_links' :
    210210                        wp_dashboard_incoming_links();
    211211                        break;
    212                 case 'dashboard_primary' :
    213                         wp_dashboard_primary();
     212                case 'dashboard_rss' :
     213                        wp_dashboard_rss();
    214214                        break;
    215                 case 'dashboard_secondary' :
    216                         wp_dashboard_secondary();
    217                         break;
    218215                case 'dashboard_plugins' :
    219216                        wp_dashboard_plugins();
    220217                        break;
  • wp-admin/includes/dashboard.php

     
    8181        // Recent Drafts
    8282        if ( is_blog_admin() && current_user_can('edit_posts') )
    8383                wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
     84               
     85        // RSS Widget
     86        wp_add_dashboard_widget( 'dashboard_rss', __( 'News' ), 'wp_dashboard_rss', 'wp_dashboard_rss_feed_control' );
    8487
    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' );
    99 
    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() ) {
     
    163136        }
    164137
    165138        if ( is_blog_admin () )
    166                 $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
     139                $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts','dashboard_rss');
    167140        else if (is_network_admin() )
    168                 $side_widgets = array('dashboard_primary', 'dashboard_secondary');
     141                $side_widgets = array('dashboard_rss');
    169142        else
    170143                $side_widgets = array();
    171144
     
    856829        unset($rss);
    857830}
    858831
     832function wp_dashboard_rss_feed_control() {
     833        wp_dashboard_rss_control( 'dashboard_rss' );
     834}
     835
    859836function wp_dashboard_incoming_links_control() {
    860837        wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) );
    861838}
    862839
    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 
    871840/**
    872841 * Display primary dashboard RSS widget feed.
    873842 *
     
    875844 *
    876845 * @param string $widget_id
    877846 */
    878 function wp_dashboard_rss_output( $widget_id ) {
     847function wp_dashboard_rss_output() {
    879848        $widgets = get_option( 'dashboard_widget_options' );
    880         echo '<div class="rss-widget">';
    881         wp_widget_rss_output( $widgets[$widget_id] );
    882         echo "</div>";
    883 }
    884 
    885 function wp_dashboard_secondary() {
    886         wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );
    887 }
    888 
    889 function wp_dashboard_secondary_control() {
    890         wp_dashboard_rss_control( 'dashboard_secondary' );
    891 }
    892 
    893 /**
    894  * Display secondary dashboard RSS widget feed.
    895  *
    896  * @since 2.5.0
    897  *
    898  * @return unknown
    899  */
    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 );
    904 
    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>';
    910                 }
    911         } elseif ( !$rss->get_item_quantity() ) {
    912                 $rss->__destruct();
    913                 unset($rss);
    914                 return false;
    915         } else {
     849       
     850        foreach( $widgets['dashboard_rss'] as $feed ) {
    916851                echo '<div class="rss-widget">';
    917                 wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
    918                 echo '</div>';
    919                 $rss->__destruct();
    920                 unset($rss);
     852                if ( isset( $feed['title'] ) )
     853                        echo '<h4>' . $feed['title'] . '</h4>';
     854                wp_widget_rss_output( $feed['url'], $feed );
     855                echo "</div>";
    921856        }
    922857}
    923858
     859/**
     860 * Display (cached) dashboard RSS widget
     861 *
     862 * @since 3.7.0
     863 */
     864function wp_dashboard_rss() {
     865        $default_feeds = array(
     866                'news'   => array(
     867                        'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ),
     868                        'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
     869                        'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
     870                        'items' => 2,
     871                        'show_summary' => 1,
     872                        'show_author' => 0,
     873                        'show_date' => 1,
     874                ),
     875                'planet' => array(
     876                        'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
     877                        'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
     878                        'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
     879                        'items' => 5,
     880                        'show_summary' => 0,
     881                        'show_author' => 0,
     882                        'show_date' => 0,
     883                )
     884        );
     885       
     886        $widget_options = get_option( 'dashboard_widget_options' );
     887       
     888        if ( !$widget_options || !is_array($widget_options) )
     889                $widget_options = array();
     890       
     891        if ( ! isset( $widget_options['dashboard_rss'] ) ) {
     892                $widget_options['dashboard_rss'] = $default_feeds;
     893                update_option( 'dashboard_widget_options', $widget_options );
     894        }
     895               
     896        foreach( $default_feeds as $key => $value ) {
     897                $default_urls[] = $value['url'];
     898        }
     899       
     900        wp_dashboard_cached_rss_widget( 'dashboard_rss', 'wp_dashboard_rss_output', $default_urls );
     901}
     902
    924903function wp_dashboard_plugins() {
    925904        wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array(
    926905                'http://wordpress.org/plugins/rss/browse/popular/',
     
    10891068        if ( !isset($widget_options[$widget_id]) )
    10901069                $widget_options[$widget_id] = array();
    10911070
    1092         $number = 1; // Hack to use wp_widget_rss_form()
    1093         $widget_options[$widget_id]['number'] = $number;
     1071        if ( isset( $widget_options[$widget_id]['url'] ) ) {
     1072                // Single feed
     1073                $widget_options[$widget_id]['number'] = 1;
     1074                wp_dashboard_rss_form_control( $widget_options[$widget_id], $form_inputs );
     1075        } else {
     1076                // Multiple feeds
     1077                foreach ( $widget_options[$widget_id] as $name => $options ) {
     1078                        $options['number'] = $name;
     1079                        wp_dashboard_rss_form_control( $options, $form_inputs );
     1080                        echo "<hr />";
     1081        }
     1082        }
    10941083
    1095         if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
    1096                 $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] );
    1097                 $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
    1098                 $widget_options[$widget_id]['number'] = $number;
    1099                 // title is optional. If black, fill it if possible
    1100                 if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
    1101                         $rss = fetch_feed($widget_options[$widget_id]['url']);
    1102                         if ( is_wp_error($rss) ) {
    1103                                 $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
    1104                         } else {
    1105                                 $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
    1106                                 $rss->__destruct();
    1107                                 unset($rss);
     1084        if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss']) ) {
     1085
     1086                if ( isset( $widget_options[$widget_id]['url'] ) ) {
     1087                        // Single feed
     1088                        $_POST['widget-rss'][1] = wp_unslash( $_POST['widget-rss'][1] );
     1089                        $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][1] );
     1090                } else {
     1091                        // Multiple feeds
     1092                        $_POST['widget-rss'] = wp_unslash( $_POST['widget-rss'] );
     1093                        foreach ( $widget_options[$widget_id] as $name => $options ) {
     1094                                $widget_options[$widget_id][$name] = wp_widget_rss_process( $_POST['widget-rss'][$name] );
    11081095                        }
    11091096                }
    11101097                update_option( 'dashboard_widget_options', $widget_options );
    11111098                $cache_key = 'dash_' . md5( $widget_id );
    11121099                delete_transient( $cache_key );
    11131100        }
     1101}
    11141102
    1115         wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
     1103function wp_dashboard_rss_form_control( $options, $form_inputs ) {
     1104        wp_widget_rss_form( $options, $form_inputs );
    11161105}
    11171106
    11181107/**
  • 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',
     33                'dashboard_rss',
    3534                'dashboard_plugins'
    3635        ];
    3736
  • wp-admin/css/ie-rtl.css

     
    9595}
    9696
    9797#dashboard_incoming_links ul li,
    98 #dashboard_secondary ul li,
    99 #dashboard_primary ul li,
    10098p.row-actions {
    10199        width: 100%;
    102100}
  • wp-admin/css/colors-fresh.css

     
    552552        border-color: #666;
    553553}
    554554
    555 #dashboard_secondary div.dashboard-widget-content ul li a {
    556         background-color: #f9f9f9;
    557 }
    558 
    559555input.readonly, textarea.readonly {
    560556        background-color: #ddd;
    561557}
  • wp-admin/css/wp-admin.css

     
    67866786        padding: 0;
    67876787}
    67886788
     6789#dashboard-widgets .rss-widget h4 {
     6790        border-bottom: 1px solid #eee;
     6791        color: #8f8f8f;
     6792        font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
     6793        font-size: 14px;
     6794        font-weight: normal;
     6795        margin: 13px 0 11px;
     6796        padding-bottom: 8px;
     6797}
     6798
     6799#dashboard_rss hr {
     6800        border: none;
     6801        border-top: 1px solid #eee;
     6802        margin: 13px 0;
     6803}
     6804
    67896805/* Right Now */
    67906806#dashboard_right_now p.sub,
    67916807#dashboard_right_now .table, #dashboard_right_now .versions {
  • wp-admin/css/colors-classic.css

     
    550550        border-color: #666;
    551551}
    552552
    553 #dashboard_secondary div.dashboard-widget-content ul li a {
    554         background-color: #f9f9f9;
    555 }
    556 
    557553input.readonly, textarea.readonly {
    558554        background-color: #ddd;
    559555}