mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Warning for out of date and insecure browsers, props aaroncampbell, fixes #17323
git-svn-id: http://svn.automattic.com/wordpress/trunk@17887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e324f8dd88
commit
8fe1d44938
File diff suppressed because one or more lines are too long
@ -641,6 +641,56 @@ table.widefat span.spam a,
|
||||
border-color: #D1E5EE;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox.browser-insecure {
|
||||
background-color: #AC1B1B;
|
||||
border-color: #AC1B1B;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox {
|
||||
background-color: #e29808;
|
||||
border-color: #EDC048;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox {
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow:none;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.browser-insecure.postbox h3 {
|
||||
border-bottom-color: #CD5A5A;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox h3 {
|
||||
border-bottom-color: #F6E2AC;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox h3 {
|
||||
background:none;
|
||||
text-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.ui-sortable #dashboard_browser_nag.postbox,
|
||||
.ui-sortable #dashboard_browser_nag.postbox h3 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.browser-insecure a.browse-happy-link,
|
||||
#dashboard_browser_nag.browser-insecure a.update-browser-link {
|
||||
text-shadow: #871B15 0 1px 0;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag a.browse-happy-link,
|
||||
#dashboard_browser_nag a.update-browser-link {
|
||||
text-shadow: #D29A04 0 1px 0;
|
||||
}
|
||||
|
||||
.widget,
|
||||
.postbox {
|
||||
background-color: #fff;
|
||||
|
File diff suppressed because one or more lines are too long
@ -686,6 +686,54 @@ table.widefat span.spam a,
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox.browser-insecure {
|
||||
background-color: #AC1B1B;
|
||||
border-color: #AC1B1B;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox {
|
||||
background-color: #e29808;
|
||||
border-color: #EDC048;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox {
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow:none;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox.browser-insecure h3 {
|
||||
border-bottom-color: #CD5A5A;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.postbox h3 {
|
||||
border-bottom-color: #F6E2AC;
|
||||
text-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
.ui-sortable #dashboard_browser_nag.postbox,
|
||||
.ui-sortable #dashboard_browser_nag.postbox h3 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag.browser-insecure a.browse-happy-link,
|
||||
#dashboard_browser_nag.browser-insecure a.update-browser-link {
|
||||
text-shadow: #871B15 0 1px 0;
|
||||
}
|
||||
|
||||
#dashboard_browser_nag a.browse-happy-link,
|
||||
#dashboard_browser_nag a.update-browser-link {
|
||||
text-shadow: #D29A04 0 1px 0;
|
||||
}
|
||||
|
||||
.ui-sortable .postbox h3 {
|
||||
color: #464646;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -73,10 +73,24 @@ div.postbox div.inside {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#dashboard-widgets a.update-browser-link {
|
||||
font-size:1.2em;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
#dashboard-widgets #dashboard_browser_nag a,
|
||||
#dashboard-widgets h3 a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#dashboard-widgets p.browser-update-nag.has-browser-icon {
|
||||
padding-right:125px;
|
||||
}
|
||||
|
||||
#dashboard-widgets .browser-icon {
|
||||
margin-top: -35px;
|
||||
}
|
||||
|
||||
#dashboard-widgets h3 .postbox-title-action {
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
|
@ -25,6 +25,16 @@ function wp_dashboard_setup() {
|
||||
|
||||
/* Register Widgets and Controls */
|
||||
|
||||
$response = wp_check_browser_version();
|
||||
|
||||
if ( $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' );
|
||||
else
|
||||
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
|
||||
}
|
||||
|
||||
// Right Now
|
||||
if ( is_blog_admin() && current_user_can('edit_posts') )
|
||||
wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
|
||||
@ -1147,6 +1157,83 @@ function wp_dashboard_quota() {
|
||||
}
|
||||
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['insecure'] ) {
|
||||
$msg = sprintf( __( 'It looks like you\'re using an insecure version of <a href="%1$s">%2$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="%1$s">%2$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'] ) );
|
||||
}
|
||||
|
||||
$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>";
|
||||
$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/' );
|
||||
$notice .= '<p><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['insecure'] )
|
||||
$classes[] = 'browser-insecure';
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user needs a browser update
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
function wp_check_browser_version() {
|
||||
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
|
||||
|
||||
if ( false === ($response = get_site_transient('browsehappy_' . $key) ) ) {
|
||||
global $wp_version;
|
||||
|
||||
$options = array(
|
||||
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
|
||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
|
||||
);
|
||||
|
||||
$raw_response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.0/', $options );
|
||||
|
||||
if ( is_wp_error( $raw_response ) || 200 != $raw_response['response']['code'] )
|
||||
return;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
$response = unserialize( $raw_response['body'] );
|
||||
|
||||
if ( ! $response )
|
||||
return;
|
||||
|
||||
set_site_transient( 'browsehappy_' . $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).
|
||||
*/
|
||||
|
@ -18,6 +18,11 @@ var postboxes;
|
||||
$('.postbox h3 a').click( function(e) {
|
||||
e.stopPropagation();
|
||||
} );
|
||||
$('.postbox a.dismiss').click( function(e) {
|
||||
var hide_id = $(this).parents('.postbox').attr('id') + '-hide';
|
||||
$( '#' + hide_id ).attr('checked', false).triggerHandler('click');
|
||||
return false;
|
||||
} );
|
||||
$('.hide-postbox-tog').click( function() {
|
||||
var box = $(this).val();
|
||||
|
||||
|
@ -1 +1 @@
|
||||
var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var e=a(this).parent(".postbox"),f=e.attr("id");e.toggleClass("closed");postboxes.save_state(c);if(f){if(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(f)}else{if(e.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(f)}}}});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).attr("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,h=a("#poststuff");if(h.length){if(e==2){h.addClass("has-right-sidebar");a("#side-sortables").addClass("temp-border")}else{if(e==1){h.removeClass("has-right-sidebar");a("#normal-sortables").append(a("#side-sortables").children(".postbox"))}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+d(f)+"-sortables");a("#"+d(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=1;f<=e;f++){g=a("#"+d(f)+"-sortables");if(g.parent().is(":hidden")){g.addClass("temp-border").parent().show()}}a(".postbox-container:visible").css("width",98/e+"%")}postboxes.save_order(c)});function d(e){switch(e){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,start:function(f,d){a("body").css({WebkitUserSelect:"none",KhtmlUserSelect:"none"})},stop:function(f,d){postboxes.save_order(c);d.item.parent().removeClass("temp-border");a("body").css({WebkitUserSelect:"",KhtmlUserSelect:""})}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b)},pbshow:false,pbhide:false}}(jQuery));
|
||||
var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var e=a(this).parent(".postbox"),f=e.attr("id");e.toggleClass("closed");postboxes.save_state(c);if(f){if(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(f)}else{if(e.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(f)}}}});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".postbox a.dismiss").click(function(g){var f=a(this).parents(".postbox").attr("id")+"-hide";a("#"+f).attr("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).attr("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,h=a("#poststuff");if(h.length){if(e==2){h.addClass("has-right-sidebar");a("#side-sortables").addClass("temp-border")}else{if(e==1){h.removeClass("has-right-sidebar");a("#normal-sortables").append(a("#side-sortables").children(".postbox"))}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+d(f)+"-sortables");a("#"+d(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=1;f<=e;f++){g=a("#"+d(f)+"-sortables");if(g.parent().is(":hidden")){g.addClass("temp-border").parent().show()}}a(".postbox-container:visible").css("width",98/e+"%")}postboxes.save_order(c)});function d(e){switch(e){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,start:function(f,d){a("body").css({WebkitUserSelect:"none",KhtmlUserSelect:"none"})},stop:function(f,d){postboxes.save_order(c);d.item.parent().removeClass("temp-border");a("body").css({WebkitUserSelect:"",KhtmlUserSelect:""})}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b)},pbshow:false,pbhide:false}}(jQuery));
|
@ -325,7 +325,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
$scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20100403' );
|
||||
$scripts->add_data( 'xfn', 'group', 1 );
|
||||
|
||||
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' );
|
||||
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20110511' );
|
||||
$scripts->add_data( 'postbox', 'group', 1 );
|
||||
|
||||
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110429' );
|
||||
@ -449,7 +449,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
'l10n_print_after' => 'try{convertEntities(navMenuL10n);}catch(e){};'
|
||||
) );
|
||||
|
||||
$scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20101025' );
|
||||
$scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20110511' );
|
||||
$scripts->add_data( 'custom-background', 'group', 1 );
|
||||
}
|
||||
}
|
||||
@ -493,7 +493,7 @@ function wp_default_styles( &$styles ) {
|
||||
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
|
||||
|
||||
// all colors stylesheets need to have the same query strings (cache manifest compat)
|
||||
$colors_version = '20110511n';
|
||||
$colors_version = '20110511o';
|
||||
|
||||
// Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
|
||||
$styles->add( 'colors', true, array(), $colors_version );
|
||||
@ -506,7 +506,7 @@ function wp_default_styles( &$styles ) {
|
||||
$styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20110511g' );
|
||||
$styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20110121' );
|
||||
$styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20110511b' );
|
||||
$styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20110511b' );
|
||||
$styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20110511c' );
|
||||
$styles->add( 'install', "/wp-admin/css/install$suffix.css", array(), '20110506' ); // Readme as well
|
||||
$styles->add( 'theme-editor', "/wp-admin/css/theme-editor$suffix.css", array(), '20110506' );
|
||||
$styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array(), '20110506' );
|
||||
|
Loading…
Reference in New Issue
Block a user