| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/INFRABIKEDE/wp-content/plugins/weglot/src/actions/admin/ |
Upload File : |
<?php
namespace WeglotWP\Actions\Admin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WeglotWP\Models\Hooks_Interface_Weglot;
use WeglotWP\Services\User_Api_Service_Weglot;
class Ajax_User_Info implements Hooks_Interface_Weglot {
/**
* @var User_Api_Service_Weglot
*/
private $user_services;
public function __construct() {
$this->user_services = weglot_get_service( 'User_Api_Service_Weglot' );
}
/**
* @see Hooks_Interface_Weglot
*
* @since 3.0.0
* @return void
*/
public function hooks() {
if ( ! is_admin() ) {
return;
}
add_action( 'wp_ajax_get_user_info', array( $this, 'get_user_info' ) ); // @phpstan-ignore-line
}
/**
* @since 3.0.0
* @return array
*/
public function get_user_info() {
if ( ! isset( $_POST['api_key'] ) ) { //phpcs:ignore
wp_send_json_error();
return;
}
$api_key = sanitize_title( $_POST['api_key'] ); //phpcs:ignore
$response = $this->user_services->get_user_info( $api_key );
if ( array_key_exists( 'not_exist', $response ) && ! $response['not_exist'] ) {
wp_send_json_error();
return;
}
wp_send_json_success( $response );
}
}