<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[23504] trunk: Improved logged out warnings, first run, props mintindeed, see #23295</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23504">23504</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2013-02-28 08:57:17 +0000 (Thu, 28 Feb 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Improved logged out warnings, first run, props mintindeed, see <a href="http://core.trac.wordpress.org/ticket/23295">#23295</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpincludesdefaultfiltersphp">trunk/wp-includes/default-filters.php</a></li>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
<li><a href="#trunkwploginphp">trunk/wp-login.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpincludesclasswpauthcheckphp">trunk/wp-includes/class-wp-auth-check.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (23503 => 23504)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2013-02-28 07:40:11 UTC (rev 23503)
+++ trunk/wp-admin/css/wp-admin.css        2013-02-28 08:57:17 UTC (rev 23504)
</span><span class="lines">@@ -6785,7 +6785,24 @@
</span><span class="cx">         width: auto;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.interim-login #login {
+        padding: 0;
+        width: 300px;
+}
</ins><span class="cx"> 
</span><ins>+.interim-login.login h1 a {
+        width: auto;
+}
+
+.interim-login #login_error,
+.interim-login.login .message {
+        margin: 0 0 16px;
+}
+
+.interim-login.login form {
+        margin: 0;
+}
+
</ins><span class="cx"> /* ms */
</span><span class="cx"> /* Dashboard: MS Specific Data */
</span><span class="cx"> #dashboard_right_now p.musub {
</span></span></pre></div>
<a id="trunkwpincludesclasswpauthcheckphp"></a>
<div class="addfile"><h4>Added: trunk/wp-includes/class-wp-auth-check.php (0 => 23504)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-auth-check.php                                (rev 0)
+++ trunk/wp-includes/class-wp-auth-check.php        2013-02-28 08:57:17 UTC (rev 23504)
</span><span class="lines">@@ -0,0 +1,192 @@
</span><ins>+&lt;?php
+/**
+ * Test the user's current authorization state
+ *
+ * @package WordPress
+ * @since 3.6.0
+ */
+class WP_Auth_Check {
+
+        /**
+         * Holds the singleton instance of this object
+         */
+        private static $_instance = null;
+
+        /**
+         * Private constructor because we're a singleton
+         */
+        private function __construct() {}
+
+        /**
+         * Initialize the singleton
+         */
+        public static function get_instance() {
+                $this_class = get_called_class(); // gets the right class when this is extended
+                if ( ! ( self::$_instance instanceof $this_class ) ) {
+                        self::$_instance = new $this_class;
+                        self::$_instance-&gt;_init();
+                }
+
+                return self::$_instance;
+        }
+
+        /**
+         * Object init, sets up hooks. Not done in the constructor so that the
+         * _init() method may be extended without breaking the singleton.
+         */
+        protected function _init() {
+                if ( is_admin() ) {
+                        add_action( 'admin_footer', array( $this, 'enqueue_scripts' ) );
+                        add_action( 'admin_print_footer_scripts', array( $this, 'footer_js' ) );
+                } elseif ( is_user_logged_in() ) {
+                        add_action( 'wp_footer', array( $this, 'enqueue_scripts' ) );
+                        add_action( 'wp_print_footer_scripts', array( $this, 'footer_js' ) );
+                }
+
+                add_filter( 'heartbeat_received', array( $this, 'login' ), 10, 2 );
+                add_filter( 'heartbeat_nopriv_received', array( $this, 'nopriv_login' ), 10, 2 );
+        }
+
+        /**
+         * Checks if the user is still logged in
+         */
+        public function login( $response, $data ) {
+                if ( array_key_exists('wp-auth-check', $data) &amp;&amp; ( ! isset( $_COOKIE[LOGGED_IN_COOKIE] ) || ! wp_validate_auth_cookie() || ! empty( $GLOBALS['login_grace_period'] ) ) )
+                        $response['wp-auth-check-html'] = $this-&gt;notice();
+
+                
+                $response['LOGGED_IN_COOKIE'] = isset( $_COOKIE[LOGGED_IN_COOKIE] );
+                
+                $response['wp_validate_auth_cookie'] = wp_validate_auth_cookie();
+                
+                return $response;
+        }
+
+        /**
+         * Runs when a user is expected to be logged in
+         * but has logged out or cannot be validated
+         */
+        public function nopriv_login( $response, $data ) {
+                if ( array_key_exists('wp-auth-check', $data) )
+                        $response['wp-auth-check-html'] = $this-&gt;notice();
+
+                
+                $response['nopriv_login'] = 1;
+                
+                
+                return $response;
+        }
+        
+        public function footer_js() {
+                ?&gt;
+                &lt;script&gt;
+                (function($){
+                        $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
+                                var wrap = $('#wp-auth-check-notice-wrap');
+
+                                if ( data['wp-auth-check-html'] &amp;&amp; ! wrap.length ) {
+                                        $('body').append( data['wp-auth-check-html'] );
+                                } else if ( !data['wp-auth-check-html'] &amp;&amp; wrap.length &amp;&amp; ! wrap.data('logged-in') ) {
+                                        wrap.remove();
+                                }
+                        }).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
+                                data['wp-auth-check'] = 1;
+                        });
+                }(jQuery));
+                &lt;/script&gt;
+                &lt;?php
+        }
+
+        public function enqueue_scripts() {
+                // This will also enqueue jQuery
+                wp_enqueue_script( 'heartbeat' );
+        }
+
+        /**
+         * Returns the login notice
+         */
+        public function notice() {
+                // Inline JS and CSS, keep the notice portable.
+                return '
+&lt;div id=&quot;wp-auth-check-notice-wrap&quot;&gt;
+&lt;style type=&quot;text/css&quot; scoped&gt;
+#wp-auth-check {
+        position: fixed;
+        height: 90%;
+        left: 50%;
+        max-height: 415px;
+        overflow: auto;
+        top: 35px;
+        width: 300px;
+        margin: 0 0 0 -160px;
+        padding: 12px 20px;
+        border: 1px solid #ddd;
+        background-color: #fbfbfb;
+        -webkit-border-radius: 3px;
+        border-radius: 3px;
+        z-index: 1000000000;
+}
+#wp-auth-check-form {
+        background: url(&quot;' . admin_url('/images/wpspin_light-2x.gif') . '&quot;) no-repeat center center;
+        background-size: 16px 16px;
+}
+#wp-auth-check-form iframe {
+        height: 100%;
+        overflow: hidden;
+}
+#wp-auth-check a.wp-auth-check-close {
+        position: absolute;
+        right: 8px;
+        top: 8px;
+        width: 24px;
+        height: 24px;
+        background: url(&quot;' . includes_url('images/uploader-icons.png') . '&quot;) no-repeat scroll -95px center transparent;
+}
+#wp-auth-check h3 {
+        margin: 0 0 12px;
+        padding: 0;
+        font-size: 1.25em;
+}
+@media print,
+  (-o-min-device-pixel-ratio: 5/4),
+  (-webkit-min-device-pixel-ratio: 1.25),
+  (min-resolution: 120dpi) {
+        #wp-auth-check a.wp-auth-check-close {
+                background-image: url(&quot;' . includes_url('images/uploader-icons-2x.png') . '&quot;);
+                background-size: 134px 15px;
+        }
+}
+&lt;/style&gt;
+&lt;div id=&quot;wp-auth-check&quot; tabindex=&quot;0&quot;&gt;
+&lt;h3&gt;' .  __('Session expired') . '&lt;/h3&gt;
+&lt;a href=&quot;#&quot; class=&quot;wp-auth-check-close&quot;&gt;&lt;span class=&quot;screen-reader-text&quot;&gt;' . __('close') . '&lt;/span&gt;&lt;/a&gt;
+&lt;div id=&quot;wp-auth-check-form&quot;&gt;
+        &lt;iframe src=&quot;' . esc_url( add_query_arg( array( 'interim-login' =&gt; 1 ), wp_login_url() ) ) . '&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+&lt;script type=&quot;text/javascript&quot;&gt;
+(function($){
+var el, wrap = $(&quot;#wp-auth-check-notice-wrap&quot;);
+el = $(&quot;#wp-auth-check&quot;).focus().find(&quot;a.wp-auth-check-close&quot;).on(&quot;click&quot;, function(e){
+        el.fadeOut(200, function(){ wrap.remove(); });
+        e.preventDefault();
+});
+$(&quot;#wp-auth-check-form iframe&quot;).load(function(){
+        var height;
+        try { height = $(this.contentWindow.document).find(&quot;#login&quot;).height(); } catch(er){}
+        if ( height ) {
+                $(&quot;#wp-auth-check&quot;).css(&quot;max-height&quot;, height + 40 + &quot;px&quot;);
+                $(this).css(&quot;height&quot;, height + 5 + &quot;px&quot;);
+                if ( height &lt; 200 ) {
+                        wrap.data(&quot;logged-in&quot;, true);
+                        setTimeout( function(){ wrap.fadeOut(200, function(){ wrap.remove(); }); }, 5000 );
+                }
+        }
+});
+}(jQuery));
+&lt;/script&gt;
+&lt;/div&gt;';
+
+        }
+}
+
</ins><span class="cx">Property changes on: trunk/wp-includes/class-wp-auth-check.php
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkwpincludesdefaultfiltersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-filters.php (23503 => 23504)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-filters.php        2013-02-28 07:40:11 UTC (rev 23503)
+++ trunk/wp-includes/default-filters.php        2013-02-28 08:57:17 UTC (rev 23504)
</span><span class="lines">@@ -294,4 +294,7 @@
</span><span class="cx"> // Default settings for heartbeat
</span><span class="cx"> add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' );
</span><span class="cx"> 
</span><ins>+// Check if the user is logged out
+add_action( 'admin_init', 'wp_auth_check_load' );
+
</ins><span class="cx"> unset($filter, $action);
</span></span></pre></div>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (23503 => 23504)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2013-02-28 07:40:11 UTC (rev 23503)
+++ trunk/wp-includes/functions.php        2013-02-28 08:57:17 UTC (rev 23504)
</span><span class="lines">@@ -3883,4 +3883,18 @@
</span><span class="cx">  */
</span><span class="cx"> function wp_checkdate( $month, $day, $year, $source_date ) {
</span><span class="cx">         return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
+
+/**
+ * Load the auth check, for monitoring whether the user is still logged in
+ *
+ * @since 3.6.0
+ *
+ * @return void
+ */
+function wp_auth_check_load() {
+        if ( ! class_exists('WP_Auth_Check') ) {
+                require( ABSPATH . WPINC . '/class-wp-auth-check.php' );
+                WP_Auth_Check::get_instance();
+        }
+}
</ins></span></pre></div>
<a id="trunkwploginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-login.php (23503 => 23504)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-login.php        2013-02-28 07:40:11 UTC (rev 23503)
+++ trunk/wp-login.php        2013-02-28 08:57:17 UTC (rev 23504)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">         $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );
</span><span class="cx">         $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
</span><span class="cx"> 
</span><del>-        if ( $shake_error_codes &amp;&amp; $wp_error-&gt;get_error_code() &amp;&amp; in_array( $wp_error-&gt;get_error_code(), $shake_error_codes ) )
</del><ins>+        if ( ! $interim_login &amp;&amp; $shake_error_codes &amp;&amp; $wp_error-&gt;get_error_code() &amp;&amp; in_array( $wp_error-&gt;get_error_code(), $shake_error_codes ) )
</ins><span class="cx">                 add_action( 'login_head', 'wp_shake_js', 12 );
</span><span class="cx"> 
</span><span class="cx">         ?&gt;&lt;!DOCTYPE html&gt;
</span><span class="lines">@@ -82,16 +82,19 @@
</span><span class="cx">         $login_header_url   = apply_filters( 'login_headerurl',   $login_header_url   );
</span><span class="cx">         $login_header_title = apply_filters( 'login_headertitle', $login_header_title );
</span><span class="cx"> 
</span><del>-        // Don't allow interim logins to navigate away from the page.
-        if ( $interim_login )
-                $login_header_url = '#';
-
</del><span class="cx">         $classes = array( 'login-action-' . $action, 'wp-core-ui' );
</span><span class="cx">         if ( wp_is_mobile() )
</span><span class="cx">                 $classes[] = 'mobile';
</span><span class="cx">         if ( is_rtl() )
</span><span class="cx">                 $classes[] = 'rtl';
</span><ins>+        if ( $interim_login ) {
+                // Don't allow interim logins to navigate away from the page.
+                $login_header_url = '#';
+                $classes[] = 'interim-login';
+        }
+
</ins><span class="cx">         $classes = apply_filters( 'login_body_class', $classes, $action );
</span><ins>+
</ins><span class="cx">         ?&gt;
</span><span class="cx">         &lt;/head&gt;
</span><span class="cx">         &lt;body class=&quot;login &lt;?php echo esc_attr( implode( ' ', $classes ) ); ?&gt;&quot;&gt;
</span><span class="lines">@@ -613,12 +616,6 @@
</span><span class="cx">                 if ( $interim_login ) {
</span><span class="cx">                         $message = '&lt;p class=&quot;message&quot;&gt;' . __('You have logged in successfully.') . '&lt;/p&gt;';
</span><span class="cx">                         login_header( '', $message ); ?&gt;
</span><del>-
-                        &lt;?php if ( ! $customize_login ) : ?&gt;
-                        &lt;script type=&quot;text/javascript&quot;&gt;setTimeout( function(){window.close()}, 8000);&lt;/script&gt;
-                        &lt;p class=&quot;alignright&quot;&gt;
-                        &lt;input type=&quot;button&quot; class=&quot;button-primary&quot; value=&quot;&lt;?php esc_attr_e('Close'); ?&gt;&quot; onclick=&quot;window.close()&quot; /&gt;&lt;/p&gt;
-                        &lt;?php endif; ?&gt;
</del><span class="cx">                         &lt;/div&gt;
</span><span class="cx">                         &lt;?php do_action( 'login_footer' ); ?&gt;
</span><span class="cx">                         &lt;?php if ( $customize_login ) : ?&gt;
</span><span class="lines">@@ -662,7 +659,7 @@
</span><span class="cx">         elseif        ( isset($_GET['checkemail']) &amp;&amp; 'registered' == $_GET['checkemail'] )
</span><span class="cx">                 $errors-&gt;add('registered', __('Registration complete. Please check your e-mail.'), 'message');
</span><span class="cx">         elseif        ( $interim_login )
</span><del>-                $errors-&gt;add('expired', __('Your session has expired. Please log-in again.'), 'message');
</del><ins>+                $errors-&gt;add('expired', __('Please log-in again. You will not move away from this page.'), 'message');
</ins><span class="cx">         elseif ( strpos( $redirect_to, 'about.php?updated' ) )
</span><span class="cx">                 $errors-&gt;add('updated', __( '&lt;strong&gt;You have successfully updated WordPress!&lt;/strong&gt; Please log back in to experience the awesomeness.' ), 'message' );
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>