Ticket #23295: 23295-5.patch
File 23295-5.patch, 18.2 KB (added by , 12 years ago) |
---|
-
wp-admin/css/wp-admin.css
7291 7291 width: auto; 7292 7292 } 7293 7293 7294 body.interim-login { 7295 height: auto; 7296 } 7297 7294 7298 .interim-login #login { 7295 7299 padding: 0; 7296 width: 300px;7300 margin: 25px auto 20px; 7297 7301 } 7298 7302 7299 7303 .interim-login.login h1 a { -
wp-includes/css/wp-auth-check.css
1 /*------------------------------------------------------------------------------ 2 Interim login dialog 3 ------------------------------------------------------------------------------*/ 4 5 #wp-auth-check-wrap.hidden { 6 display: none; 7 } 8 9 #wp-auth-check-wrap #wp-auth-check-bg { 10 position: fixed; 11 top: 0; 12 bottom: 0; 13 left: 0; 14 right: 0; 15 background: #000; 16 opacity: 0.5; 17 filter: alpha(opacity=50); 18 z-index: 1000000; 19 } 20 21 #wp-auth-check-wrap #wp-auth-check { 22 position: fixed; 23 left: 50%; 24 overflow: hidden; 25 top: 40px; 26 bottom: 20px; 27 max-height: 435px; 28 width: 380px; 29 margin: 0 0 0 -190px; 30 padding: 0; 31 background-color: #fbfbfb; 32 -webkit-border-radius: 3px; 33 border-radius: 3px; 34 z-index: 1000001; 35 } 36 37 #wp-auth-check-wrap.xdomain #wp-auth-check { 38 max-height: 180px; 39 overflow: auto; 40 } 41 42 #wp-auth-check-wrap #wp-auth-check-form { 43 background: url('../images/wpspin-2x.gif') no-repeat center center; 44 background-size: 16px 16px; 45 height: 100%; 46 } 47 48 #wp-auth-check-wrap #wp-auth-check-form iframe { 49 height: 100%; 50 width: 100%; 51 overflow: auto; 52 } 53 54 #wp-auth-check-wrap .wp-auth-check-close { 55 bottom: 10px; 56 display: none; 57 position: absolute; 58 right: 30px; 59 } 60 61 #wp-auth-check-wrap .wp-auth-xdomain { 62 font-size: 14px; 63 line-height: 21px; 64 padding: 10px 25px; 65 display: none; 66 } 67 68 #wp-auth-check-wrap.xdomain .wp-auth-xdomain, 69 #wp-auth-check-wrap.xdomain .wp-auth-check-close { 70 display: block; 71 } 72 -
wp-includes/default-filters.php
295 295 add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' ); 296 296 297 297 // Check if the user is logged out 298 add_action( ' admin_init', 'wp_auth_check_load' );298 add_action( 'init', 'wp_auth_check_load' ); 299 299 300 300 unset($filter, $action); -
wp-includes/functions.php
3887 3887 } 3888 3888 3889 3889 /** 3890 * Load the auth check, for monitoring whether the user is still logged in 3890 * Load the auth check for monitoring whether the user is still logged in. 3891 * Can be disabled with remove_action( 'init', 'wp_auth_check_load' ); 3891 3892 * 3892 3893 * @since 3.6.0 3893 3894 * 3894 3895 * @return void 3895 3896 */ 3896 3897 function wp_auth_check_load() { 3897 wp_enqueue_script( 'heartbeat' ); 3898 add_filter( 'heartbeat_received', 'wp_auth_check', 10, 2 ); 3899 add_filter( 'heartbeat_nopriv_received', 'wp_auth_check', 10, 2 ); 3898 global $pagenow; 3900 3899 3901 if ( is_admin() ) 3902 add_action( 'admin_print_footer_scripts', 'wp_auth_check_js' ); 3903 elseif ( is_user_logged_in() ) 3904 add_action( 'wp_print_footer_scripts', 'wp_auth_check_js' ); 3900 // Don't load for these types of requests 3901 if ( defined('XMLRPC_REQUEST') || defined('IFRAME_REQUEST') || 'wp-login.php' == $pagenow ) 3902 return; 3903 3904 if ( is_admin() || is_user_logged_in() ) { 3905 if ( defined('DOING_AJAX') ) { 3906 add_filter( 'heartbeat_received', 'wp_auth_check', 10, 2 ); 3907 add_filter( 'heartbeat_nopriv_received', 'wp_auth_check', 10, 2 ); 3908 } else { 3909 wp_enqueue_style( 'wp-auth-check' ); 3910 wp_enqueue_script( 'wp-auth-check' ); 3911 3912 if ( is_admin() ) 3913 add_action( 'admin_print_footer_scripts', 'wp_auth_check_html', 5 ); 3914 else 3915 add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 ); 3916 } 3917 } 3905 3918 } 3906 3919 3907 3920 /** 3908 * Output the JS that shows the wp-login iframewhen the user is no longer logged in3921 * Output the HTML that shows the wp-login dialog when the user is no longer logged in 3909 3922 */ 3910 function wp_auth_check_js() { 3923 function wp_auth_check_html() { 3924 $login_url = wp_login_url(); 3925 $current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST']; 3926 $same_domain = ( strpos( $login_url, $current_domain ) === 0 ); 3927 3928 // Let plugins change this if they know better. 3929 $same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain ); 3930 $wrap_class = $same_domain ? 'hidden' : 'hidden xdomain'; 3931 3911 3932 ?> 3912 < script type="text/javascript">3913 (function($){3914 $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {3915 var wrap = $('#wp-auth-check-notice-wrap');3933 <div id="wp-auth-check-wrap" class="<?php echo $wrap_class; ?>"> 3934 <div id="wp-auth-check-bg"></div> 3935 <div id="wp-auth-check"> 3936 <?php 3916 3937 3917 if ( data['wp-auth-check-html'] && ! wrap.length ) { 3918 $('body').append( data['wp-auth-check-html'] ); 3919 } else if ( !data['wp-auth-check-html'] && wrap.length && ! wrap.data('logged-in') ) { 3920 wrap.remove(); 3921 } 3922 }).on( 'heartbeat-send.wp-auth-check', function( e, data ) { 3923 data['wp-auth-check'] = 1; 3924 }); 3925 }(jQuery)); 3926 </script> 3938 if ( $same_domain ) { 3939 ?> 3940 <div id="wp-auth-check-form" data-src="<?php echo esc_url( add_query_arg( array( 'interim-login' => 1 ), $login_url ) ); ?>"></div> 3941 <?php 3942 } 3943 3944 ?> 3945 <div class="wp-auth-xdomain"> 3946 <p><b class="wp-auth-xdomain-expired" tabindex="0"><?php _e('Session expired'); ?></b></p> 3947 <p><a href="<?php echo esc_url( $login_url ); ?>" target="_blank"><?php _e('Please log in again.'); ?></a> 3948 <?php _e('The login page will open in a new window. After logging in you can close it and return to this page.'); ?></p> 3949 </div> 3950 <p class="wp-auth-check-close"><a href="#" class="button button-primary"><?php _e('Close'); ?></a></p> 3951 </div> 3952 </div> 3927 3953 <?php 3928 3954 } 3929 3955 … … 3940 3966 if ( is_user_logged_in() && empty( $GLOBALS['login_grace_period'] ) ) 3941 3967 return $response; 3942 3968 3943 return array_merge( $response, array( 3944 'wp-auth-check-html' => '<div id="wp-auth-check-notice-wrap"> 3945 <style type="text/css" scoped> 3946 #wp-auth-check { 3947 position: fixed; 3948 height: 90%; 3949 left: 50%; 3950 max-height: 415px; 3951 overflow: auto; 3952 top: 35px; 3953 width: 300px; 3954 margin: 0 0 0 -160px; 3955 padding: 12px 20px; 3956 border: 1px solid #ddd; 3957 background-color: #fbfbfb; 3958 -webkit-border-radius: 3px; 3959 border-radius: 3px; 3960 z-index: 1000000000; 3969 return array_merge( $response, array( 'wp-auth-check' => '1' ) ); 3961 3970 } 3962 #wp-auth-check-form {3963 background: url("' . admin_url('/images/wpspin_light-2x.gif') . '") no-repeat center center;3964 background-size: 16px 16px;3965 }3966 #wp-auth-check-form iframe {3967 height: 100%;3968 overflow: hidden;3969 }3970 #wp-auth-check a.wp-auth-check-close {3971 position: absolute;3972 right: 8px;3973 top: 8px;3974 width: 24px;3975 height: 24px;3976 background: url("' . includes_url('images/uploader-icons.png') . '") no-repeat scroll -95px center transparent;3977 }3978 #wp-auth-check h3 {3979 margin: 0 0 12px;3980 padding: 0;3981 font-size: 1.25em;3982 }3983 @media print,3984 (-o-min-device-pixel-ratio: 5/4),3985 (-webkit-min-device-pixel-ratio: 1.25),3986 (min-resolution: 120dpi) {3987 #wp-auth-check a.wp-auth-check-close {3988 background-image: url("' . includes_url('images/uploader-icons-2x.png') . '");3989 background-size: 134px 15px;3990 }3991 }3992 </style>3993 <div id="wp-auth-check" tabindex="0">3994 <h3>' . __('Session expired') . '</h3>3995 <a href="#" class="wp-auth-check-close"><span class="screen-reader-text">' . __('close') . '</span></a>3996 <div id="wp-auth-check-form">3997 <iframe src="' . esc_url( add_query_arg( array( 'interim-login' => 1 ), wp_login_url() ) ) . '" frameborder="0"></iframe>3998 </div>3999 </div>4000 <script type="text/javascript">4001 (function($){4002 var el, wrap = $("#wp-auth-check-notice-wrap");4003 el = $("#wp-auth-check").focus().find("a.wp-auth-check-close").on("click", function(e){4004 el.fadeOut(200, function(){ wrap.remove(); });4005 e.preventDefault();4006 });4007 $("#wp-auth-check-form iframe").load(function(){4008 var height;4009 try { height = $(this.contentWindow.document).find("#login").height(); } catch(er){}4010 if ( height ) {4011 $("#wp-auth-check").css("max-height", height + 40 + "px");4012 $(this).css("height", height + 5 + "px");4013 if ( height < 200 ) {4014 wrap.data("logged-in", true);4015 setTimeout( function(){ wrap.fadeOut(200, function(){ wrap.remove(); }); }, 5000 );4016 }4017 }4018 });4019 }(jQuery));4020 </script>4021 </div>' ) );4022 }4023 3971 4024 3972 /** 4025 3973 * Return RegEx body to liberally match an opening HTML tag that: … … 4039 3987 return; 4040 3988 4041 3989 return sprintf( '(<%1$s[^>]*(?:/?>$|>[\s\S]*?</%1$s>))', tag_escape( $tag ) ); 4042 } 4043 No newline at end of file 3990 } -
wp-includes/js/wp-auth-check.js
1 // Interim login dialog 2 (function($){ 3 var wrap; 4 5 function show() { 6 var parent = $('#wp-auth-check'), form = $('#wp-auth-check-form'), frame; 7 8 if ( form.length ) { 9 // Add unload confirmation to counter (frame-busting) JS redirects 10 $(window).on( 'beforeunload.wp-auth-check', function(e) { 11 e.originalEvent.returnValue = window.authcheckL10n.beforeunload; 12 }); 13 14 // Add 'sandbox' for browsers that support it, only restrict access to the top window. 15 frame = $('<iframe id="wp-auth-check-frame" sandbox="allow-same-origin allow-forms allow-scripts" frameborder="0">').attr( 'title', wrap.find('.wp-auth-xdomain-expired').text() ); 16 frame.load( function(e) { 17 var height, body; 18 19 try { 20 body = $(this).contents().find('body'); 21 height = body.height(); 22 } catch(e) { 23 wrap.addClass('xdomain'); 24 form.remove(); 25 } 26 27 if ( height ) { 28 if ( body && body.hasClass('interim-login-success') ) { 29 height += 35; 30 parent.find('.wp-auth-check-close').show(); 31 wrap.data('logged-in', 1); 32 setTimeout( function() { hide(); }, 3000 ); 33 } 34 35 parent.css( 'max-height', height + 60 + 'px' ); 36 } 37 }).attr( 'src', form.data('src') ); 38 39 $('#wp-auth-check-form').append( frame ); 40 } 41 42 wrap.removeClass('hidden'); 43 44 if ( frame ) 45 frame.focus(); 46 else 47 wrap.find('.wp-auth-xdomain-expired').focus(); 48 } 49 50 function hide() { 51 $(window).off( 'beforeunload.wp-auth-check' ); 52 53 wrap.fadeOut( 200, function() { 54 wrap.addClass('hidden').css('display', ''); 55 $('#wp-auth-check-frame').remove(); 56 }); 57 } 58 59 $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) { 60 if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) { 61 show(); 62 } else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') && ! wrap.data('logged-in') ) { 63 hide(); 64 } 65 }).on( 'heartbeat-send.wp-auth-check', function( e, data ) { 66 data['wp-auth-check'] = 1; 67 }).ready( function() { 68 wrap = $('#wp-auth-check-wrap').data('logged-in', 0); 69 wrap.find('.wp-auth-check-close').on( 'click', function(e) { 70 hide(); 71 }); 72 }); 73 74 }(jQuery)); -
wp-includes/js/wp-auth-check.js
-
wp-includes/script-loader.php
Property changes on: wp-includes/js/wp-auth-check.js ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
113 113 apply_filters( 'heartbeat_settings', array() ) 114 114 ); 115 115 116 $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array('heartbeat'), false, 1 ); 117 did_action( 'init' ) && $scripts->localize( 'wp-auth-check', 'authcheckL10n', array( 118 'beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'), 119 ) ); 120 116 121 $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 ); 117 122 118 123 // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source. … … 543 548 $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie' ) ); 544 549 $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons' ) ); 545 550 $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); 551 $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css" ); 546 552 547 553 $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer$suffix.css" ); 548 554 $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.css", array( 'mediaelement' ) ); -
wp-login.php
48 48 $wp_error = new WP_Error(); 49 49 50 50 // Shake it! 51 $shake_error_codes = array( ' empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );51 $shake_error_codes = array( 'interim_login_error', 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' ); 52 52 $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); 53 53 54 if ( ! $interim_login &&$shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )54 if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) 55 55 add_action( 'login_head', 'wp_shake_js', 12 ); 56 56 57 57 ?><!DOCTYPE html> … … 100 100 // Don't allow interim logins to navigate away from the page. 101 101 $login_header_url = '#'; 102 102 $classes[] = 'interim-login'; 103 ?> 104 <style type="text/css">html{background-color: transparent;}</style> 105 <?php 106 107 if ( 'success' === $interim_login ) 108 $classes[] = 'interim-login-success'; 103 109 } 104 110 105 111 $classes = apply_filters( 'login_body_class', $classes, $action ); … … 624 630 if ( !is_wp_error($user) && !$reauth ) { 625 631 if ( $interim_login ) { 626 632 $message = '<p class="message">' . __('You have logged in successfully.') . '</p>'; 633 $interim_login = 'success'; 627 634 login_header( '', $message ); ?> 628 635 </div> 629 636 <?php do_action( 'login_footer' ); ?> … … 648 655 } 649 656 650 657 $errors = $user; 651 // Clear errors if loggedout or interim_loginis set.652 if ( !empty($_GET['loggedout']) || $reauth || $interim_login)658 // Clear errors if loggedout is set. 659 if ( !empty($_GET['loggedout']) || $reauth ) 653 660 $errors = new WP_Error(); 654 661 655 662 // If cookies are disabled we can't log in even with a valid user+pass 656 663 if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) ) 657 664 $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.")); 658 665 659 // Some parts of this script use the main login form to display a message 660 if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) 661 $errors->add('loggedout', __('You are now logged out.'), 'message'); 662 elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) 663 $errors->add('registerdisabled', __('User registration is currently not allowed.')); 664 elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) 665 $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); 666 elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) 667 $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); 668 elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) 669 $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); 670 elseif ( $interim_login ) 671 $errors->add('expired', __('Please log in again. You will not move away from this page.'), 'message'); 672 elseif ( strpos( $redirect_to, 'about.php?updated' ) ) 673 $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' ); 666 // Clear most errors if interim login 667 if ( $interim_login ) { 668 $error_code = $errors->get_error_code(); 669 $errors = new WP_Error(); 674 670 671 if ( $error_code ) { 672 if ( in_array( $error_code, array( 'empty_password', 'empty_username', 'invalid_username', 'incorrect_password' ) ) ) 673 $errors->add('interim_login_error', __('<strong>ERROR</strong>: Invalid username or password.')); 674 else 675 $errors->add('interim_login_error_other', sprintf( __( '<strong>ERROR</strong>: Please contact the site administrator or try to <a href="%s" target="_blank">log in from a new window</a>.' ), wp_login_url() ) ); 676 } else { 677 $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); 678 } 679 } else { 680 // Some parts of this script use the main login form to display a message 681 if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) 682 $errors->add('loggedout', __('You are now logged out.'), 'message'); 683 elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) 684 $errors->add('registerdisabled', __('User registration is currently not allowed.')); 685 elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) 686 $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); 687 elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) 688 $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); 689 elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) 690 $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); 691 elseif ( strpos( $redirect_to, 'about.php?updated' ) ) 692 $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' ); 693 } 694 675 695 // Clear any stale cookies. 676 696 if ( $reauth ) 677 697 wp_clear_auth_cookie();