Created
November 18, 2021 15:59
-
-
Save richaber/07c6aeb1261f6a4189137aabe87edd30 to your computer and use it in GitHub Desktop.
Local By Flywheel v 6.1.5+5536 (macO) bootstrap file located at /Applications/Local.app/Contents/Resources/extraResources/local-bootstrap.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is a PHP script that is auto-added to Local's PHP Lightning Service php.ini's | |
* via auto_prepend_script to add relevant constants. | |
* | |
* @copyright Copyright (c) 2020, WP Engine | |
*/ | |
define( 'WP_ENVIRONMENT_TYPE', 'local' ); | |
function localwp_auto_login() { | |
/** | |
* Do not auto-login if X-Original-Host header is present. | |
* | |
* This prevents auto login from being used over Live Links Pro. | |
*/ | |
if ( !empty( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) ) { | |
return; | |
} | |
if ( empty( $_GET['localwp_auto_login'] ) ) { | |
return; | |
} | |
if ( ! function_exists( 'wp_set_auth_cookie' ) ) { | |
return; | |
} | |
$admin_id = $_GET['localwp_auto_login']; | |
$user = get_user_by( 'id', $admin_id ); | |
if ( ! is_wp_error( $user ) ) { | |
wp_clear_auth_cookie(); | |
wp_set_current_user( $user->ID ); | |
wp_set_auth_cookie( $user->ID, false, is_ssl() ); | |
do_action( 'wp_login', $user->user_login, $user ); | |
$redirect_to = user_admin_url(); | |
wp_safe_redirect( $redirect_to ); | |
exit(); | |
} | |
} | |
$GLOBALS['wp_filter'] = array( | |
'init' => array( | |
10 => array( | |
'localwp_auto_login' => array( | |
'function' => 'localwp_auto_login', | |
'accepted_args' => 1, | |
), | |
), | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment