Index: /trunk/src/wp-admin/includes/dashboard.php =================================================================== --- /trunk/src/wp-admin/includes/dashboard.php (revision 50688) +++ /trunk/src/wp-admin/includes/dashboard.php (revision 50689) @@ -20,4 +20,5 @@ function wp_dashboard_setup() { global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; + $wp_dashboard_control_callbacks = array(); $screen = get_current_screen(); @@ -29,4 +30,5 @@ if ( $response && $response['upgrade'] ) { add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' ); + if ( $response['insecure'] ) { wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); @@ -38,6 +40,10 @@ // PHP Version. $response = wp_check_php_version(); - if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'update_php' ) ) { + + if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] + && current_user_can( 'update_php' ) + ) { add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' ); + wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' ); } @@ -175,6 +181,7 @@ */ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null, $context = 'normal', $priority = 'core' ) { + global $wp_dashboard_control_callbacks; + $screen = get_current_screen(); - global $wp_dashboard_control_callbacks; $private_callback_args = array( '__widget_basename' => $widget_name ); @@ -186,7 +193,8 @@ } - if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { + if ( $control_callback && is_callable( $control_callback ) && current_user_can( 'edit_dashboard' ) ) { $wp_dashboard_control_callbacks[ $widget_id ] = $control_callback; - if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { + + if ( isset( $_GET['edit'] ) && $widget_id === $_GET['edit'] ) { list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); $widget_name .= ' ' . __( 'Cancel' ) . ''; @@ -213,4 +221,5 @@ $context = 'normal'; } + if ( empty( $priority ) ) { $priority = 'core'; @@ -247,8 +256,8 @@ $columns = absint( $screen->get_columns() ); $columns_css = ''; + if ( $columns ) { $columns_css = " columns-$columns"; } - ?>
'; } @@ -657,5 +684,4 @@ if ( $comment->comment_post_ID > 0 ) { - $comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); $comment_post_url = get_the_permalink( $comment->comment_post_ID ); @@ -953,5 +979,6 @@ */ $query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args ); - $posts = new WP_Query( $query_args ); + + $posts = new WP_Query( $query_args ); if ( $posts->have_posts() ) { @@ -971,7 +998,8 @@ $time = get_the_time( 'U' ); - if ( gmdate( 'Y-m-d', $time ) == $today ) { + + if ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); - } elseif ( gmdate( 'Y-m-d', $time ) == $tomorrow ) { + } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { $relative = __( 'Tomorrow' ); } elseif ( gmdate( 'Y', $time ) !== $year ) { @@ -1026,4 +1054,5 @@ 'offset' => 0, ); + if ( ! current_user_can( 'edit_posts' ) ) { $comments_query['status'] = 'approve'; @@ -1034,13 +1063,17 @@ break; } + foreach ( $possible as $comment ) { if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) { continue; } + $comments[] = $comment; - if ( count( $comments ) == $total_items ) { + + if ( count( $comments ) === $total_items ) { break 2; } } + $comments_query['offset'] += $comments_query['number']; $comments_query['number'] = $total_items * 10; @@ -1110,8 +1143,10 @@ if ( empty( $check_urls ) ) { $widgets = get_option( 'dashboard_widget_options' ); + if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) { echo $loading; return false; } + $check_urls = array( $widgets[ $widget_id ]['url'] ); } @@ -1120,4 +1155,5 @@ $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); $output = get_transient( $cache_key ); + if ( false !== $output ) { echo $output; @@ -1157,5 +1193,8 @@ global $wp_dashboard_control_callbacks; - if ( is_scalar( $widget_control_id ) && $widget_control_id && isset( $wp_dashboard_control_callbacks[ $widget_control_id ] ) && is_callable( $wp_dashboard_control_callbacks[ $widget_control_id ] ) ) { + if ( is_scalar( $widget_control_id ) && $widget_control_id + && isset( $wp_dashboard_control_callbacks[ $widget_control_id ] ) + && is_callable( $wp_dashboard_control_callbacks[ $widget_control_id ] ) + ) { call_user_func( $wp_dashboard_control_callbacks[ $widget_control_id ], @@ -1182,4 +1221,5 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { $widget_options = get_option( 'dashboard_widget_options' ); + if ( ! $widget_options ) { $widget_options = array(); @@ -1210,5 +1250,7 @@ } } + update_option( 'dashboard_widget_options', $widget_options ); + $locale = get_user_locale(); $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); @@ -1555,5 +1597,7 @@ */ function wp_dashboard_quota() { - if ( ! is_multisite() || ! current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) { + if ( ! is_multisite() || ! current_user_can( 'upload_files' ) + || get_site_option( 'upload_space_check_disabled' ) + ) { return true; } @@ -1567,4 +1611,5 @@ $percentused = ( $used / $quota ) * 100; } + $used_class = ( $percentused >= 70 ) ? ' warning' : ''; $used = round( $used, 2 ); @@ -1704,4 +1749,5 @@ $response = get_site_transient( 'browser_' . $key ); + if ( false === $response ) { // Include an unmodified $wp_version. @@ -1720,5 +1766,5 @@ $response = wp_remote_post( $url, $options ); - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { + if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { return false; }