Action uncanny-automator

automator_settings_advanced_tab_view

Fires when the advanced tab of Automator settings is viewed, allowing for custom tab content.

add_action( 'automator_settings_advanced_tab_view', $callback, 10, 1 );

Description

Fires within the Uncanny Automator advanced settings tab, specifically for the background actions section. Developers can hook into this action to output custom content or functionality related to background action settings. This hook provides a flexible way to extend the default advanced settings interface.


Usage

add_action( 'automator_settings_advanced_tab_view', 'your_function_name', 10, 1 );

Examples

/**
 * Adds a custom section to the advanced settings tab for background actions.
 *
 * This example demonstrates how to hook into 'automator_settings_advanced_tab_view'
 * to add custom fields or information within the existing "Background actions" section
 * of the Uncanny Automator advanced settings.
 *
 * @param mixed $settings_group The current settings group being processed.
 */
function my_automator_add_advanced_background_settings( $settings_group ) {
	// Ensure this hook is only processed for the correct settings group, if applicable.
	// In this case, 'self::SETTINGSGROUP' is passed, so we can assume it's the intended group.
	// If there were multiple groups, you might check: if ( 'my_specific_group' !== $settings_group ) return;

	?>
	<div class="uap-settings-panel-row">
		<div class="uap-settings-panel-label">
			<label for="my_custom_background_setting"><?php esc_html_e( 'Custom Background Task Interval (minutes)', 'your-text-domain' ); ?></label>
		</div>
		<div class="uap-settings-panel-input">
			<input type="number"
				   id="my_custom_background_setting"
				   name="automator_settings[my_custom_background_setting]"
				   value="<?php echo esc_attr( get_option( 'my_custom_background_setting', 5 ) ); ?>"
				   min="1"
				   step="1">
			<p class="uap-settings-panel-description"><?php esc_html_e( 'Set how often your custom background tasks should run.', 'your-text-domain' ); ?></p>
		</div>
	</div>
	<?php
}
add_action( 'automator_settings_advanced_tab_view', 'my_automator_add_advanced_background_settings', 10, 1 );

/**
 * Example of how to save the custom setting when the main settings are saved.
 * This is typically handled by the main plugin's save process, but you'd need
 * to ensure your custom field is included in the sanitization and saving logic.
 *
 * This function is illustrative and would need to be integrated with the
 * Uncanny Automator plugin's settings save process.
 */
function my_automator_save_advanced_background_settings( $settings ) {
	if ( isset( $_POST['automator_settings']['my_custom_background_setting'] ) ) {
		$new_value = intval( $_POST['automator_settings']['my_custom_background_setting'] );
		if ( $new_value > 0 ) {
			update_option( 'my_custom_background_setting', $new_value );
		} else {
			// Handle invalid input if necessary, perhaps set a default.
			update_option( 'my_custom_background_setting', 5 );
		}
	}
	// You would also return the $settings array if this function was part of a filter
	// that modifies the settings before they are saved by the plugin.
	// return $settings;
}
// This would likely be hooked into a different action or filter provided by Uncanny Automator
// for saving settings, for example: add_action( 'automator_save_settings', 'my_automator_save_advanced_background_settings' );

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/tab/advanced/background-actions.php:31

<div class="uap-settings-panel-title">
				<?php esc_html_e( 'Background actions', 'uncanny-automator' ); ?>
			</div>

			<div class="uap-settings-panel-content">

			<?php do_action( 'automator_settings_advanced_tab_view', self::SETTINGSGROUP ); ?>

			</div>
		</div>

		<div class="uap-settings-panel-bottom">

			<div class="uap-settings-panel-bottom-left">

Internal Usage

Found in src/core/classes/class-background-actions.php:54:

add_action( 'automator_settings_advanced_tab_view', array( $this, 'settings_output' ), 0 );
Scroll to Top