| Server IP : 121.121.20.254 / Your IP : 216.73.216.146 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/WPCAFE/wp-content/plugins/jetpack-boost/app/rest-api/ |
Upload File : |
<?php
namespace Automattic\Jetpack_Boost\REST_API;
class Route {
/**
* @var \Automattic\Jetpack_Boost\REST_API\Contracts\Endpoint
*/
protected $endpoint;
protected $permissions;
public function __construct( $endpoint ) {
$this->endpoint = new $endpoint();
$this->permissions = $this->endpoint->permissions();
}
public function register_rest_route() {
register_rest_route(
JETPACK_BOOST_REST_NAMESPACE,
JETPACK_BOOST_REST_PREFIX . '/' . $this->endpoint->name(),
array(
'methods' => $this->endpoint->request_methods(),
'callback' => array( $this->endpoint, 'response' ),
'permission_callback' => array( $this, 'verify_permissions' ),
)
);
}
/**
* This method is going to run and try to verify that
* all the permission callbacks are successful.
*
* If any of them fail - return false immediately.
*
* @param \WP_REST_Request $request
*
* @return bool
*/
public function verify_permissions( $request ) {
foreach ( $this->permissions as $permission ) {
if ( true !== $permission->verify( $request ) ) {
return false;
}
}
return true;
}
}