Ticket #16927: 16927.diff
File 16927.diff, 8.4 KB (added by , 14 years ago) |
---|
-
wp-admin/includes/dashboard.php
function wp_dashboard_recent_comments_control() { 767 767 } 768 768 769 769 function wp_dashboard_incoming_links() { 770 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 770 $widgets = get_option( 'dashboard_widget_options' ); 771 if ( $cache = wp_cache_get( 'incoming_links_output_' . md5( serialize( @$widgets['dashboard_incoming_links'] ) ), 'dashboard' ) ) { 772 echo $cache; 773 return; 774 } else { 775 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 776 } 771 777 } 772 778 773 779 /** … … function wp_dashboard_incoming_links() { 776 782 * @since 2.5.0 777 783 */ 778 784 function wp_dashboard_incoming_links_output() { 785 ob_start(); 779 786 $widgets = get_option( 'dashboard_widget_options' ); 780 787 @extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP ); 781 788 $rss = fetch_feed( $url ); … … function wp_dashboard_incoming_links_output() { 793 800 echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "</p>\n"; 794 801 $rss->__destruct(); 795 802 unset($rss); 796 return; 797 } 803 } else { 798 804 799 echo "<ul>\n";805 echo "<ul>\n"; 800 806 801 if ( !isset($items) )802 $items = 10;807 if ( !isset($items) ) 808 $items = 10; 803 809 804 foreach ( $rss->get_items(0, $items) as $item ) {805 $publisher = '';806 $site_link = '';807 $link = '';808 $content = '';809 $date = '';810 $link = esc_url( strip_tags( $item->get_link() ) );810 foreach ( $rss->get_items(0, $items) as $item ) { 811 $publisher = ''; 812 $site_link = ''; 813 $link = ''; 814 $content = ''; 815 $date = ''; 816 $link = esc_url( strip_tags( $item->get_link() ) ); 811 817 812 $author = $item->get_author();813 if ( $author ) {814 $site_link = esc_url( strip_tags( $author->get_link() ) );818 $author = $item->get_author(); 819 if ( $author ) { 820 $site_link = esc_url( strip_tags( $author->get_link() ) ); 815 821 816 if ( !$publisher = esc_html( strip_tags( $author->get_name() ) ) )817 $publisher = __( 'Somebody' );818 } else {819 $publisher = __( 'Somebody' );820 }821 if ( $site_link )822 $publisher = "<a href='$site_link'>$publisher</a>";823 else824 $publisher = "<strong>$publisher</strong>";822 if ( !$publisher = esc_html( strip_tags( $author->get_name() ) ) ) 823 $publisher = __( 'Somebody' ); 824 } else { 825 $publisher = __( 'Somebody' ); 826 } 827 if ( $site_link ) 828 $publisher = "<a href='$site_link'>$publisher</a>"; 829 else 830 $publisher = "<strong>$publisher</strong>"; 825 831 826 $content = $item->get_content();827 $content = wp_html_excerpt($content, 50) . ' ...';832 $content = $item->get_content(); 833 $content = wp_html_excerpt($content, 50) . ' ...'; 828 834 829 if ( $link ) 830 /* translators: incoming links feed, %1$s is other person, %3$s is content */ 831 $text = __( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"' ); 832 else 833 /* translators: incoming links feed, %1$s is other person, %3$s is content */ 834 $text = __( '%1$s linked here saying, "%3$s"' ); 835 836 if ( !empty($show_date) ) { 837 if ( !empty($show_author) || !empty($show_summary) ) 838 /* translators: incoming links feed, %4$s is the date */ 839 $text .= ' ' . __( 'on %4$s' ); 840 $date = esc_html( strip_tags( $item->get_date() ) ); 841 $date = strtotime( $date ); 842 $date = gmdate( get_option( 'date_format' ), $date ); 835 if ( $link ) 836 /* translators: incoming links feed, %1$s is other person, %3$s is content */ 837 $text = __( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"' ); 838 else 839 /* translators: incoming links feed, %1$s is other person, %3$s is content */ 840 $text = __( '%1$s linked here saying, "%3$s"' ); 841 842 if ( !empty($show_date) ) { 843 if ( !empty($show_author) || !empty($show_summary) ) 844 /* translators: incoming links feed, %4$s is the date */ 845 $text .= ' ' . __( 'on %4$s' ); 846 $date = esc_html( strip_tags( $item->get_date() ) ); 847 $date = strtotime( $date ); 848 $date = gmdate( get_option( 'date_format' ), $date ); 849 } 850 851 echo "\t<li>" . sprintf( $text, $publisher, $link, $content, $date ) . "</li>\n"; 843 852 } 844 853 845 echo "\t<li>" . sprintf( $text, $publisher, $link, $content, $date ) . "</li>\n"; 854 echo "</ul>\n"; 855 $rss->__destruct(); 856 unset($rss); 846 857 } 847 848 echo "</ul>\n"; 849 $rss->__destruct(); 850 unset($rss); 858 $cache = ob_get_flush(); 859 if ( $cache ) 860 wp_cache_set( 'incoming_links_output_' . md5( serialize( @$widgets['dashboard_incoming_links'] ) ), $cache, 'dashboard', 30*15 ); 851 861 } 852 862 853 863 function wp_dashboard_incoming_links_control() { … … function wp_dashboard_incoming_links_control() { 855 865 } 856 866 857 867 function wp_dashboard_primary() { 858 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 868 $widgets = get_option( 'dashboard_widget_options' ); 869 if ( $cache = wp_cache_get( 'primary_output_' . md5( serialize( @$widgets['dashboard_primary'] ) ), 'dashboard' ) ) { 870 echo $cache; 871 return; 872 } else { 873 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 874 } 859 875 } 860 876 861 877 function wp_dashboard_primary_control() { … … function wp_dashboard_primary_control() { 870 886 * @param string $widget_id 871 887 */ 872 888 function wp_dashboard_rss_output( $widget_id ) { 889 ob_start(); 873 890 $widgets = get_option( 'dashboard_widget_options' ); 874 891 echo '<div class="rss-widget">'; 875 892 wp_widget_rss_output( $widgets[$widget_id] ); 876 893 echo "</div>"; 894 $cache = ob_get_flush(); 895 if ( $cache ) 896 wp_cache_set( 'primary_output_' . md5( serialize( @$widgets['dashboard_primary'] ) ), $cache, 'dashboard', 30*15 ); 877 897 } 878 898 879 899 function wp_dashboard_secondary() { 880 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 900 $widgets = get_option( 'dashboard_widget_options' ); 901 if ( $cache = wp_cache_get( 'secondary_output_' . md5( serialize( @$widgets['dashboard_secondary'] ) ), 'dashboard' ) ) { 902 echo $cache; 903 return; 904 } else { 905 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 906 } 881 907 } 882 908 883 909 function wp_dashboard_secondary_control() { … … function wp_dashboard_secondary_control() { 892 918 * @return unknown 893 919 */ 894 920 function wp_dashboard_secondary_output() { 921 ob_start(); 895 922 $widgets = get_option( 'dashboard_widget_options' ); 896 923 @extract( @$widgets['dashboard_secondary'], EXTR_SKIP ); 897 924 $rss = @fetch_feed( $url ); 898 899 925 if ( is_wp_error($rss) ) { 900 926 if ( is_admin() || current_user_can('manage_options') ) { 901 927 echo '<div class="rss-widget"><p>'; … … function wp_dashboard_secondary_output() { 913 939 $rss->__destruct(); 914 940 unset($rss); 915 941 } 942 $cache = ob_get_flush(); 943 if ( $cache ) 944 wp_cache_set( 'secondary_output_' . md5( serialize( @$widgets['dashboard_secondary'] ) ), $cache, 'dashboard', 30*15 ); 916 945 } 917 946 918 947 function wp_dashboard_plugins() { 919 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 948 if ( $cache = wp_cache_get( 'plugins_output', 'dashboard' ) ) { 949 echo $cache; 950 return; 951 } else { 952 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 953 } 920 954 } 921 955 922 956 /** … … function wp_dashboard_plugins() { 925 959 * @since 2.5.0 926 960 */ 927 961 function wp_dashboard_plugins_output() { 962 ob_start(); 928 963 $popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' ); 929 964 $new = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' ); 930 965 $updated = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/updated/' ); … … function wp_dashboard_plugins_output() { 998 1033 $$feed->__destruct(); 999 1034 unset($$feed); 1000 1035 } 1036 $cache = ob_get_flush(); 1037 if ( $cache ) 1038 wp_cache_set( 'plugins_output', $cache, 'dashboard', 30*60 ); 1001 1039 } 1002 1040 1003 1041 /**