<!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>[23543] trunk/wp-includes: Logged out warnings: restructure the PHP code (no need for a class), props nacin, 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/23543">23543</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2013-03-01 01:55:33 +0000 (Fri, 01 Mar 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Logged out warnings: restructure the PHP code (no need for a class), props nacin, see <a href="http://core.trac.wordpress.org/ticket/23295">#23295</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
</ul>

<h3>Removed 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="trunkwpincludesclasswpauthcheckphp"></a>
<div class="delfile"><h4>Deleted: trunk/wp-includes/class-wp-auth-check.php (23542 => 23543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-auth-check.php        2013-02-28 22:58:40 UTC (rev 23542)
+++ trunk/wp-includes/class-wp-auth-check.php        2013-03-01 01:55:33 UTC (rev 23543)
</span><span class="lines">@@ -1,183 +0,0 @@
</span><del>-&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();
-
-                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();
-
-                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;';
-
-        }
-}
-
</del></span></pre></div>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (23542 => 23543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2013-02-28 22:58:40 UTC (rev 23542)
+++ trunk/wp-includes/functions.php        2013-03-01 01:55:33 UTC (rev 23543)
</span><span class="lines">@@ -3894,8 +3894,129 @@
</span><span class="cx">  * @return void
</span><span class="cx">  */
</span><span class="cx"> function wp_auth_check_load() {
</span><del>-        if ( ! class_exists('WP_Auth_Check') ) {
-                require( ABSPATH . WPINC . '/class-wp-auth-check.php' );
-                WP_Auth_Check::get_instance();
</del><ins>+        wp_enqueue_script( 'heartbeat' );
+        add_filter( 'heartbeat_received', 'wp_auth_check', 10, 2 );
+        add_filter( 'heartbeat_nopriv_received', 'wp_auth_check', 10, 2 );
+
+        if ( is_admin() )
+                add_action( 'admin_print_footer_scripts', 'wp_auth_check_js' );
+        elseif ( is_user_logged_in() )
+                add_action( 'wp_print_footer_scripts', 'wp_auth_check_js' );
+}
+
+/**
+ * Output the JS that shows the wp-login iframe when the user is no longer logged in
+ */ 
+function wp_auth_check_js() {
+        ?&gt;
+        &lt;script type=&quot;text/javascript&quot;&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
+}
+
+/**
+ * Check whether a user is still logged in, and act accordingly if not.
+ *
+ * @since 3.6.0
+ */
+function wp_auth_check( $response, $data ) {
+        if ( ! isset( $data['wp-auth-check'] ) )
+                return $response;
+
+        // If the user is logged in and we are outside the login grace period, bail.
+        if ( is_user_logged_in() &amp;&amp; empty( $GLOBALS['login_grace_period'] ) )
+                return $response;
+
+        return array_merge( $response, array(
+                'wp-auth-check-html' =&gt; '&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;
</ins><span class="cx">         }
</span><span class="cx"> }
</span><ins>+&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></pre>
</div>
</div>

</body>
</html>