Ticket #19239: 19239.4.diff
File 19239.4.diff, 11.2 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
209 209 case 'dashboard_incoming_links' : 210 210 wp_dashboard_incoming_links(); 211 211 break; 212 case 'dashboard_ primary' :213 wp_dashboard_ primary();212 case 'dashboard_rss' : 213 wp_dashboard_rss(); 214 214 break; 215 case 'dashboard_secondary' :216 wp_dashboard_secondary();217 break;218 215 case 'dashboard_plugins' : 219 216 wp_dashboard_plugins(); 220 217 break; -
wp-admin/includes/dashboard.php
81 81 // Recent Drafts 82 82 if ( is_blog_admin() && current_user_can('edit_posts') ) 83 83 wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' ); 84 85 // RSS Widget 86 wp_add_dashboard_widget( 'dashboard_rss', __( 'News' ), 'wp_dashboard_rss', 'wp_dashboard_rss_feed_control' ); 84 87 85 // Primary feed (Dev Blog) Widget86 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) Widget101 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 115 88 // Hook to register new widgets 116 89 // Filter widget order 117 90 if ( is_network_admin() ) { … … 163 136 } 164 137 165 138 if ( is_blog_admin () ) 166 $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');139 $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts','dashboard_rss'); 167 140 else if (is_network_admin() ) 168 $side_widgets = array('dashboard_ primary', 'dashboard_secondary');141 $side_widgets = array('dashboard_rss'); 169 142 else 170 143 $side_widgets = array(); 171 144 … … 856 829 unset($rss); 857 830 } 858 831 832 function wp_dashboard_rss_feed_control() { 833 wp_dashboard_rss_control( 'dashboard_rss' ); 834 } 835 859 836 function wp_dashboard_incoming_links_control() { 860 837 wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) ); 861 838 } 862 839 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 840 /** 872 841 * Display primary dashboard RSS widget feed. 873 842 * … … 875 844 * 876 845 * @param string $widget_id 877 846 */ 878 function wp_dashboard_rss_output( $widget_id) {847 function wp_dashboard_rss_output() { 879 848 $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 { 849 850 foreach( $widgets['dashboard_rss'] as $feed ) { 916 851 echo '<div class="rss-widget">'; 917 wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );918 echo '</div>';919 $rss->__destruct();920 unset($rss);852 if ( isset( $feed['title'] ) ) 853 echo '<h4>' . $feed['title'] . '</h4>'; 854 wp_widget_rss_output( $feed['url'], $feed ); 855 echo "</div>"; 921 856 } 922 857 } 923 858 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 924 903 function wp_dashboard_plugins() { 925 904 wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array( 926 905 'http://wordpress.org/plugins/rss/browse/popular/', … … 1088 1067 1089 1068 if ( !isset($widget_options[$widget_id]) ) 1090 1069 $widget_options[$widget_id] = array(); 1070 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 } 1083 1084 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss']) ) { 1091 1085 1092 $number = 1; // Hack to use wp_widget_rss_form() 1093 $widget_options[$widget_id]['number'] = $number; 1094 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 // title is optional. If black, fill it if possible 1099 if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { 1100 $rss = fetch_feed($widget_options[$widget_id]['url']); 1101 if ( is_wp_error($rss) ) { 1102 $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); 1103 } else { 1104 $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); 1105 $rss->__destruct(); 1106 unset($rss); 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] ); 1107 1095 } 1108 1096 } 1109 1097 update_option( 'dashboard_widget_options', $widget_options ); 1110 1098 $cache_key = 'dash_' . md5( $widget_id ); 1111 1099 delete_transient( $cache_key ); 1112 1100 } 1101 } 1113 1102 1114 wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); 1103 function wp_dashboard_rss_form_control( $options, $form_inputs ) { 1104 wp_widget_rss_form( $options, $form_inputs ); 1115 1105 } 1116 1106 1117 1107 /** -
wp-admin/js/dashboard.js
30 30 // These widgets are sometimes populated via ajax 31 31 ajaxWidgets = [ 32 32 'dashboard_incoming_links', 33 'dashboard_primary', 34 'dashboard_secondary', 33 'dashboard_rss', 35 34 'dashboard_plugins' 36 35 ]; 37 36 -
wp-admin/css/ie-rtl.css
95 95 } 96 96 97 97 #dashboard_incoming_links ul li, 98 #dashboard_secondary ul li,99 #dashboard_primary ul li,100 98 p.row-actions { 101 99 width: 100%; 102 100 } -
wp-admin/css/colors-fresh.css
552 552 border-color: #666; 553 553 } 554 554 555 #dashboard_secondary div.dashboard-widget-content ul li a {556 background-color: #f9f9f9;557 }558 559 555 input.readonly, textarea.readonly { 560 556 background-color: #ddd; 561 557 } -
wp-admin/css/wp-admin.css
6786 6786 padding: 0; 6787 6787 } 6788 6788 6789 #dashboard-widgets .rss-widget h4 { 6790 border-bottom: 1px solid #eee; 6791 color: #8f8f8f; 6792 font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif; 6793 font-size: 14px; 6794 font-weight: normal; 6795 margin: 13px 0 11px; 6796 padding-bottom: 8px; 6797 } 6798 6799 #dashboard_rss hr { 6800 border: none; 6801 border-top: 1px solid #eee; 6802 margin: 13px 0; 6803 } 6804 6789 6805 /* Right Now */ 6790 6806 #dashboard_right_now p.sub, 6791 6807 #dashboard_right_now .table, #dashboard_right_now .versions { -
wp-admin/css/colors-classic.css
550 550 border-color: #666; 551 551 } 552 552 553 #dashboard_secondary div.dashboard-widget-content ul li a {554 background-color: #f9f9f9;555 }556 557 553 input.readonly, textarea.readonly { 558 554 background-color: #ddd; 559 555 }