| 1 | Index: wp-admin/css/wp-admin.css |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/css/wp-admin.css (revision 23284) |
|---|
| 4 | +++ wp-admin/css/wp-admin.css (working copy) |
|---|
| 5 | @@ -6517,6 +6517,23 @@ |
|---|
| 6 | word-wrap: break-word; |
|---|
| 7 | } |
|---|
| 8 | |
|---|
| 9 | +/* Newsfeed Widget */ |
|---|
| 10 | +#dashboard_wp_newsfeed .wp-official { |
|---|
| 11 | + height: 16px; |
|---|
| 12 | + width: 16px; |
|---|
| 13 | + margin-right: 8px; |
|---|
| 14 | + display: inline-block; |
|---|
| 15 | + background: url(../images/wp-logo-vs.png) no-repeat center center; |
|---|
| 16 | + position: relative; |
|---|
| 17 | + top: 3px; |
|---|
| 18 | +} |
|---|
| 19 | + |
|---|
| 20 | +#dashboard_wp_newsfeed h4 { |
|---|
| 21 | + font-weight: bold; |
|---|
| 22 | + padding-bottom: 0.5em; |
|---|
| 23 | + border-bottom: 1px solid #333; |
|---|
| 24 | +} |
|---|
| 25 | + |
|---|
| 26 | /* Browser Nag */ |
|---|
| 27 | #dashboard_browser_nag a.update-browser-link { |
|---|
| 28 | font-size: 1.2em; |
|---|
| 29 | @@ -8512,6 +8529,11 @@ |
|---|
| 30 | .customize-loading #customize-container { |
|---|
| 31 | background-image: url(../images/wpspin_light-2x.gif); |
|---|
| 32 | } |
|---|
| 33 | + |
|---|
| 34 | + #dashboard_wp_newsfeed .wp-official { |
|---|
| 35 | + background-image: url(../images/wp-logo-vs-2x.png); |
|---|
| 36 | + background-size: 16px 16px; |
|---|
| 37 | + } |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | /* =Localized CSS |
|---|
| 41 | Index: wp-admin/includes/ajax-actions.php |
|---|
| 42 | =================================================================== |
|---|
| 43 | --- wp-admin/includes/ajax-actions.php (revision 23284) |
|---|
| 44 | +++ wp-admin/includes/ajax-actions.php (working copy) |
|---|
| 45 | @@ -194,12 +194,9 @@ |
|---|
| 46 | case 'dashboard_incoming_links' : |
|---|
| 47 | wp_dashboard_incoming_links(); |
|---|
| 48 | break; |
|---|
| 49 | - case 'dashboard_primary' : |
|---|
| 50 | - wp_dashboard_primary(); |
|---|
| 51 | + case 'dashboard_wp_newsfeed': |
|---|
| 52 | + wp_dashboard_newsfeed(); |
|---|
| 53 | break; |
|---|
| 54 | - case 'dashboard_secondary' : |
|---|
| 55 | - wp_dashboard_secondary(); |
|---|
| 56 | - break; |
|---|
| 57 | case 'dashboard_plugins' : |
|---|
| 58 | wp_dashboard_plugins(); |
|---|
| 59 | break; |
|---|
| 60 | Index: wp-admin/includes/dashboard.php |
|---|
| 61 | =================================================================== |
|---|
| 62 | --- wp-admin/includes/dashboard.php (revision 23284) |
|---|
| 63 | +++ wp-admin/includes/dashboard.php (working copy) |
|---|
| 64 | @@ -82,36 +82,9 @@ |
|---|
| 65 | if ( is_blog_admin() && current_user_can('edit_posts') ) |
|---|
| 66 | wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' ); |
|---|
| 67 | |
|---|
| 68 | - // Primary feed (Dev Blog) Widget |
|---|
| 69 | - if ( !isset( $widget_options['dashboard_primary'] ) ) { |
|---|
| 70 | - $update = true; |
|---|
| 71 | - $widget_options['dashboard_primary'] = array( |
|---|
| 72 | - 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ), |
|---|
| 73 | - 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), |
|---|
| 74 | - 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), |
|---|
| 75 | - 'items' => 2, |
|---|
| 76 | - 'show_summary' => 1, |
|---|
| 77 | - 'show_author' => 0, |
|---|
| 78 | - 'show_date' => 1, |
|---|
| 79 | - ); |
|---|
| 80 | - } |
|---|
| 81 | - wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' ); |
|---|
| 82 | + // WordPress Feed Widget |
|---|
| 83 | + wp_add_dashboard_widget( 'dashboard_wp_newsfeed', __( 'WordPress News' ), 'wp_dashboard_newsfeed' ); |
|---|
| 84 | |
|---|
| 85 | - // Secondary Feed (Planet) Widget |
|---|
| 86 | - if ( !isset( $widget_options['dashboard_secondary'] ) ) { |
|---|
| 87 | - $update = true; |
|---|
| 88 | - $widget_options['dashboard_secondary'] = array( |
|---|
| 89 | - 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), |
|---|
| 90 | - 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), |
|---|
| 91 | - 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), |
|---|
| 92 | - 'items' => 5, |
|---|
| 93 | - 'show_summary' => 0, |
|---|
| 94 | - 'show_author' => 0, |
|---|
| 95 | - 'show_date' => 0, |
|---|
| 96 | - ); |
|---|
| 97 | - } |
|---|
| 98 | - wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' ); |
|---|
| 99 | - |
|---|
| 100 | // Hook to register new widgets |
|---|
| 101 | // Filter widget order |
|---|
| 102 | if ( is_network_admin() ) { |
|---|
| 103 | @@ -860,14 +833,6 @@ |
|---|
| 104 | wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) ); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | -function wp_dashboard_primary() { |
|---|
| 108 | - wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' ); |
|---|
| 109 | -} |
|---|
| 110 | - |
|---|
| 111 | -function wp_dashboard_primary_control() { |
|---|
| 112 | - wp_dashboard_rss_control( 'dashboard_primary' ); |
|---|
| 113 | -} |
|---|
| 114 | - |
|---|
| 115 | /** |
|---|
| 116 | * {@internal Missing Short Description}} |
|---|
| 117 | * |
|---|
| 118 | @@ -882,42 +847,107 @@ |
|---|
| 119 | echo "</div>"; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | -function wp_dashboard_secondary() { |
|---|
| 123 | - wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' ); |
|---|
| 124 | +/** |
|---|
| 125 | + * Display (cached) dashboard widget for WordPress news and Planet WordPress |
|---|
| 126 | + * |
|---|
| 127 | + * @since 3.6.0 |
|---|
| 128 | + */ |
|---|
| 129 | +function wp_dashboard_newsfeed() { |
|---|
| 130 | + wp_dashboard_cached_rss_widget( |
|---|
| 131 | + 'wp_dashboard_newsfeed', |
|---|
| 132 | + 'wp_dashboard_newsfeed_output', |
|---|
| 133 | + array( |
|---|
| 134 | + 'http://wordpress.org/news/feed/', |
|---|
| 135 | + 'http://planet.wordpress.org/feed/' |
|---|
| 136 | + ) |
|---|
| 137 | + ); |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | -function wp_dashboard_secondary_control() { |
|---|
| 141 | - wp_dashboard_rss_control( 'dashboard_secondary' ); |
|---|
| 142 | +/** |
|---|
| 143 | + * Display options for the newsfeed widget. |
|---|
| 144 | + * |
|---|
| 145 | + * @since 3.6.0 |
|---|
| 146 | + */ |
|---|
| 147 | +function wp_dashboard_newsfeed_control() { |
|---|
| 148 | + |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | /** |
|---|
| 152 | - * Display secondary dashboard RSS widget feed. |
|---|
| 153 | + * Actual (uncached) output of the newsfeed widget. |
|---|
| 154 | * |
|---|
| 155 | - * @since 2.5.0 |
|---|
| 156 | - * |
|---|
| 157 | - * @return unknown |
|---|
| 158 | + * @since 3.6.0 |
|---|
| 159 | */ |
|---|
| 160 | -function wp_dashboard_secondary_output() { |
|---|
| 161 | - $widgets = get_option( 'dashboard_widget_options' ); |
|---|
| 162 | - @extract( @$widgets['dashboard_secondary'], EXTR_SKIP ); |
|---|
| 163 | - $rss = @fetch_feed( $url ); |
|---|
| 164 | +function wp_dashboard_newsfeed_output() { |
|---|
| 165 | + $official = fetch_feed( 'http://wordpress.org/news/feed/' ); |
|---|
| 166 | + $planet = fetch_feed( 'http://planet.wordpress.org/feed/' ); |
|---|
| 167 | |
|---|
| 168 | - if ( is_wp_error($rss) ) { |
|---|
| 169 | - if ( is_admin() || current_user_can('manage_options') ) { |
|---|
| 170 | - echo '<div class="rss-widget"><p>'; |
|---|
| 171 | - printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message()); |
|---|
| 172 | - echo '</p></div>'; |
|---|
| 173 | + foreach( array( 'official' => __( 'WordPress.org Official Blog' ), 'planet' => __( 'Planet WordPress' ) ) as $feed => $label ) { |
|---|
| 174 | + if ( is_wp_error( $$feed ) || ! $$feed->get_item_quantity() ) |
|---|
| 175 | + continue; |
|---|
| 176 | + switch( $feed ) { |
|---|
| 177 | + case 'official': |
|---|
| 178 | + $items = $$feed->get_items( 0, 2 ); |
|---|
| 179 | + break; |
|---|
| 180 | + default: |
|---|
| 181 | + $items = $$feed->get_items( 0, 5 ); |
|---|
| 182 | } |
|---|
| 183 | - } elseif ( !$rss->get_item_quantity() ) { |
|---|
| 184 | - $rss->__destruct(); |
|---|
| 185 | - unset($rss); |
|---|
| 186 | - return false; |
|---|
| 187 | - } else { |
|---|
| 188 | - echo '<div class="rss-widget">'; |
|---|
| 189 | - wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] ); |
|---|
| 190 | - echo '</div>'; |
|---|
| 191 | - $rss->__destruct(); |
|---|
| 192 | - unset($rss); |
|---|
| 193 | + |
|---|
| 194 | + echo "<h4>"; |
|---|
| 195 | + |
|---|
| 196 | + if ( 'official' == $feed ) { |
|---|
| 197 | + echo '<span class="wp-official"></span>'; |
|---|
| 198 | + } |
|---|
| 199 | + |
|---|
| 200 | + echo "$label</h4>"; |
|---|
| 201 | + echo "<ul>"; |
|---|
| 202 | + |
|---|
| 203 | + foreach( $items as $item ) { |
|---|
| 204 | + $link = $item->get_link(); |
|---|
| 205 | + $title = $item->get_title(); |
|---|
| 206 | + $description = $item->get_description(); |
|---|
| 207 | + $date = 'official' == $feed ? $item->get_date( 'U' ) : ''; |
|---|
| 208 | + |
|---|
| 209 | + // Filter title |
|---|
| 210 | + $title = esc_attr( strip_tags( $title ) ); |
|---|
| 211 | + if ( empty( $title ) ) { |
|---|
| 212 | + $title = __( 'Untitled' ); |
|---|
| 213 | + } |
|---|
| 214 | + |
|---|
| 215 | + // Filter description |
|---|
| 216 | + $description = str_replace( array( "\n", "\r" ), ' ', esc_attr( strip_tags( @html_entity_decode( $description, ENT_QUOTES, get_option( 'blog_charset' ) ) ) ) ); |
|---|
| 217 | + $description = wp_html_excerpt( $description, 360 ); |
|---|
| 218 | + |
|---|
| 219 | + // Append ellipsis. Change existing [...] to […]. |
|---|
| 220 | + if ( '[...]' == substr( $description, -5 ) ) { |
|---|
| 221 | + $description = substr( $description, 0, -5 ) . '[…]'; |
|---|
| 222 | + } elseif ( '[…]' != substr( $description, -10 ) ) { |
|---|
| 223 | + $description .= ' […]'; |
|---|
| 224 | + } |
|---|
| 225 | + $description = esc_html( $description ); |
|---|
| 226 | + |
|---|
| 227 | + // Filter summary |
|---|
| 228 | + if ( 'official' == $feed ) { |
|---|
| 229 | + $summary = "<div class='rssSummary'>$description</div>"; |
|---|
| 230 | + } else { |
|---|
| 231 | + $summary = ''; |
|---|
| 232 | + } |
|---|
| 233 | + |
|---|
| 234 | + // Filter date |
|---|
| 235 | + if ( '' !== $date ) { |
|---|
| 236 | + $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>'; |
|---|
| 237 | + } |
|---|
| 238 | + |
|---|
| 239 | + if ( '' === $link ) { |
|---|
| 240 | + echo "<li>$title{$date}{$summary}</li>"; |
|---|
| 241 | + } else { |
|---|
| 242 | + echo "<li><a class='rsswidget' href='$link' title='$description'>$title</a>{$date}{$summary}</li>"; |
|---|
| 243 | + } |
|---|
| 244 | + } |
|---|
| 245 | + |
|---|
| 246 | + echo "</ul>"; |
|---|
| 247 | + |
|---|
| 248 | + $$feed->__destruct(); |
|---|
| 249 | + unset( $$feed ); |
|---|
| 250 | } |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | Index: wp-admin/js/dashboard.js |
|---|
| 254 | =================================================================== |
|---|
| 255 | --- wp-admin/js/dashboard.js (revision 23284) |
|---|
| 256 | +++ wp-admin/js/dashboard.js (working copy) |
|---|
| 257 | @@ -30,9 +30,8 @@ |
|---|
| 258 | // These widgets are sometimes populated via ajax |
|---|
| 259 | ajaxWidgets = [ |
|---|
| 260 | 'dashboard_incoming_links', |
|---|
| 261 | - 'dashboard_primary', |
|---|
| 262 | - 'dashboard_secondary', |
|---|
| 263 | - 'dashboard_plugins' |
|---|
| 264 | + 'dashboard_plugins', |
|---|
| 265 | + 'dashboard_wp_newsfeed' |
|---|
| 266 | ]; |
|---|
| 267 | |
|---|
| 268 | ajaxPopulateWidgets = function(el) { |
|---|