Filter uncanny-automator

automator_content_header_css_class

Filters the CSS classes applied to the content header for customization.

add_filter( 'automator_content_header_css_class', $callback, 10, 2 );

Description

This filter allows developers to modify the CSS classes applied to the settings content header. It's useful for conditionally adding or removing classes based on the active tab or other context, enabling custom styling for different sections of the automator settings.


Usage

add_filter( 'automator_content_header_css_class', 'your_function_name', 10, 2 );

Parameters

$active (mixed)
This parameter is the default CSS class string that will be returned if no other filters modify it.
$tab (mixed)
This parameter represents the currently active tab, which is used to conditionally apply CSS classes.

Return Value

The filtered value.


Examples

<?php
/**
 * Add a custom CSS class to the automator content header based on the active tab.
 *
 * @param string $classes The default CSS classes.
 * @param string $active  The currently active tab slug.
 * @param string $tab     The current tab data (array).
 *
 * @return string The modified CSS classes.
 */
add_filter(
	'automator_content_header_css_class',
	function ( $classes, $active, $tab ) {
		// Add a specific class if the active tab is 'integrations'.
		if ( 'integrations' === $active ) {
			$classes .= ' automator-integrations-header';
		}

		// Add another class if the tab has a specific 'premium' flag set to true.
		if ( isset( $tab['premium'] ) && true === $tab['premium'] ) {
			$classes .= ' automator-premium-feature-header';
		}

		// Trim whitespace to ensure clean class names.
		return trim( $classes );
	},
	10,
	3 // Accepts 3 arguments: $classes, $active, $tab
);

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/includes/automator-settings.php:212

$header_content = ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

						?>

						<?php if ( ! empty( $header_content ) ) { ?>

							<div
								class="uo-settings-content-header<?php echo esc_attr( apply_filters( 'automator_content_header_css_class', '', $active, $tab ) ); ?>">
								<?php echo $header_content;  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
							</div>

						<?php } ?>

						<div class="uo-settings-content-top">
							<div class="uo-settings-content-info">


Scroll to Top