Permalink
Browse files

Browse Happy: Add a notice for the browser you are using and suggest

they update to the newest version.

If they are running Internet Explorer on Windows XP, let them know we
suggest they try a different browser, as they cannot update further.

props hugobaeta for the design.

fixes #1
1 parent 86d840b commit 1a7e33ecb40e9b1de6ff1a15d3cfabdcf1138597 @nacin nacin committed May 11, 2012
Showing with 577 additions and 92 deletions.
  1. +34 −2 functions.php
  2. +9 −2 index.php
  3. +534 −88 style.css
View
@@ -46,7 +46,7 @@ function browsehappy_get_browser_data( $browser = false ) {
'normalized' => 1, // just first number
'facebook' => 'internetexplorer',
'url' => 'http://www.microsoft.com/windows/internet-explorer/',
- 'info' => __( '“Designed to help you take control of your privacy and browse with confidence. Free from Microsoft.”' ),
+ 'info' => __( '“Designed to help you take control of your privacy and browse with confidence. Free from Microsoft.”', 'browsehappy' ),
),
);
if ( false === $browser )
@@ -186,4 +186,36 @@ function query_posts() { }
function handle_404() {
status_header( 200 );
}
-}
+}
+
+if ( function_exists( 'browsehappy_parse_user_agent' ) )
+ add_action( 'browsehappy_browser_notice', 'browsehappy_browser_notice' );
+
+function browsehappy_browser_notice() {
+ $ua = $_SERVER['HTTP_USER_AGENT'];
+ $results = browsehappy_parse_user_agent( $ua );
+ if ( ! $results['upgrade'] )
+ return;
+ ?>
+ <div id="browser-status" class="wrap">
+ <?php if ( $results['name'] == 'Internet Explorer' && strpos( $ua, 'Windows NT 5.' ) !== false ) : ?>
+ <?php if ( $results['insecure'] ) : ?>
+ <p><?php printf( __( 'It looks like you&#8217;re using an insecure version of %s.', 'browsehappy' ), $results['name'] ); ?>
+ <?php _e( 'Using an outdated browser makes your computer unsafe.', 'browsehappy' ); ?>
+ <?php else : ?>
+ <p><?php _e( 'It looks like you&#8217;re using an old version of Internet Explorer.', 'browsehappy' ); ?>
+ <?php endif; ?>
+ <?php _e( 'On Windows XP, you are unable to update to the latest version. For the best experience on the web, we suggest you try a new browser.', 'browsehappy' ); ?></p>
+ <?php elseif ( $results['insecure'] ) : ?>
+ <p class="browser-status-text"><?php printf( __( 'It looks like you&#8217;re using an insecure version of %s.', 'browsehappy' ), $results['name'] ); ?>
+ <?php _e( 'Using an outdated browser makes your computer unsafe.', 'browsehappy' ); ?>
+ <?php _e( 'For the best experience on the web, please update your browser.', 'browsehappy' ); ?></p>
+ <p class="browser-status-action"><a href="<?php echo esc_url( $results['update_url'] ); ?>"><?php _e( 'Upgrade now!', 'browsehappy' ); ?></a></p>
+ <?php else : ?>
+ <p class="browser-status-text"><?php printf( __( 'Your browser is out of date! It looks like you&#8217;re using an old version of %s.', 'browsehappy' ), $results['name'] ); ?>
+ <?php _e( 'For the best experience on the web, please update your browser.', 'browsehappy' ); ?></p>
+ <p class="browser-status-action"><a href="<?php echo esc_url( $results['update_url'] ); ?>"><?php _e( 'Upgrade now!', 'browsehappy' ); ?></a></p>
+ <?php endif; ?>
+ </div>
+ <?php
+}
View
@@ -18,7 +18,7 @@
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo get_template_directory_uri(); ?>/imgs/apple-touch-icon-114x114.png" />
<!--[if (gt IE 6)|!(IE)]><!-->
- <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/style.css" />
+ <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/style.css?1" />
<script src="<?php echo get_template_directory_uri(); ?>/js/modernizr-1.6.min.js"></script>
<script src="http://use.typekit.com/lsw6yis.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
@@ -28,6 +28,13 @@
</head>
<body>
+<?php
+/*
+<div id="i18n-alert">
+ <p>Browse Happy is also available in %s. <a href="%s">Click here to change the language to %s</a>.</p>
+</div>
+*/
+?>
<div id="body-wrap">
<header>
@@ -36,7 +43,7 @@
<h2><?php _e( 'Online. Worry-free. <em>Upgrade your browser today</em>!', 'browsehappy' ); ?></h2>
</hgroup>
</header>
-
+ <?php do_action( 'browsehappy_browser_notice' ); ?>
<div id="main">
<ul id="browserlist" class="wrap">
<?php foreach ( browsehappy_get_browser_data() as $browser => $data ) : ?>
Oops, something went wrong.

0 comments on commit 1a7e33e

Please sign in to comment.