Filter tin-canny-learndash-reporting

tincanny_ui

Filters the font used in the Tincanny UI, allowing customization before it's applied to the interface.

add_filter( 'tincanny_ui', $callback, 10, 1 );

Description

Allows developers to modify the default UI font stack used throughout the plugin's admin interface. This filter provides fine-grained control over typography, enabling customization for specific design needs or accessibility requirements. The `$font` parameter accepts a string representing a valid CSS font-family declaration.


Usage

add_filter( 'tincanny_ui', 'your_function_name', 10, 1 );

Parameters

$font (mixed)
This parameter contains the CSS font-family stack to be used for the UI elements.

Return Value

The filtered value.


Examples

add_filter( 'tincanny_ui', 'my_custom_tincanny_ui_font', 10, 1 );

/**
 * Modifies the default font used in the Tincanny UI.
 *
 * This function allows developers to override the default system font stack
 * with a custom font, for example, to enforce a specific brand font.
 *
 * @param mixed $font The current font setting.
 * @return string The modified font setting.
 */
function my_custom_tincanny_ui_font( $font ) {
	// Check if a custom font option is set in the WordPress options.
	// This is a hypothetical option for demonstration purposes.
	$custom_font_option = get_option( 'my_plugin_custom_tincanny_font' );

	if ( ! empty( $custom_font_option ) && is_string( $custom_font_option ) ) {
		// If a custom font is set, use it. Otherwise, return the original font.
		return esc_attr( $custom_font_option );
	}

	// Fallback to the original font if no custom font is specified.
	return $font;
}

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/reporting-admin-menu.php:662

private static function get_ui_data() {
		// Define default font
		$font = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif';

		// Get colors from DB
		$primary   = '';
		$secondary = '';
		$notice    = '';

		$not_started = '';
		$in_progress = '';
		$completed   = '';

		// Define default values
		$primary   = empty( $primary ) ? '#0290c2' : $primary;
		$secondary = empty( $secondary ) ? '#d52c82' : $secondary;
		$notice    = empty( $notice ) ? '#f5ba05' : $notice;

		$completed   = empty( $completed ) ? '#02c219' : $completed;
		$in_progress = empty( $in_progress ) ? '#FF9E01' : $in_progress;
		$not_started = empty( $not_started ) ? '#e3e3e3' : $not_started;

		return apply_filters(
			'tincanny_ui',
			array(
				'mainFont' => $font,
				'colors'   => array(
					'primary'   => $primary,
					'secondary' => $secondary,
					'notice'    => $notice,
					'status'    => array(
						'completed'  => $completed,
						'inProgress' => $in_progress,
						'notStarted' => $not_started,
					),
				),
				'show'     => array(
					'tinCanData' => 'no' !== get_option( 'show_tincan_reporting_tables' ),
				),
			)
		);
	}

Scroll to Top