Make WordPress Core

Changeset 24695


Ignore:
Timestamp:
07/12/2013 11:32:32 PM (11 years ago)
Author:
azaozz
Message:

Logged out warnings:

  • Replace the Close button with an always visible "X" icon in the top/right corner.
  • Check if the user is still logged in every 3 min. by default.
  • Add 'wp_auth_check_interval' filter so the interval can be set from PHP.

See #23295.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/wp-admin.css

    r24688 r24695  
    71887188.interim-login #login {
    71897189    padding: 0;
    7190     margin: 25px auto 20px;
     7190    margin: 5px auto 20px;
    71917191}
    71927192
  • trunk/wp-includes/css/wp-auth-check.css

    r23805 r24695  
    2525    top: 40px;
    2626    bottom: 20px;
    27     max-height: 435px;
     27    max-height: 415px;
    2828    width: 380px;
    2929    margin: 0 0 0 -190px;
    30     padding: 0;
     30    padding: 30px 0 0;
    3131    background-color: #fbfbfb;
    3232    -webkit-border-radius: 3px;
     
    4141
    4242#wp-auth-check-wrap #wp-auth-check-form {
    43     background: url('../images/wpspin-2x.gif') no-repeat center center;
     43    background: url(../images/wpspin-2x.gif) no-repeat center center;
    4444    background-size: 16px 16px;
    4545    height: 100%;
     
    5353
    5454#wp-auth-check-wrap .wp-auth-check-close {
    55     bottom: 10px;
    56     display: none;
    5755    position: absolute;
    58     right: 30px;
     56    top: 8px;
     57    right: 8px;
     58    height: 14px;
     59    width: 14px;
     60    cursor: pointer;
     61    background-image: url(../images/uploader-icons.png);
     62    background-repeat: no-repeat;
     63    background-position: -100px 0;
     64}
     65
     66#wp-auth-check-wrap .wp-auth-check-close:focus {
     67    outline: 1px dotted #888;
    5968}
    6069
     
    6675    font-size: 14px;
    6776    line-height: 21px;
    68     padding: 10px 25px;
     77    padding: 0 25px;
    6978    display: none;
    7079}
     
    7584}
    7685
     86@media print,
     87  (-o-min-device-pixel-ratio: 5/4),
     88  (-webkit-min-device-pixel-ratio: 1.25),
     89  (min-resolution: 120dpi) {
     90    #wp-auth-check-wrap .wp-auth-check-close {
     91        background-image: url(../images/uploader-icons-2x.png);
     92        background-size: 134px 15px;
     93    }
     94}
  • trunk/wp-includes/functions.php

    r24594 r24695  
    39443944    <div id="wp-auth-check-bg"></div>
    39453945    <div id="wp-auth-check">
     3946    <div class="wp-auth-check-close" tabindex="0" title="<?php esc_attr_e('Close'); ?>"></div>
    39463947    <?php
    39473948
     
    39583959        <?php _e('The login page will open in a new window. After logging in you can close it and return to this page.'); ?></p>
    39593960    </div>
    3960     <p class="wp-auth-check-close"><a href="#" class="button button-primary"><?php _e('Close'); ?></a></p>
    39613961    </div>
    39623962    </div>
     
    39753975    // If the user is logged in and we are outside the login grace period, bail.
    39763976    if ( is_user_logged_in() && empty( $GLOBALS['login_grace_period'] ) )
    3977         return $response;
    3978 
    3979     return array_merge( $response, array( 'wp-auth-check' => '1' ) );
     3977        return array_merge( $response, array( 'wp-auth-check' => '1' ) );
     3978
     3979    return array_merge( $response, array( 'wp-auth-check' => 'show' ) );
    39803980}
    39813981
  • trunk/wp-includes/js/wp-auth-check.js

    r24655 r24695  
    11// Interim login dialog
    22(function($){
    3     var wrap, check, scheduleTimeout;
     3    var wrap, check, next;
    44
    55    function show() {
     
    3333                        hide();
    3434                    else
    35                         parent.css( 'max-height', height + 60 + 'px' );
     35                        parent.css( 'max-height', height + 40 + 'px' );
    3636                } else if ( ! body || ! body.length ) {
    3737                    // Catch "silent" iframe origin exceptions in WebKit after another page is loaded in the iframe
     
    7575
    7676        wrap.fadeOut( 200, function() {
    77             wrap.addClass('hidden').css('display', '').find('.wp-auth-check-close').css('display', '');
     77            wrap.addClass('hidden').css('display', '');
    7878            $('#wp-auth-check-frame').remove();
    7979        });
     
    8181
    8282    function schedule() {
    83         check = false;
    84         window.clearTimeout( scheduleTimeout );
    85         scheduleTimeout = window.setTimeout( function(){ check = 1; }, 300000 ); // 5 min.
     83        var interval = parseInt( window.authcheckL10n.interval, 10 ) || 180; // in seconds, default 3 min.
     84        next = ( new Date() ).getTime() + ( interval * 1000 );
    8685    }
    8786
    8887    $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
    89         if ( check === 2 )
     88        if ( data['wp-auth-check'] ) {
    9089            schedule();
    9190
    92         if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) {
    93             show();
    94         } else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') ) {
    95             hide();
     91            if ( data['wp-auth-check'] == 'show' && wrap.hasClass('hidden') )
     92                show();
     93            else if ( data['wp-auth-check'] != 'show' && ! wrap.hasClass('hidden') )
     94                hide();
    9695        }
     96    }).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
     97        if ( ( new Date() ).getTime() > next )
     98            data['wp-auth-check'] = 1;
    9799    }).ready( function() {
    98100        schedule();
     
    101103            hide();
    102104        });
    103         // Bind later
    104         $( document ).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
    105             var i, empty = true;
    106             // Check if something is using heartbeat. If yes, trigger the logged out check too.
    107             for ( i in data ) {
    108                 if ( data.hasOwnProperty( i ) ) {
    109                     empty = false;
    110                     break;
    111                 }
    112             }
    113 
    114             if ( check || ! empty )
    115                 data['wp-auth-check'] = 1;
    116 
    117             if ( check )
    118                 check = 2;
    119         });
    120105    });
    121106
  • trunk/wp-includes/script-loader.php

    r24686 r24695  
    114114    did_action( 'init' ) && $scripts->localize( 'wp-auth-check', 'authcheckL10n', array(
    115115        'beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'),
     116        'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ),
    116117    ) );
    117118
Note: See TracChangeset for help on using the changeset viewer.