+// Display File upload quota on dashboard
+function wp_dashboard_quota() {
+ if ( !is_multisite() || !current_user_can('upload_files') || get_site_option( 'upload_space_check_disabled' ) )
+ return true;
+
+ $quota = get_space_allowed();
+ $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
+
+ if ( $used > $quota )
+ $percentused = '100';
+ else
+ $percentused = ( $used / $quota ) * 100;
+ $used_color = ( $percentused >= 70 ) ? ' spam' : '';
+ $used = round( $used, 2 );
+ $percentused = number_format( $percentused );
+
+ ?>
+ <p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
+ <div class="table table_content musubtable">
+ <table>
+ <tr class="first">
+ <td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td>
+ <td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
+ </tr>
+ </table>
+ </div>
+ <div class="table table_discussion musubtable">
+ <table>
+ <tr class="first">
+ <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>
+ <td class="last t comments<?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
+ </tr>
+ </table>
+ </div>
+ <br class="clear" />
+ <?php
+}
+add_action( 'activity_box_end', 'wp_dashboard_quota' );
+
+// Display Browser Nag Meta Box
+function wp_dashboard_browser_nag() {
+ $notice = '';
+ $response = wp_check_browser_version();
+
+ if ( $response ) {
+ if ( $response['insecure'] ) {
+ $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'] ) );
+ } else {
+ $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'] ) );
+ }
+
+ $browser_nag_class = '';
+ if ( !empty( $response['img_src'] ) ) {
+ $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src'];
+
+ $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
+ $browser_nag_class = ' has-browser-icon';
+ }
+ $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
+
+ $browsehappy = 'http://browsehappy.com/';
+ $locale = get_locale();
+ if ( 'en_US' !== $locale )
+ $browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
+
+ $notice .= '<p>' . sprintf( __( '<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>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
+ $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>';
+ $notice .= '<div class="clear"></div>';
+ }
+
+ 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 . '; ' . home_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 = maybe_unserialize( wp_remote_retrieve_body( $response ) );
+
+ if ( ! is_array( $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.0
+ */
+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 );
+ ?>
+ <div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
+ <?php wp_nonce_field( 'welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
+ <a class="welcome-panel-close" href="<?php echo esc_url( admin_url( '?welcome=0' ) ); ?>"><?php _e('Dismiss'); ?></a>
+ <div class="wp-badge"><?php printf( __( 'Version %s' ), $display_version ); ?></div>
+
+ <div class="welcome-panel-content">
+ <h3><?php _e( 'Welcome to your new WordPress site!' ); ?></h3>
+ <p class="about-description"><?php _e( 'If you need help getting started, check out our documentation on <a href="http://codex.wordpress.org/First_Steps_With_WordPress">First Steps with WordPress</a>. 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.' ); ?></p>
+ <div class="welcome-panel-column-container">
+ <div class="welcome-panel-column">
+ <h4><span class="icon16 icon-settings"></span> <?php _e( 'Basic Settings' ); ?></h4>
+ <p><?php _e( 'Here are a few easy things you can do to get your feet wet. Make sure to click Save on each Settings screen.' ); ?></p>
+ <ul>
+ <li><?php echo sprintf( __( '<a href="%s">Choose your privacy setting</a>' ), esc_url( admin_url('options-privacy.php') ) ); ?></li>
+ <li><?php echo sprintf( __( '<a href="%s">Select your tagline and time zone</a>' ), esc_url( admin_url('options-general.php') ) ); ?></li>
+ <li><?php echo sprintf( __( '<a href="%s">Turn comments on or off</a>' ), esc_url( admin_url('options-discussion.php') ) ); ?></li>
+ <li><?php echo sprintf( __( '<a href="%s">Fill in your profile</a>' ), esc_url( admin_url('profile.php') ) ); ?></li>
+ </ul>
+ </div>
+ <div class="welcome-panel-column">
+ <h4><span class="icon16 icon-page"></span> <?php _e( 'Add Real Content' ); ?></h4>
+ <p><?php _e( 'Check out the sample page & post editors to see how it all works, then delete the default content and write your own!' ); ?></p>
+ <ul>
+ <li><?php echo sprintf( __( 'View the <a href="%1$s">sample page</a> and <a href="%2$s">post</a>' ), esc_url( get_permalink( 2 ) ), esc_url( get_permalink( 1 ) ) ); ?></li>
+ <li><?php echo sprintf( __( 'Delete the <a href="%1$s">sample page</a> and <a href="%2$s">post</a>' ), esc_url( admin_url('edit.php?post_type=page') ), esc_url( admin_url('edit.php') ) ); ?></li>
+ <li><?php echo sprintf( __( '<a href="%s">Create an About Me page</a>' ), esc_url( admin_url('edit.php?post_type=page') ) ); ?></li>
+ <li><?php echo sprintf( __( '<a href="%s">Write your first post</a>' ), esc_url( admin_url('post-new.php') ) ); ?></li>
+ </ul>
+ </div>
+ <div class="welcome-panel-column welcome-panel-last">
+ <h4><span class="icon16 icon-appearance"></span> <?php _e( 'Customize Your Site' ); ?></h4>
+ <?php
+ $theme = wp_get_theme();
+ if ( $theme->errors() ) :
+ echo '<p>';
+ printf( __( '<a href="%s">Install a theme</a> to get started customizing your site.' ), esc_url( admin_url( 'themes.php' ) ) );
+ echo '</p>';
+ else:
+ $customize_links = array();
+ if ( 'twentyeleven' == $theme->get_stylesheet() )
+ $customize_links[] = sprintf( __( '<a href="%s">Choose light or dark</a>' ), esc_url( admin_url( 'themes.php?page=theme_options' ) ) );
+
+ if ( current_theme_supports( 'custom-background' ) )
+ $customize_links[] = sprintf( __( '<a href="%s">Set a background color</a>' ), esc_url( admin_url( 'themes.php?page=custom-background' ) ) );
+
+ if ( current_theme_supports( 'custom-header' ) )
+ $customize_links[] = sprintf( __( '<a href="%s">Select a new header image</a>' ), esc_url( admin_url( 'themes.php?page=custom-header' ) ) );
+
+ if ( current_theme_supports( 'widgets' ) )
+ $customize_links[] = sprintf( __( '<a href="%s">Add some widgets</a>' ), esc_url( admin_url( 'widgets.php' ) ) );
+
+ if ( ! empty( $customize_links ) ) {
+ echo '<p>';
+ printf( __( 'Use the current theme — %1$s — or <a href="%2$s">choose a new one</a>. If you stick with %1$s, here are a few ways to make your site look unique.' ), $theme->display('Name'), esc_url( admin_url( 'themes.php' ) ) );
+ echo '</p>';
+ ?>
+ <ul>
+ <?php foreach ( $customize_links as $customize_link ) : ?>
+ <li><?php echo $customize_link ?></li>
+ <?php endforeach; ?>
+ </ul>
+ <?php
+ } else {
+ echo '<p>';
+ printf( __( 'Use the current theme — %1$s — or <a href="%2$s">choose a new one</a>.' ), $theme->display('Name'), esc_url( admin_url( 'themes.php' ) ) );
+ echo '</p>';
+ }
+ endif; ?>
+ </div>
+ </div>
+ <p class="welcome-panel-dismiss"><?php printf( __( 'Already know what you’re doing? <a href="%s">Dismiss this message</a>.' ), esc_url( admin_url( '?welcome=0' ) ) ); ?></p>
+ </div>
+ </div>
+ <?php
+}