X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/ae01624bdce6b71c47e08e8a0287de58284a6b73..refs/tags/wordpress-3.3.1-scripts:/wp-admin/includes/dashboard.php diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 2b10928b..008a4fdd 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -1,6 +1,6 @@ id, $location, 'core' ); + + $priority = 'core'; + if ( 'dashboard_browser_nag' === $widget_id ) + $priority = 'high'; + + add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority ); } function _wp_dashboard_control_callback( $dashboard, $meta_box ) { @@ -185,33 +200,33 @@ function wp_dashboard() { $hide2 = $hide3 = $hide4 = ''; switch ( $screen_layout_columns ) { case 4: - $width = 'width:24.5%;'; + $width = 'width:25%;'; break; case 3: - $width = 'width:32.67%;'; + $width = 'width:33.333333%;'; $hide4 = 'display:none;'; break; case 2: - $width = 'width:49%;'; + $width = 'width:50%;'; $hide3 = $hide4 = 'display:none;'; break; default: - $width = 'width:98%;'; + $width = 'width:100%;'; $hide2 = $hide3 = $hide4 = 'display:none;'; } ?>
@@ -372,11 +387,15 @@ function wp_dashboard_right_now() { $ct = current_theme_info(); echo "\n\t"; - if ( !empty($wp_registered_sidebars) ) { + + if ( empty( $ct->stylesheet_dir ) ) { + if ( ! is_multisite() || is_super_admin() ) + echo '' . __('Change Theme') . ''; + if ( current_user_can( 'switch_themes') ) $switch_themes = '' . $switch_themes . ''; - } if ( current_user_can( 'edit_theme_options' ) ) { printf(_n('Theme %1$s with %2$s Widget', 'Theme %1$s with %2$s Widgets', $num_widgets), $switch_themes, $num); } else { printf(_n('Theme %1$s with %2$s Widget', 'Theme %1$s with %2$s Widgets', $num_widgets), $switch_themes, $num); } } else { - if ( current_user_can( 'switch_themes' ) ) { - echo '' . __('Change Theme') . ''; + if ( current_user_can( 'switch_themes' ) ) printf( __('Theme %1$s'), $ct->title ); - } else { + else printf( __('Theme %1$s'), $ct->title ); - } } echo '
'; + // Check if search engines are blocked. + if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ) { + $title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') ); + $content = apply_filters('privacy_on_link_text', __('Search Engines Blocked') ); + + echo " '; + } elseif ( ! empty($wp_registered_sidebars) ) { $sidebars_widgets = wp_get_sidebars_widgets(); $num_widgets = 0; foreach ( (array) $sidebars_widgets as $k => $v ) { - if ( 'wp_inactive_widgets' == $k ) + if ( 'wp_inactive_widgets' == $k || 'orphaned_widgets' == substr( $k, 0, 16 ) ) continue; if ( is_array($v) ) $num_widgets = $num_widgets + count($v); @@ -384,25 +403,29 @@ function wp_dashboard_right_now() { $num = number_format_i18n( $num_widgets ); $switch_themes = $ct->title; - if ( current_user_can( 'switch_themes') ) { - echo '"; + } + update_right_now_message(); echo "\n\t".'{$msg}
"; + $notice .= '' . sprintf( __( 'Update %2$s or learn how to browse happy' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), 'http://browsehappy.com/' ) . '
'; + $notice .= ' '; + $notice .= ''; + } + + echo apply_filters( 'browse-happy-notice', $notice, $response ); +} + +function dashboard_browser_nag_class( $classes ) { + $response = wp_check_browser_version(); + + if ( $response && $response['insecure'] ) + $classes[] = 'browser-insecure'; + + return $classes; +} + +/** + * Check if the user needs a browser update + * + * @since 3.2.0 + * + * @return array|bool False on failure, array of browser data on success. + */ +function wp_check_browser_version() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) + return false; + + $key = md5( $_SERVER['HTTP_USER_AGENT'] ); + + if ( false === ($response = get_site_transient('browser_' . $key) ) ) { + global $wp_version; + + $options = array( + 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), + 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) + ); + + $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.0/', $options ); + + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) + return false; + + /** + * Response should be an array with: + * 'name' - string - A user friendly browser name + * 'version' - string - The most recent version of the browser + * 'current_version' - string - The version of the browser the user is using + * 'upgrade' - boolean - Whether the browser needs an upgrade + * 'insecure' - boolean - Whether the browser is deemed insecure + * 'upgrade_url' - string - The url to visit to upgrade + * 'img_src' - string - An image representing the browser + * 'img_src_ssl' - string - An image (over SSL) representing the browser + */ + $response = unserialize( wp_remote_retrieve_body( $response ) ); + + if ( ! $response ) + return false; + + set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week + } + + return $response; +} + /** * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS). */ function wp_dashboard_empty() {} +/** + * Displays a welcome panel to introduce users to WordPress. + * + * @since 3.3 + */ +function wp_welcome_panel() { + global $wp_version; + + if ( ! current_user_can( 'edit_theme_options' ) ) + return; + + $classes = 'welcome-panel'; + + $option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); + // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner + $hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) ); + if ( $hide ) + $classes .= ' hidden'; + + list( $display_version ) = explode( '-', $wp_version ); + ?> +First Steps with WordPress. If you’d rather dive right in, here are a few things most people do first when they set up a new WordPress site. If you need help, use the Help tabs in the upper right corner to get information on how to use your current screen and where to go for more assistance.' ); ?>
+'; + printf( __( 'Install a theme to get started customizing your site.' ), esc_url( admin_url( 'themes.php' ) ) ); + echo '
'; + else: + $customize_links = array(); + if ( 'twentyeleven' == $ct->stylesheet ) + $customize_links[] = sprintf( __( 'Choose light or dark' ), esc_url( admin_url( 'themes.php?page=theme_options' ) ) ); + + if ( current_theme_supports( 'custom-background' ) ) + $customize_links[] = sprintf( __( 'Set a background color' ), esc_url( admin_url( 'themes.php?page=custom-background' ) ) ); + + if ( current_theme_supports( 'custom-header' ) ) + $customize_links[] = sprintf( __( 'Select a new header image' ), esc_url( admin_url( 'themes.php?page=custom-header' ) ) ); + + if ( current_theme_supports( 'widgets' ) ) + $customize_links[] = sprintf( __( 'Add some widgets' ), esc_url( admin_url( 'widgets.php' ) ) ); + + if ( ! empty( $customize_links ) ) { + echo ''; + printf( __( 'Use the current theme — %1$s — or choose a new one. If you stick with %3$s, here are a few ways to make your site look unique.' ), $ct->title, esc_url( admin_url( 'themes.php' ) ), $ct->title ); + echo '
'; + ?> +Dismiss this message.' ), esc_url( admin_url( '?welcome=0' ) ) ); ?>
+