Filter Uncanny Redemption Codes

ulc_download_date_format

Filters the date format used for downloads, allowing customization of how dates appear.

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

Description

Filters the date format used for displaying download dates. Developers can use this hook to customize the date format globally or conditionally, overriding the WordPress general date format setting. This filter provides flexibility in how download information is presented to users.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Change the date format for download display to a more specific format if a specific plugin is active.
 *
 * @param string $date_format The current date format from WordPress settings.
 * @return string The modified date format.
 */
add_filter( 'ulc_download_date_format', function( $date_format ) {
	// Check if a specific plugin (e.g., ACF Pro) is active.
	// This is a hypothetical check; replace 'acf-pro/acf-pro.php' with the actual plugin file.
	if ( is_plugin_active( 'acf-pro/acf-pro.php' ) ) {
		// If ACF Pro is active, use a more detailed date format.
		return 'F j, Y H:i:s'; // Example: 'October 26, 2023 10:30:15'
	}

	// Otherwise, return the default WordPress date format.
	return $date_format;
}, 10, 1 );

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/classes/helpers/class-database.php:979
src/classes/helpers/class-database.php:1132

$results = $wpdb->get_results( $qry );

		if ( empty( $results ) ) {
			return array();
		}

		$date_format       = apply_filters( 'ulc_download_date_format', get_option( 'date_format' ) );
		$time_format       = apply_filters( 'ulc_download_time_format', get_option( 'time_format' ) );
		$num_times_allowed = 1;
		if ( is_numeric( $group ) ) {
			$num_times_allowed = self::number_of_times_a_user_allowed_to_redeem( $group );
		}

		foreach ( $results as $result ) {


Scroll to Top