@@ -37,6 +37,13 @@ class WordPress extends Adapter {
3737 */
3838 protected $ news_feed = 'https://wordpress.org/news/feed/ ' ;
3939
40+ /**
41+ * Planet WordPress feed URL.
42+ *
43+ * @var string
44+ */
45+ protected $ planet_feed = 'https://planet.wordpress.org/feed/ ' ;
46+
4047 /**
4148 * Cached dashboard RSS widgets.
4249 *
@@ -57,6 +64,11 @@ public function get_channels( $channels, $user_id ) { // phpcs:ignore Generic.Co
5764 'name ' => \__ ( 'WordPress Events and News ' , 'microsub ' ),
5865 );
5966
67+ $ channels [] = array (
68+ 'uid ' => 'wp-planet ' ,
69+ 'name ' => \__ ( 'Planet WordPress ' , 'microsub ' ),
70+ );
71+
6072 foreach ( $ this ->get_rss_widgets () as $ widget ) {
6173 $ channels [] = array (
6274 'uid ' => 'wp-rss- ' . $ widget ['id ' ],
@@ -86,6 +98,11 @@ public function get_timeline( $result, $channel, $args ) {
8698 return $ result ;
8799 }
88100
101+ if ( 'wp-planet ' === $ channel ) {
102+ $ result ['items ' ] = \array_merge ( $ result ['items ' ], $ this ->get_feed_items ( $ this ->planet_feed , $ limit , $ channel ) );
103+ return $ result ;
104+ }
105+
89106 if ( 'wp-dashboard ' === $ channel ) {
90107 $ news_items = $ this ->get_news_items ( $ limit );
91108 $ events = $ this ->get_events_items ( $ limit );
@@ -412,21 +429,36 @@ protected function get_rss_widgets() {
412429 $ this ->rss_widgets = array ();
413430 $ options = \get_option ( 'dashboard_widget_options ' , array () );
414431
432+ if ( ! \is_array ( $ options ) ) {
433+ return $ this ->rss_widgets ;
434+ }
435+
415436 // Derive RSS widgets directly from stored options (title/url) even in REST context.
416- if ( ! empty ( $ options ) ) {
417- foreach ( $ options as $ widget_id => $ settings ) {
418- if ( empty ( $ settings ['url ' ] ) ) {
419- continue ;
420- }
421-
422- $ title = $ settings ['title ' ] ?? $ widget_id ;
423-
424- $ this ->rss_widgets [] = array (
425- 'id ' => $ widget_id ,
426- 'name ' => $ title ,
427- 'url ' => $ settings ['url ' ],
428- );
437+ foreach ( $ options as $ widget_id => $ settings ) {
438+ if ( ! \is_array ( $ settings ) ) {
439+ continue ;
429440 }
441+
442+ // Check for feed URL in common keys.
443+ $ url = null ;
444+ if ( ! empty ( $ settings ['url ' ] ) ) {
445+ $ url = $ settings ['url ' ];
446+ } elseif ( ! empty ( $ settings ['link ' ] ) && \filter_var ( $ settings ['link ' ], \FILTER_VALIDATE_URL ) ) {
447+ // 'link' is sometimes the feed URL in older widgets.
448+ $ url = $ settings ['link ' ];
449+ }
450+
451+ if ( ! $ url ) {
452+ continue ;
453+ }
454+
455+ $ title = ! empty ( $ settings ['title ' ] ) ? $ settings ['title ' ] : $ widget_id ;
456+
457+ $ this ->rss_widgets [] = array (
458+ 'id ' => $ widget_id ,
459+ 'name ' => $ title ,
460+ 'url ' => $ url ,
461+ );
430462 }
431463
432464 return $ this ->rss_widgets ;
0 commit comments