Filter: wpd_ai_child_page_register
Register or modify child (sub) pages under the Alpha Insights admin menu.
Description
The admin menu builder collects child pages (submenu items) and sorts them by menu_position. This filter receives the array of child page definitions so you can add new subpages or change existing ones. Each child page must have at least page_title, menu_title, menu_slug, and page_callback.
Location
File: includes/classes/WPDAI_Admin_Menu.php
Context: When building the admin menu (before sorting and loading child pages).
Parameters
| Parameter | Type | Description |
|---|---|---|
| $child_pages | array | Array of child page arrays. Each item typically has page_title, menu_title, menu_slug, page_callback, and optionally menu_position (numeric; lower first). |
Return
Type: array
The (possibly modified) array of child page definitions.
Example Usage
Add a custom subpage
add_filter( 'wpd_ai_child_page_register', 'add_my_alpha_child_page' );
function add_my_alpha_child_page( $child_pages ) {
$child_pages[] = array(
'page_title' => __( 'My Extension', 'alpha-insights-pro' ),
'menu_title' => __( 'My Extension', 'alpha-insights-pro' ),
'menu_slug' => 'alpha-insights-my-extension',
'page_callback' => 'my_extension_render_page',
'menu_position' => 50,
);
return $child_pages;
}
function my_extension_render_page() {
echo '<p>' . esc_html__( 'My custom page content.', 'alpha-insights-pro' ) . '</p>';
}
Remove a built-in subpage
add_filter( 'wpd_ai_child_page_register', 'remove_alpha_child_page' );
function remove_alpha_child_page( $child_pages ) {
return array_filter( $child_pages, function( $page ) {
return ( isset( $page['menu_slug'] ) && $page['menu_slug'] !== 'page-to-remove' );
} );
}
Related Filters
- wpd_alpha_insights_menu_items – Modify menu items structure
- wpd_alpha_insights_menu_html – Modify menu HTML output