| 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 | | |
| 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 ) { |
| | 859 | /** |
| | 860 | * Display (cached) dashboard RSS widget |
| | 861 | * |
| | 862 | * @since 3.7.0 |
| | 863 | */ |
| | 864 | function 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 | |
| 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 | } |
| 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] ); |