Action
Dynamic
uncanny-automator
automator_settings_{dynamic}_tab
> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Fires when a specific dynamic tab within Automator settings is displayed, allowing for customization.
add_action( 'automator_settings_{dynamic}_tab', $callback, 10, 1 );
Description
Fires when a specific settings tab is rendered. Use this dynamic hook to inject custom content or functionality into individual settings tabs within the plugin's administration area. The `$tab_key` variable in the hook name represents the unique identifier of the current tab.
Usage
add_action( 'automator_settings_{dynamic}_tab', 'your_function_name', 10, 1 );
Examples
add_action( 'automator_settings_general_tab', 'my_automator_add_custom_settings_to_general_tab', 10, 0 );
/**
* Adds custom fields to the 'General' settings tab in the Automator plugin.
*
* This function demonstrates how to hook into the `automator_settings_{dynamic}_tab`
* action to inject custom HTML content into specific settings tabs. In this case,
* we're adding a simple text input field to the 'General' tab for demonstration.
*
* @since 1.0.0
*/
function my_automator_add_custom_settings_to_general_tab() {
?>
<div class="automator-custom-setting">
<label for="my_custom_automator_setting">My Custom Setting:</label>
<input type="text" id="my_custom_automator_setting" name="my_custom_automator_setting" value="<?php echo esc_attr( get_option( 'my_custom_automator_setting', '' ) ); ?>">
<p class="description">Enter a value for your custom Automator setting.</p>
</div>
<?php
}
// Example of saving the custom setting (this would typically be in a separate save function hooked to `admin_init` or similar)
add_action( 'admin_init', 'my_automator_save_custom_settings' );
function my_automator_save_custom_settings() {
if ( isset( $_POST['my_custom_automator_setting'] ) ) {
update_option( 'my_custom_automator_setting', sanitize_text_field( $_POST['my_custom_automator_setting'] ) );
}
}
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/views/admin-settings/admin-settings.php:114
// IF the tab is selected, then add the "active" attribute
echo $setting_tab->is_selected ? 'active' : '';
?>
>
<?php do_action( 'automator_settings_' . $tab_key . '_tab' ); ?>
</uo-tab-panel>
<?php
}
}