File "Geolocation_Controller.php"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/better-wp-security/core/lib/rest/Geolocation_Controller.php
File size: 721 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace iThemesSecurity\Lib\REST;

class Geolocation_Controller extends \WP_REST_Controller {

	protected $namespace = 'ithemes-security/v1';
	protected $rest_base = 'geolocate';

	public function register_routes() {
		register_rest_route( $this->namespace, $this->rest_base . '/(?P<ip>.+)', [
			[
				'methods'             => \WP_REST_Server::READABLE,
				'callback'            => [ $this, 'get_item' ],
				'permission_callback' => 'ITSEC_Core::current_user_can_manage',
				'args'                => [
					'ip' => [
						'type'   => 'string',
						'format' => 'ip',
					],
				],
			],
		] );
	}

	public function get_item( $request ) {
		return \ITSEC_Lib_Geolocation::geolocate( $request['ip'] );
	}
}