Filter: wpd_ai_all_integrations_for_display
Filter the merged list of integrations used to render the integrations grid (metadata + instance per slug).
Description
The manager builds a single list for the UI by merging metadata (label, description, logo, category, url) with the registered instance (if any) for each slug. This filter receives that merged array so you can reorder, add, or remove entries before they are output as cards. Each item is array( 'metadata' => array(...), 'instance' => WPDAI_Integration_Base|null ).
Location
File: includes/integrations/WPDAI_Integrations_Manager.php
Method: get_all_integrations_for_display()
Parameters
| Parameter | Type | Description |
|---|---|---|
| $merged | array | Associative array slug => array( ‘metadata’ => array, ‘instance’ => WPDAI_Integration_Base|null ) |
Return
Type: array
The (possibly modified) merged array.
Example Usage
Sort integrations by label
add_filter( 'wpd_ai_all_integrations_for_display', 'sort_integrations_by_label' );
function sort_integrations_by_label( $merged ) {
uasort( $merged, function( $a, $b ) {
$la = isset( $a['metadata']['label'] ) ? $a['metadata']['label'] : '';
$lb = isset( $b['metadata']['label'] ) ? $b['metadata']['label'] : '';
return strcasecmp( $la, $lb );
} );
return $merged;
}
Remove Pro integrations for a specific role
add_filter( 'wpd_ai_all_integrations_for_display', 'hide_pro_integrations_for_editor' );
function hide_pro_integrations_for_editor( $merged ) {
if ( current_user_can( 'editor' ) ) {
foreach ( $merged as $slug => $data ) {
if ( ! empty( $data['metadata']['is_pro'] ) ) {
unset( $merged[ $slug ] );
}
}
}
return $merged;
}
Related
- wpd_ai_registered_integrations – Registered instances
- wpd_ai_integration_metadata – Metadata for cards