Changes from trunk/wp-admin/includes/dashboard.php at r18314 to branches/3.1/wp-admin/includes/dashboard.php at r17557
- File:
-
- 1 edited
-
branches/3.1/wp-admin/includes/dashboard.php (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-admin/includes/dashboard.php
r18314 r17557 1 1 <?php 2 2 /** 3 * WordPress Dashboard Widget Administration ScreenAPI3 * WordPress Dashboard Widget Administration Panel API 4 4 * 5 5 * @package WordPress … … 25 25 26 26 /* Register Widgets and Controls */ 27 28 $response = wp_check_browser_version();29 30 if ( $response && $response['upgrade'] ) {31 add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );32 if ( $response['insecure'] )33 wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );34 else35 wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );36 }37 27 38 28 // Right Now … … 172 162 if ( in_array($widget_id, $side_widgets) ) 173 163 $location = 'side'; 174 175 $priority = 'core'; 176 if ( 'dashboard_browser_nag' === $widget_id ) 177 $priority = 'high'; 178 179 add_meta_box( $widget_id, $widget_name, $callback, $screen->id, $location, $priority ); 164 add_meta_box( $widget_id, $widget_name , $callback, $screen->id, $location, 'core' ); 180 165 } 181 166 … … 400 385 401 386 $switch_themes = $ct->title; 402 if ( current_user_can( 'switch_themes') ) 387 if ( current_user_can( 'switch_themes') ) { 388 echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>'; 403 389 $switch_themes = '<a href="themes.php">' . $switch_themes . '</a>'; 390 } 404 391 if ( current_user_can( 'edit_theme_options' ) ) { 405 392 printf(_n('Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $switch_themes, $num); … … 408 395 } 409 396 } else { 410 if ( current_user_can( 'switch_themes' ) ) 397 if ( current_user_can( 'switch_themes' ) ) { 398 echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>'; 411 399 printf( __('Theme <span class="b"><a href="themes.php">%1$s</a></span>'), $ct->title ); 412 else400 } else { 413 401 printf( __('Theme <span class="b">%1$s</span>'), $ct->title ); 402 } 414 403 } 415 404 echo '</p>'; 416 417 // Check if search engines are blocked.418 if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ) {419 $title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') );420 $content = apply_filters('privacy_on_link_text', __('Search Engines Blocked') );421 422 echo "<p><a href='options-privacy.php' title='$title'>$content</a></p>";423 }424 405 425 406 update_right_now_message(); … … 477 458 } 478 459 479 function wp_dashboard_quick_press () {460 function wp_dashboard_quick_press_output() { 480 461 global $post_ID; 481 462 … … 558 539 <span id="publishing-action"> 559 540 <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" /> 560 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt=""/>541 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" /> 561 542 </span> 562 543 <br class="clear" /> … … 568 549 if ( $drafts ) 569 550 wp_dashboard_recent_drafts( $drafts ); 551 } 552 553 function wp_dashboard_quick_press() { 554 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 570 555 } 571 556 … … 597 582 <li><?php echo join( "</li>\n<li>", $list ); ?></li> 598 583 </ul> 599 <p class="textright"><a href="edit.php?post_status=draft" ><?php _e('View all'); ?></a></p>584 <p class="textright"><a href="edit.php?post_status=draft" class="button"><?php _e('View all'); ?></a></p> 600 585 <?php 601 586 } else { … … 650 635 <?php 651 636 if ( current_user_can('edit_posts') ) { ?> 652 < ?php _get_list_table('WP_Comments_List_Table')->views(); ?>637 <p class="textright"><a href="edit-comments.php" class="button"><?php _e('View all'); ?></a></p> 653 638 <?php } 654 639 … … 783 768 784 769 function wp_dashboard_incoming_links() { 785 wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' );770 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 786 771 } 787 772 … … 871 856 872 857 function wp_dashboard_primary() { 873 wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' );858 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 … … 893 878 894 879 function wp_dashboard_secondary() { 895 wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );880 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 896 881 } 897 882 … … 932 917 933 918 function wp_dashboard_plugins() { 934 wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array( 935 'http://wordpress.org/extend/plugins/rss/browse/popular/', 936 'http://wordpress.org/extend/plugins/rss/browse/new/', 937 'http://wordpress.org/extend/plugins/rss/browse/updated/' 938 ) ); 919 echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 939 920 } 940 921 … … 1036 1017 */ 1037 1018 function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { 1038 $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>'; 1039 $doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); 1019 $loading = '<p class="widget-loading">' . __( 'Loading…' ) . '</p>'; 1040 1020 1041 1021 if ( empty($check_urls) ) { 1042 1022 $widgets = get_option( 'dashboard_widget_options' ); 1043 if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax) {1023 if ( empty($widgets[$widget_id]['url']) ) { 1044 1024 echo $loading; 1045 1025 return false; … … 1048 1028 } 1049 1029 1050 $cache_key = 'dash_' . md5( $widget_id ); 1051 if ( false !== ( $output = get_transient( $cache_key ) ) ) { 1052 echo $output; 1053 return true; 1054 } 1055 1056 if ( ! $doing_ajax ) { 1057 echo $loading; 1058 return false; 1030 include_once ABSPATH . WPINC . '/class-feed.php'; 1031 foreach ( $check_urls as $check_url ) { 1032 $cache = new WP_Feed_Cache_Transient('', md5($check_url), ''); 1033 if ( ! $cache->load() ) { 1034 echo $loading; 1035 return false; 1036 } 1059 1037 } 1060 1038 … … 1062 1040 $args = array_slice( func_get_args(), 2 ); 1063 1041 array_unshift( $args, $widget_id ); 1064 ob_start();1065 1042 call_user_func_array( $callback, $args ); 1066 set_transient( $cache_key, ob_get_flush(), 43200); // Default lifetime in cache of 12 hours (same as the feeds)1067 1043 } 1068 1044 … … 1124 1100 } 1125 1101 update_option( 'dashboard_widget_options', $widget_options ); 1126 $cache_key = 'dash_' . md5( $widget_id );1127 delete_transient( $cache_key );1128 1102 } 1129 1103 … … 1133 1107 // Display File upload quota on dashboard 1134 1108 function wp_dashboard_quota() { 1135 if ( !is_multisite() || !current_user_can(' upload_files') || get_site_option( 'upload_space_check_disabled' ) )1109 if ( !is_multisite() || !current_user_can('edit_posts') || get_site_option( 'upload_space_check_disabled' ) ) 1136 1110 return true; 1137 1111 … … 1143 1117 else 1144 1118 $percentused = ( $used / $quota ) * 100; 1145 $used_color = ( $percentused >= 70 ) ? ' spam' : '';1119 $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam'; 1146 1120 $used = round( $used, 2 ); 1147 1121 $percentused = number_format( $percentused ); … … 1161 1135 <tr class="first"> 1162 1136 <td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td> 1163 <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>1137 <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td> 1164 1138 </tr> 1165 1139 </table> … … 1170 1144 add_action( 'activity_box_end', 'wp_dashboard_quota' ); 1171 1145 1172 // Display Browser Nag Meta Box1173 function wp_dashboard_browser_nag() {1174 $notice = '';1175 $response = wp_check_browser_version();1176 1177 if ( $response ) {1178 if ( $response['insecure'] ) {1179 $msg = sprintf( __( "It looks like you're using an insecure version of <a href='%s'>%s</a>. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );1180 } else {1181 $msg = sprintf( __( "It looks like you're using an old version of <a href='%s'>%s</a>. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );1182 }1183 1184 $browser_nag_class = '';1185 if ( !empty( $response['img_src'] ) ) {1186 $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src'];1187 1188 $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';1189 $browser_nag_class = ' has-browser-icon';1190 }1191 $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";1192 $notice .= sprintf( __( '<p><a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a></p>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), 'http://browsehappy.com/' );1193 $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>';1194 $notice .= '<div class="clear"></div>';1195 }1196 1197 echo apply_filters( 'browse-happy-notice', $notice, $response );1198 }1199 1200 function dashboard_browser_nag_class( $classes ) {1201 $response = wp_check_browser_version();1202 1203 if ( $response && $response['insecure'] )1204 $classes[] = 'browser-insecure';1205 1206 return $classes;1207 }1208 1209 /**1210 * Check if the user needs a browser update1211 *1212 * @since 3.2.01213 *1214 * @return array|bool False on failure, array of browser data on success.1215 */1216 function wp_check_browser_version() {1217 if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )1218 return false;1219 1220 $key = md5( $_SERVER['HTTP_USER_AGENT'] );1221 1222 if ( false === ($response = get_site_transient('browser_' . $key) ) ) {1223 global $wp_version;1224 1225 $options = array(1226 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),1227 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )1228 );1229 1230 $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.0/', $options );1231 1232 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )1233 return false;1234 1235 /**1236 * Response should be an array with:1237 * 'name' - string - A user friendly browser name1238 * 'version' - string - The most recent version of the browser1239 * 'current_version' - string - The version of the browser the user is using1240 * 'upgrade' - boolean - Whether the browser needs an upgrade1241 * 'insecure' - boolean - Whether the browser is deemed insecure1242 * 'upgrade_url' - string - The url to visit to upgrade1243 * 'img_src' - string - An image representing the browser1244 * 'img_src_ssl' - string - An image (over SSL) representing the browser1245 */1246 $response = unserialize( wp_remote_retrieve_body( $response ) );1247 1248 if ( ! $response )1249 return false;1250 1251 set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week1252 }1253 1254 return $response;1255 }1256 1257 1146 /** 1258 1147 * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
Note: See TracChangeset
for help on using the changeset viewer.