Action
uncanny-automator
automator_app_settings_{$id}_before_{$status}_panel_content
Fires before rendering the content of a specific application settings panel for a given status.
add_action( 'automator_app_settings_{$id}_before_{$status}_panel_content', $callback, 10, 1 );
Description
Fires before the connection status specific panel content for an integration's settings panel. Developers can use this hook to output custom content, meta boxes, or modify the layout before the default connected or disconnected panel content is rendered. It allows for pre-content actions within the settings interface.
Usage
add_action( 'automator_app_settings_{$id}_before_{$status}_panel_content', 'your_function_name', 10, 1 );
Parameters
-
$this(mixed) - This parameter represents the current object instance of the integration being displayed in the settings panel.
Examples
/**
* Example function to add custom content before the settings panel content for a specific integration.
*
* This function is hooked to 'automator_app_settings_{$id}_before_{$status}_panel_content'
* to inject custom HTML or perform actions before the main settings panel content is rendered.
*
* @param object $integration_instance The instance of the integration object for which settings are being displayed.
*/
add_action( 'automator_app_settings_google_drive_before_connected_panel_content', function( $integration_instance ) {
// Check if the passed object is indeed an instance of the expected integration class.
// Replace 'Your_Google_Drive_Integration_Class' with the actual class name if known.
if ( ! is_a( $integration_instance, 'Your_Google_Drive_Integration_Class' ) ) {
return;
}
// You can access properties or methods of the integration instance here.
// For example, let's assume there's a method to get the current user's connected status.
$user_google_status = $integration_instance->get_user_google_connection_status();
if ( ! $user_google_status ) {
?>
<div class="automator-warning notice notice-warning">
<p><?php esc_html_e( 'Your Google Drive connection is not fully established. Some features might not be available until it's resolved.', 'your-text-domain' ); ?></p>
</div>
<?php
}
// Example: Display a link to re-authenticate if the connection is stale.
// Assuming a method like 'get_reauthentication_url()' exists.
$reauth_url = $integration_instance->get_reauthentication_url();
if ( $reauth_url ) {
?>
<div class="automator-info notice notice-info">
<p><?php echo wp_kses_post( sprintf( __( 'Your Google Drive connection might be outdated. <a href="%s">Click here to re-authenticate</a>.', 'your-text-domain' ), esc_url( $reauth_url ) ) ); ?></p>
</div>
<?php
}
}, 10, 1 ); // Priority 10, accepts 1 argument
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/lib/settings/trait-premium-integration-templating.php:159
public function output_panel_content() {
// Dynamic hook status key.
$status = $this->get_hook_status_key();
$id = $this->get_id();
// Hook before main content based on integration and connection status.
do_action( "automator_app_settings_{$id}_before_{$status}_panel_content", $this );
// Output main content based on connection status
if ( $this->is_connected ) {
$this->output_main_connected_content();
} else {
$this->output_main_disconnected_content();
}
// Hook after main content based on integration and connection status.
do_action( "automator_app_settings_{$id}_after_{$status}_panel_content", $this );
}