Server : Apache System : Linux ls31.server.ly 3.10.0-962.3.2.lve1.5.68.el7.x86_64 #1 SMP Wed Apr 6 11:12:23 UTC 2022 x86_64 User : medchoco ( 2906) PHP Version : 8.3.16 Disable Function : mail Directory : /home/medchoco/www/wp-content/plugins/jetpack-boost-git/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; } }