3897 | | if ( ! class_exists('WP_Auth_Check') ) { |
3898 | | require( ABSPATH . WPINC . '/class-wp-auth-check.php' ); |
3899 | | WP_Auth_Check::get_instance(); |
| 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 ); |
| 3900 | } |
| 3901 | |
| 3902 | /** |
| 3903 | * Check whether a user is still logged in, and act accordingly if not. |
| 3904 | * |
| 3905 | * @since 3.6.0 |
| 3906 | */ |
| 3907 | function wp_auth_check( $response, $data ) { |
| 3908 | if ( ! isset( $data['wp-auth-check'] ) ) |
| 3909 | return $response; |
| 3910 | |
| 3911 | // If the user is logged in and we are outside the login grace period, bail. |
| 3912 | if ( is_user_logged_in() && empty( $GLOBALS['login_grace_period'] ) ) |
| 3913 | return $response; |
| 3914 | |
| 3915 | return array_merge( $response, array( |
| 3916 | 'wp-auth-check-html' => '<div id="wp-auth-check-notice-wrap"> |
| 3917 | <style type="text/css" scoped> |
| 3918 | #wp-auth-check { |
| 3919 | position: fixed; |
| 3920 | height: 90%; |
| 3921 | left: 50%; |
| 3922 | max-height: 415px; |
| 3923 | overflow: auto; |
| 3924 | top: 35px; |
| 3925 | width: 300px; |
| 3926 | margin: 0 0 0 -160px; |
| 3927 | padding: 12px 20px; |
| 3928 | border: 1px solid #ddd; |
| 3929 | background-color: #fbfbfb; |
| 3930 | -webkit-border-radius: 3px; |
| 3931 | border-radius: 3px; |
| 3932 | z-index: 1000000000; |
| 3933 | } |
| 3934 | #wp-auth-check-form { |
| 3935 | background: url("' . admin_url('/images/wpspin_light-2x.gif') . '") no-repeat center center; |
| 3936 | background-size: 16px 16px; |
| 3937 | } |
| 3938 | #wp-auth-check-form iframe { |
| 3939 | height: 100%; |
| 3940 | overflow: hidden; |
| 3941 | } |
| 3942 | #wp-auth-check a.wp-auth-check-close { |
| 3943 | position: absolute; |
| 3944 | right: 8px; |
| 3945 | top: 8px; |
| 3946 | width: 24px; |
| 3947 | height: 24px; |
| 3948 | background: url("' . includes_url('images/uploader-icons.png') . '") no-repeat scroll -95px center transparent; |
| 3949 | } |
| 3950 | #wp-auth-check h3 { |
| 3951 | margin: 0 0 12px; |
| 3952 | padding: 0; |
| 3953 | font-size: 1.25em; |
| 3954 | } |
| 3955 | @media print, |
| 3956 | (-o-min-device-pixel-ratio: 5/4), |
| 3957 | (-webkit-min-device-pixel-ratio: 1.25), |
| 3958 | (min-resolution: 120dpi) { |
| 3959 | #wp-auth-check a.wp-auth-check-close { |
| 3960 | background-image: url("' . includes_url('images/uploader-icons-2x.png') . '"); |
| 3961 | background-size: 134px 15px; |
| 3964 | </style> |
| 3965 | <div id="wp-auth-check" tabindex="0"> |
| 3966 | <h3>' . __('Session expired') . '</h3> |
| 3967 | <a href="#" class="wp-auth-check-close"><span class="screen-reader-text">' . __('close') . '</span></a> |
| 3968 | <div id="wp-auth-check-form"> |
| 3969 | <iframe src="' . esc_url( add_query_arg( array( 'interim-login' => 1 ), wp_login_url() ) ) . '" frameborder="0"></iframe> |
| 3970 | </div> |
| 3971 | </div> |
| 3972 | <script type="text/javascript"> |
| 3973 | (function($){ |
| 3974 | var el, wrap = $("#wp-auth-check-notice-wrap"); |
| 3975 | el = $("#wp-auth-check").focus().find("a.wp-auth-check-close").on("click", function(e){ |
| 3976 | el.fadeOut(200, function(){ wrap.remove(); }); |
| 3977 | e.preventDefault(); |
| 3978 | }); |
| 3979 | $("#wp-auth-check-form iframe").load(function(){ |
| 3980 | var height; |
| 3981 | try { height = $(this.contentWindow.document).find("#login").height(); } catch(er){} |
| 3982 | if ( height ) { |
| 3983 | $("#wp-auth-check").css("max-height", height + 40 + "px"); |
| 3984 | $(this).css("height", height + 5 + "px"); |
| 3985 | if ( height < 200 ) { |
| 3986 | wrap.data("logged-in", true); |
| 3987 | setTimeout( function(){ wrap.fadeOut(200, function(){ wrap.remove(); }); }, 5000 ); |
| 3988 | } |
| 3989 | } |
| 3990 | }); |
| 3991 | }(jQuery)); |
| 3992 | </script> |
| 3993 | </div>' ) ); |
| 3994 | } |