api_namespace; } /** * Returns the version. * * @return string */ public function get_version() { return $this->api_version; } /** * Register endpoint Routes * * @since 1.0.0 */ public function register_routes() { if ( $this->supports_multiple_endpoints ) { $this->register_router_multiple_methods(); } else { $this->register_router_single_method(); } } /** * Register endpoint route with single method * * @param string $methods The endpoint's methods. * @param string $endpoint_callback The endpoint's callback. * * @since 1.0.13 */ public function register_router_single_method( $methods = '', $endpoint_callback = '' ) { $namespace = $this->api_namespace . $this->api_version; $endpoint_callback = empty( $endpoint_callback ) ? $this->endpoint_callback : $endpoint_callback; register_rest_route( $namespace, '/' . $this->base, array( array( 'methods' => empty( $methods ) ? $this->methods : $methods, 'callback' => array( $this, $endpoint_callback ), 'permission_callback' => array( $this, 'permissions_check' ), ), ) ); } /** * Register endpoint route with multiple methods * * @since 1.0.13 */ public function register_router_multiple_methods() { foreach ( $this->endpoint_callbacks_map as $callback => $method ) { $this->register_router_single_method( $method, $callback ); } } /** * Authenticate request * * @since 1.0.0 * * @param WP_REST_Request $request The request. * * @return boolean */ public function permissions_check( WP_REST_Request $request ) { return current_user_can( 'manage_woocommerce' ); } }