Action uncanny-automator

automator_app_settings_{$id}_before_{$status}_panel

Hook before panel output. Fires before a specific app settings panel is displayed, allowing modification of its content or behavior.

add_action( 'automator_app_settings_{$id}_before_{$status}_panel', $callback, 10, 1 );

Description

Fires before an integration's settings panel is output for a specific status. Developers can use this hook to inject custom content or perform actions immediately before the panel's default HTML is rendered, allowing for pre-panel modifications or data preparation.


Usage

add_action( 'automator_app_settings_{$id}_before_{$status}_panel', 'your_function_name', 10, 1 );

Parameters

$this (App_Integration_Settings)
The integration settings instance.

Examples

add_action( 'automator_app_settings_my_custom_app_before_active_panel', 'my_custom_app_before_active_panel_logic', 10, 1 );

/**
 * Adds extra settings or modifies the output before the 'active' panel for a specific app.
 *
 * This function demonstrates how to hook into the automator_app_settings_{$id}_before_{$status}_panel
 * action to inject custom HTML or logic. In this example, it adds a warning message
 * to the 'active' panel of an app with the ID 'my_custom_app'.
 *
 * @param App_Integration_Settings $settings The integration settings instance.
 */
function my_custom_app_before_active_panel_logic( App_Integration_Settings $settings ) {
    // Assume $settings->get_id() would return 'my_custom_app' in this context.
    // We can check for specific app IDs if needed, though the hook itself is dynamic.

    // Example: Add a custom warning message if certain conditions are met.
    $user_has_premium = false; // Replace with actual logic to check user's premium status
    if ( ! $user_has_premium ) {
        echo '<div class="uap-notice uap-notice-warning">
                <p><strong>Note:</strong> Advanced features for this app require a premium subscription.</p>
              </div>';
    }

    // Example: Output a specific setting field before the default panel content.
    // This assumes the App_Integration_Settings class has a method to output custom fields.
    // For a real scenario, you'd likely have a dedicated method or access to settings data.
    // Let's simulate outputting a simple text field for an API key.
    $api_key_value = $settings->get_setting( 'my_api_key', '' ); // Get saved API key
    ?>
    <div class="uap-settings-field">
        <label for="my_api_key_input">Custom API Key:</label>
        <input type="text" id="my_api_key_input" name="my_api_key" value="<?php echo esc_attr( $api_key_value ); ?>" class="uap-input">
        <p class="uap-description">Enter your custom API key to enable full integration.</p>
    </div>
    <?php
}

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:95

public function output_panel() {

		// Dynamic hook status key.
		$status = $this->get_hook_status_key();
		$id     = $this->get_id();

		/**
		 * Hook before panel output.
		 *
		 * @param App_Integration_Settings $this The integration settings instance.
		 */
		do_action( "automator_app_settings_{$id}_before_{$status}_panel", $this );

		?>
		<div class="uap-settings-panel">
			<div class="uap-settings-panel-top">
				<?php $this->output_panel_top(); ?>
				<?php $this->display_alerts(); ?>
				<div class="uap-settings-panel-content">
					<?php $this->output_panel_content(); ?>
				</div>
			</div>
			<div class="uap-settings-panel-bottom"<?php echo $this->should_show_connect_arrow() ? ' has-arrow' : ''; ?>>
				<?php $this->output_panel_bottom(); ?>
			</div>
		</div>
		<?php
		/**
		 * Hook after panel output.
		 *
		 * @param App_Integration_Settings $this The integration settings instance.
		 */
		do_action( "automator_app_settings_{$id}_after_{$status}_panel", $this );
	}


Scroll to Top