Filter
uncanny-automator
automator_settings_premium_integrations_tabs
Filters the array of premium integration tabs displayed within the Automator settings, allowing for customization.
add_filter( 'automator_settings_premium_integrations_tabs', $callback, 10, 1 );
Description
Filters the array of premium integration tabs displayed in the Automator settings. Developers can use this to add, remove, or modify tabs for custom premium integrations before they are rendered on the page.
Usage
add_filter( 'automator_settings_premium_integrations_tabs', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Adds a new tab to the "App Integrations" settings page for a custom integration.
*
* @param array $integrations_tabs An array of existing integration tabs.
* @return array The modified array of integration tabs.
*/
function my_custom_automator_integration_tab( $integrations_tabs ) {
// Check if the current user has the capability to manage the integration.
if ( current_user_can( 'manage_options' ) ) {
$integrations_tabs['my_custom_integration'] = array(
'name' => __( 'My Custom App', 'my-text-domain' ),
'description' => __( 'Configure your connection to My Custom App.', 'my-text-domain' ),
'callback' => array( $this, 'render_my_custom_integration_settings' ), // Assuming this method exists in the same class.
);
}
return $integrations_tabs;
}
add_filter( 'automator_settings_premium_integrations_tabs', 'my_custom_automator_integration_tab', 10, 1 );
// Assuming 'render_my_custom_integration_settings' is a method within the same class.
// This method would be responsible for outputting the HTML for the settings of your custom integration.
// For example:
/*
public function render_my_custom_integration_settings() {
// Output your custom integration's settings form here.
echo '<p>' . __( 'Settings for My Custom App integration.', 'my-text-domain' ) . '</p>';
// ... more settings fields ...
}
*/
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/core/admin/admin-settings/tabs/premium-integrations.php:42
public function tab_output() {
// Get the tabs
$integrations_tabs = apply_filters( 'automator_settings_premium_integrations_tabs', array() );
// Get the current tab
$current_integration = automator_filter_has_var( 'integration' ) ? sanitize_text_field( automator_filter_input( 'integration' ) ) : '';
// Check if the user has access to the premium integrations
// This will be true if the site is connected (Automator Free) or if the
// user has Automator Pro activated
$user_can_use_premium_integrations = Api_Server::is_automator_connected() || is_automator_pro_active();
// Get the link to upgrade to Pro
$upgrade_to_pro_url = add_query_arg(
// UTM
array(
'utm_source' => 'uncanny_automator',
'utm_medium' => 'settings',
'utm_content' => 'premium_integrations_connect',
),
'https://automatorplugin.com/pricing/'
);
// Get the link to the article about credits
$credits_article_url = add_query_arg(
// UTM
array(
'utm_source' => 'uncanny_automator',
'utm_medium' => 'settings',
'utm_content' => 'premium_integrations_connect',
),
'https://automatorplugin.com/knowledge-base/what-are-credits/'
);
// Get the link to connect the site
$connect_site_url = add_query_arg(
array(
'post_type' => AUTOMATOR_POST_TYPE_RECIPE,
'page' => 'uncanny-automator-setup-wizard',
),
admin_url( 'edit.php' )
);
// Check if the user is requesting the focus version
$layout_version = automator_filter_has_var( 'automator_hide_settings_tabs' ) ? 'focus' : 'default';
// Add the actions and get the selected tab
foreach ( $integrations_tabs as $tab_key => &$tab ) {
// Ensure the tab is an object.
$tab = (object) $tab;
// Maybe add an action to show the settings for a tab.
$this->maybe_add_action_to_show_settings( $tab_key, $tab, $user_can_use_premium_integrations );
// Set the selected state.
$tab->is_selected = ! $user_can_use_premium_integrations && $tab->requires_credits
? false
: $tab_key === $current_integration;
if ( $tab_key === $current_integration ) {
$current_integration_tab = $tab;
}
}
// Load the view
include Utilities::automator_get_view( 'admin-settings/tab/premium-integrations.php' );
}
Internal Usage
Found in src/core/lib/settings/trait-premium-integrations.php:394:
add_filter( 'automator_settings_premium_integrations_tabs', array( $this, 'add_tab' ) );
Found in src/core/lib/settings/premium-integration-settings.php:160:
add_filter( 'automator_settings_premium_integrations_tabs', array( $this, 'add_tab' ) );