| 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 | | |
| 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 | | |
| 871 | | /** |
| 872 | | * Display primary dashboard RSS widget feed. |
| 873 | | * |
| 874 | | * @since 2.5.0 |
| 875 | | * |
| 876 | | * @param string $widget_id |
| 877 | | */ |
| 878 | | function wp_dashboard_rss_output( $widget_id ) { |
| 879 | | $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 { |
| 916 | | echo '<div class="rss-widget">'; |
| 917 | | wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] ); |
| 918 | | echo '</div>'; |
| 919 | | $rss->__destruct(); |
| 920 | | unset($rss); |
| 921 | | } |
| 922 | | } |
| 923 | | |