diff --git a/wp-includes/class-wp-auth-check.php b/wp-includes/class-wp-auth-check.php deleted file mode 100644 index ca248b3bc6..0000000000 --- a/wp-includes/class-wp-auth-check.php +++ /dev/null @@ -1,183 +0,0 @@ -_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) && ( ! isset( $_COOKIE[LOGGED_IN_COOKIE] ) || ! wp_validate_auth_cookie() || ! empty( $GLOBALS['login_grace_period'] ) ) ) - $response['wp-auth-check-html'] = $this->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->notice(); - - return $response; - } - - public function footer_js() { - ?> - - - -
- -'; - - } -} - diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 4561ebecf7..1190a366f7 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3894,8 +3894,129 @@ function wp_checkdate( $month, $day, $year, $source_date ) { * @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(); + 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() { + ?> + + '