How to Register Custom Endpoints for CRM Pages

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

FieldTypeDescription
Key (array key)stringURL slug; used as the endpoint identifier (e.g. `MyCrmPage`)
`name`stringHuman-readable label
`callback`stringFully-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',
    ...
);

Manage Cookies

Choose which cookies this website may use. You can change your choice at any time.

Always on

Required for the website to work, for example to keep you signed in, keep your shopping cart and remember this cookie choice. They cannot be switched off.

Analytics, social media connections, live chat and personalized advertising based on your online activity. These are only used if you allow them.