How to register custom CRM page endpoints and link them to PHP controller classes.
Overview
The `la24_endpoints` filter maps URL slugs to PHP controller classes. When a user navigates to an endpoint in the CRM panel, LA24Core instantiates the mapped controller class and calls its `content()` method to render the page.

Hook Signature
php
apply_filters( 'la24_endpoints', array $endpoints );
**Type:** Filter
**Parameters:** `$endpoints` (array) — the current endpoint registry
**Returns:** array — the modified endpoint registry
Registering an Endpoint
php
add_filter( 'la24_endpoints', function ( $endpoints ) {
$endpoints['MyCrmPage'] = array(
'name' => __( 'CRM Dashboard', 'my-crm-ext' ),
'callback' => '\MyPlugin\Controllers\MyCrmPage',
);
$endpoints['MyCrmReports'] = array(
'name' => __( 'Reports', 'my-crm-ext' ),
'callback' => '\MyPlugin\Controllers\MyCrmReports',
);
return $endpoints;
} );
The controller class at `\MyPlugin\Controllers\MyCrmPage` must extend `BaseViewController`. See the **Building Controllers** guide for the full controller API.
Endpoint Fields
| Field | Type | Description |
|---|---|---|
| Key (array key) | string | URL slug; used as the endpoint identifier (e.g. `MyCrmPage`) |
| `name` | string | Human-readable label |
| `callback` | string | Fully-qualified class name of the controller |
Auto-generated Capability
For every registered endpoint, LA24Core automatically creates a capability named:
javascript
la24_{slug_lowercase}_access
For example, registering `MyCrmPage` creates `la24_mycrmpage_access`. Check this capability inside your controller to enforce access control:
php
if ( ! la24_user_can( get_current_user_id(), 'la24_mycrmpage_access' ) ) {
la24_get_template( 'AccessDenied.php' );
return;
}
Getting an Endpoint URL
Use the helper function to build a URL to any registered endpoint:
php
// Simple URL
$url = la24_get_permalink_panel( 'MyCrmPage' );
// With query args
$url = la24_get_permalink_panel( 'MyCrmPage/?user_id=42' );
This function always returns the correct panel URL regardless of permalink settings.
Linking Menu Items to Endpoints
A menu item registered in `la24_dashboard_menu_items` automatically links to an endpoint when its array key matches the endpoint key:
php
// Endpoint key: 'MyCrmPage'
$endpoints['MyCrmPage'] = array( ... );
// Menu item key also 'MyCrmPage' — they are linked automatically
$menus['MyCrmPage'] = array(
'name' => __( 'CRM Dashboard', 'my-crm-ext' ),
'parent' => 'my_crm_section',
...
);
