$config['callback'], 'args' => $config['args'] ?? array(), 'method' => $config['method'] ?? WP_REST_Server::READABLE, ); } /** * Register all collected add-on endpoints with WordPress REST API. * * Called on rest_api_init. * * @since 1.0.0 * * @return void */ public static function register_routes(): void { foreach ( self::$endpoints as $slug => $config ) { register_rest_route( 'wlconduit/v1', '/ext/' . sanitize_title( $slug ), array( 'methods' => $config['method'], 'callback' => $config['callback'], 'permission_callback' => array( static::class, 'check_permission' ), 'args' => $config['args'], ) ); } } /** * Permission check — enforced for all add-on endpoints. * * @since 1.0.0 * * @return bool */ public static function check_permission(): bool { return current_user_can( 'manage_wlconduit_tools' ); } }