@@ -37,13 +37,6 @@ class WordPress extends Adapter {
3737 */
3838 protected $ news_feed = 'https://wordpress.org/news/feed/ ' ;
3939
40- /**
41- * Cached dashboard RSS widgets.
42- *
43- * @var array|null
44- */
45- protected $ rss_widgets = null ;
46-
4740 /**
4841 * Get list of channels.
4942 *
@@ -434,11 +427,7 @@ protected function fetch_events_via_api( $limit, $location ) {
434427 * @return array
435428 */
436429 protected function get_rss_widgets () {
437- if ( null !== $ this ->rss_widgets ) {
438- return $ this ->rss_widgets ;
439- }
440-
441- $ this ->rss_widgets = array ();
430+ $ widgets = array ();
442431
443432 /**
444433 * Filter to register dashboard RSS feeds with Microsub.
@@ -452,7 +441,7 @@ protected function get_rss_widgets() {
452441 if ( \is_array ( $ plugin_feeds ) ) {
453442 foreach ( $ plugin_feeds as $ feed ) {
454443 if ( ! empty ( $ feed ['id ' ] ) && ! empty ( $ feed ['url ' ] ) ) {
455- $ this -> rss_widgets [] = array (
444+ $ widgets [] = array (
456445 'id ' => $ feed ['id ' ],
457446 'name ' => ! empty ( $ feed ['name ' ] ) ? $ feed ['name ' ] : $ feed ['id ' ],
458447 'url ' => $ feed ['url ' ],
@@ -464,38 +453,36 @@ protected function get_rss_widgets() {
464453 // Also check dashboard_widget_options for user-added RSS widgets.
465454 $ options = \get_option ( 'dashboard_widget_options ' , array () );
466455
467- if ( ! \is_array ( $ options ) ) {
468- return $ this ->rss_widgets ;
469- }
470-
471- foreach ( $ options as $ widget_id => $ settings ) {
472- if ( ! \is_array ( $ settings ) ) {
473- continue ;
474- }
456+ if ( \is_array ( $ options ) ) {
457+ foreach ( $ options as $ widget_id => $ settings ) {
458+ if ( ! \is_array ( $ settings ) ) {
459+ continue ;
460+ }
475461
476- // Check for feed URL in common keys.
477- $ url = null ;
478- if ( ! empty ( $ settings ['url ' ] ) ) {
479- $ url = $ settings ['url ' ];
480- } elseif ( ! empty ( $ settings ['link ' ] ) && \filter_var ( $ settings ['link ' ], \FILTER_VALIDATE_URL ) ) {
481- // 'link' is sometimes the feed URL in older widgets.
482- $ url = $ settings ['link ' ];
483- }
462+ // Check for feed URL in common keys.
463+ $ url = null ;
464+ if ( ! empty ( $ settings ['url ' ] ) ) {
465+ $ url = $ settings ['url ' ];
466+ } elseif ( ! empty ( $ settings ['link ' ] ) && \filter_var ( $ settings ['link ' ], \FILTER_VALIDATE_URL ) ) {
467+ // 'link' is sometimes the feed URL in older widgets.
468+ $ url = $ settings ['link ' ];
469+ }
484470
485- if ( ! $ url ) {
486- continue ;
487- }
471+ if ( ! $ url ) {
472+ continue ;
473+ }
488474
489- $ title = ! empty ( $ settings ['title ' ] ) ? $ settings ['title ' ] : $ widget_id ;
475+ $ title = ! empty ( $ settings ['title ' ] ) ? $ settings ['title ' ] : $ widget_id ;
490476
491- $ this ->rss_widgets [] = array (
492- 'id ' => $ widget_id ,
493- 'name ' => $ title ,
494- 'url ' => $ url ,
495- );
477+ $ widgets [] = array (
478+ 'id ' => $ widget_id ,
479+ 'name ' => $ title ,
480+ 'url ' => $ url ,
481+ );
482+ }
496483 }
497484
498- return $ this -> rss_widgets ;
485+ return $ widgets ;
499486 }
500487
501488 /**
0 commit comments