Skip to content

Request Lifecycle ​

Bootstrap ​

  1. WordPress loads active plugins and fires plugins_loaded.
  2. WP Social Ninja boots the Application and fires wp_social_reviews_loaded / wp_social_reviews_loaded_v2 with the container.
  3. On rest_api_init, the framework registers all routes by loading app/Http/Routes/routes.php, which requires api.php.

Route registration ​

Routes are declared in app/Http/Routes/api.php against the $router (WPSocialReviews\Framework\Http\Router). Each group carries a URL prefix and a policy:

php
$router->prefix('platforms')->withPolicy('PlatformPolicy')->group(function ($router) {
    $router->get('/', [PlatformController::class, 'index']);
    $router->post('/update-statuses', [PlatformController::class, 'updateStatuses']);

    $router->prefix('reviews')->group(function ($router) {
        $router->get('/configs',  [ReviewsConfigsController::class, 'index']);
        $router->post('/configs', [ReviewsConfigsController::class, 'store']);
    });
});

The router registers each route with WordPress under the REST namespace wpsocialreviews/v2 (from config/app.php), so the example above resolves to:

GET  /wp-json/wpsocialreviews/v2/platforms
POST /wp-json/wpsocialreviews/v2/platforms/update-statuses
GET  /wp-json/wpsocialreviews/v2/platforms/reviews/configs

Authorization ​

Before the controller runs, the group's policy authorizes the request (PlatformPolicy, AdminPolicy, etc.). A failing policy short-circuits with an error response. See Policies & Authorization.

Dispatch ​

The router dispatches to the [Controller::class, 'method'] handler. Controllers extend the framework Controller, read input from the injected request, call platform services and models, and return a response (typically JSON).

Data & rendering ​

  • Services (app/Services/Platforms/…) fetch and normalize platform data, apply caching, and persist to the wpsr_ tables via models.
  • Front-end output is produced separately through shortcodes and PHP views — see Shortcodes.

Summary ​

plugins_loaded → Application boots → wp_social_reviews_loaded(_v2)
rest_api_init  → routes.php → api.php → Router registers routes
HTTP request   → Policy → Controller → Service → Model → Cache/DB → JSON response

WP Social Ninja Developer Documentation