Filter tin-canny-learndash-reporting

uo_tincanny_reporting_frontend_reporting_links

Filters the base URL for frontend reporting links.

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

Description

Filters the base URL used for frontend reporting links. This allows developers to modify the generated URLs for course, user, Tin Can, and xAPI reports within the Uncanny Automator plugin. It fires during the retrieval of frontend reporting links.


Usage

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

Parameters

$base_url (mixed)
This parameter contains the base URL for WordPress admin pages.
$base_url (mixed)
This parameter is the base URL for the WordPress admin area, used to construct the full URLs for various reporting pages.

Return Value

The filtered value.


Examples

/**
 * Example of how to filter the frontend reporting links for Uncanny Tincanny.
 *
 * This example demonstrates how to add a new link to the reporting dashboard
 * and modify an existing one.
 *
 * @param array $reporting_links An array of existing reporting links.
 * @param string $base_url The base URL for frontend reporting.
 * @return array The modified array of reporting links.
 */
add_filter( 'uo_tincanny_reporting_frontend_reporting_links', function( $reporting_links, $base_url ) {

	// Add a new custom report link
	$reporting_links['customReport'] = $base_url . '/?tab=uncanny-tincanny-custom-report';

	// Modify the existing tinCanReport link to include a specific query parameter for filtering
	if ( isset( $reporting_links['tinCanReport'] ) ) {
		$reporting_links['tinCanReport'] = add_query_arg( 'filter_by_course', 'some_course_id', $reporting_links['tinCanReport'] );
	}

	return $reporting_links;
}, 10, 2 ); // Priority 10, accepts 2 arguments ($reporting_links, $base_url)

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:358

public static function get_frontend_reporting_links() {
		if ( is_admin() ) {
			$base_url = admin_url( 'admin.php' );
			return array(
				'courseReport' => $base_url . '?page=uncanny-learnDash-reporting',
				'userReport'   => $base_url . '?page=uncanny-tincanny-user-report',
				'tinCanReport' => $base_url . '?page=uncanny-tincanny-tin-can-report',
				'xapiReport'   => $base_url . '?page=uncanny-tincanny-xapi-quiz-report',
			);
		}

		$base_url = self::get_base_url();
		
		return  apply_filters(
			'uo_tincanny_reporting_frontend_reporting_links',
			array(
				'courseReport' => $base_url,
				'userReport'   => $base_url . '/?tab=uncanny-tincanny-user-report',
				'tinCanReport' => $base_url . '/?tab=uncanny-tincanny-tin-can-report',
				'xapiReport'   => $base_url . '/?tab=uncanny-tincanny-xapi-quiz-report',
			), 
			$base_url
		);
	}

Scroll to Top