gate = $gate; } protected function getGate(): FeatureGate { return $this->gate; } /** * Register REST API routes. */ public function registerRoutes(): void { register_rest_route( self::NAMESPACE, '/appearance/theme', array( 'methods' => 'GET', 'callback' => array( $this, 'get_theme' ), 'permission_callback' => array( $this, 'check_read_permission' ), ) ); register_rest_route( self::NAMESPACE, '/appearance/theme-assets', array( 'methods' => 'GET', 'callback' => array( $this, 'get_theme_assets' ), 'permission_callback' => array( $this, 'check_read_permission' ), ) ); } /** * GET /appearance/theme. * * @param WP_REST_Request $request Request. * @return WP_REST_Response */ public function get_theme( WP_REST_Request $request ): WP_REST_Response { $limited = $this->guardRateLimit( $request ); if ( $limited ) { return $limited; } return ApiResponse::success( ThemeStyles::get() ); } /** * GET /appearance/theme-assets: what a page of the active theme loads, for the preview frame. * * @param WP_REST_Request $request Request. * @return WP_REST_Response */ public function get_theme_assets( WP_REST_Request $request ): WP_REST_Response { $limited = $this->guardRateLimit( $request ); if ( $limited ) { return $limited; } return ApiResponse::success( ThemePreviewAssets::collect() ); } }