Filter uncanny-toolkit-pro

uo_learndash_certificate_font_size

Filters the font size for LearnDash certificates before they are generated.

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

Description

Filter the font size used for LearnDash certificates. Developers can modify the font size passed to the PDF generation. The `$font_size` parameter contains the current font size, and `$cert_args['cert_id']` provides the ID of the certificate being generated.


Usage

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

Parameters

$font_size (mixed)
This parameter contains the font size value for the certificate, which can be modified by the filter.
$cert_args (mixed)
This parameter holds the current font size being applied to the certificate, which can be filtered to allow for dynamic adjustments.

Return Value

The filtered value.


Examples

/**
 * Adjusts the font size of the certificate text based on certain conditions.
 *
 * This filter allows developers to programmatically override the default font size
 * for certificate elements. It's useful for scenarios where you might want to
 * apply a larger font size for specific certificate templates or user roles.
 *
 * @param int|float $font_size   The current font size value.
 * @param int       $cert_id     The ID of the certificate being generated.
 * @return int|float The modified font size.
 */
add_filter( 'uo_learndash_certificate_font_size', function( $font_size, $cert_id ) {
	// Example: Increase font size by 2 points if it's a specific certificate ID
	// and the original font size is not too large already.
	if ( $cert_id === 123 && $font_size < 18 ) {
		return $font_size + 2;
	}

	// Example: Set a fixed font size for a particular certificate ID,
	// regardless of the initial value.
	if ( $cert_id === 456 ) {
		return 16;
	}

	// If no specific conditions are met, return the original font size.
	return $font_size;
}, 10, 2 );

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/includes/tcpdf-certificate-code.php:362

$monospaced_font = esc_html( $_GET['monospaced'] );
		}
		$monospaced_font = apply_filters( 'uo_learndash_certificate_monospaced_font', $monospaced_font, $cert_args['cert_id'] );

		if ( ! empty( $_GET['fontsize'] ) ) {
			$font_size = intval( $_GET['fontsize'] );
		}
		$font_size = apply_filters( 'uo_learndash_certificate_font_size', $font_size, $cert_args['cert_id'] );

		if ( ! empty( $_GET['subsetting'] ) && ( $_GET['subsetting'] == 1 || $_GET['subsetting'] == 0 ) ) {
			$subsetting_enable = $_GET['subsetting'];
		}
		$subsetting_enable = apply_filters( 'uo_learndash_certificate_subsetting_enable', $subsetting_enable, $cert_args['cert_id'] );

		if ( $subsetting_enable == 1 ) {


Scroll to Top