let {responce} = await app.ask('browser', {
path: '/tools/urls_info',
method: 'post',
body: {
urls: urls_array
}
});
<?php
defined('ABSPATH') or die("Stop stop stop.. bro!");
/*
Plugin Name: loginME
Description: loginME
Version: 1.0
Author: dima
Author URI: #
Text Domain: loginME
*/
class loginME{
protected static $instance;
public static function init() {
is_null(self::$instance) AND self::$instance = new self;
return self::$instance;
}
public function __construct() {
add_filter('user_row_actions', array( $this, 'user_row_actions'),10,2);
add_action('init', array($this, 'loginME_init'));
add_action("wp_footer", function(){
if(isset($_COOKIE["isUSERCHANGER"])):
?>
<div style="position: fixed;
background-color: #232050;
padding: 5px;
border-radius: 5px;
bottom: 30px;
right: 30px;">
<a style="color: #fff;"
href="<?=home_url();?>/?switch_user=switch_user&user_id=<?=$_COOKIE["admin_id"];?>&clear=<?=$_COOKIE["isUSERCHANGER"];?>">
<div>Назад в админ панель ></div>
</a>
</div>
<?php
endif;
});
}
public function loginME_init() {
add_action('admin_action_switch_user', array( $this, 'switch_user'));
add_filter( 'query_vars', function( $query_vars ){
$query_vars[] = 'switch_user';
return $query_vars;
});
add_action( 'template_redirect', function(){
$switch_user = get_query_var('switch_user');
if($switch_user === 'switch_user'){
if(current_user_can('manage_loginME') || isset($_COOKIE["isUSERCHANGER"])){
$admin_id = 0;
$admin_secret = 0;
if(!isset($_COOKIE["isUSERCHANGER"])){
$admin_id = $GLOBALS['current_user']->data->ID;
$admin_secret = $GLOBALS['current_user']->data->ID.$GLOBALS['current_user']->data->user_pass;
}
$id = (isset($_GET['user_id']) ? $_GET['user_id'] : $_POST['user_id']);
$user = get_user_by( 'id', $id );
if(!isset($_GET['clear'])){
global $current_user;
unset($current_user);
nocache_headers();
wp_clear_auth_cookie();
wp_set_current_user($id, $user->user_login);
do_action( 'wp_login', $user->user_login );
wp_set_auth_cookie($id, true);
if(!isset($_COOKIE["isUSERCHANGER"])){
setcookie("isUSERCHANGER", md5($admin_secret), time()+3600);
setcookie("admin_id", $admin_id, time()+3600);
}
wp_safe_redirect(home_url());
}else{
unset($_COOKIE['isUSERCHANGER']);
setcookie('isUSERCHANGER', null, -1);
unset($_COOKIE['admin_id']);
setcookie('admin_id', null, -1);
global $current_user;
unset($current_user);
nocache_headers();
wp_clear_auth_cookie();
wp_set_current_user($id, $user->user_login);
do_action( 'wp_login', $user->user_login );
wp_set_auth_cookie($id, true);
wp_safe_redirect(admin_url( 'users.php'));
}
die();
}
}
});
}
public function switch_user()
{
$id = (isset($_GET['user_id']) ? $_GET['user_id'] : $_POST['user_id']);
if(isset($id)){
wp_safe_redirect( home_url()."/?switch_user=switch_user&user_id=".$id);
die();
}
}
public function user_row_actions($actions, $user)
{
if(current_user_can('manage_loginME')){
$action_name = "switch_user";
$action = '?action='.$action_name.'&user_id='.$user->ID;
$actions['loginME'] = '<a href="'.admin_url( "admin.php". $action ).'" aria-label="">Авторизация</a>';
}
return $actions;
}
}
register_activation_hook( __FILE__, function (){
$role = get_role( 'administrator' );
$role->add_cap( 'manage_loginME' );
});
register_deactivation_hook( __FILE__, function (){
$role = get_role( 'administrator' );
$role->remove_cap( 'manage_loginME' );
});
add_action('plugins_loaded', array('loginME', 'init'));