tinccanny_get_part_path
Filters the asset URI and file name for retrieving plugin part paths.
add_filter( 'tinccanny_get_part_path', $callback, 10, 2 );
Description
Filters the path for Tincanny reporting templates. Modify this path to customize which template files are loaded for specific Tincanny shortcode parts, allowing for custom template overrides without altering core plugin files.
Usage
add_filter( 'tinccanny_get_part_path', 'your_function_name', 10, 2 );
Parameters
-
$asset_uri(mixed) - This parameter contains the initial path to the asset being requested.
-
$file_name(mixed) - This parameter holds the initial absolute file path to the template part file before any filters are applied.
Return Value
The filtered value.
Examples
add_filter( 'tinccanny_get_part_path', 'my_tincanny_custom_template_path', 10, 2 );
/**
* Example filter to change the path of a Tincanny template part.
*
* This function demonstrates how to modify the default path where Tincanny
* looks for its template parts, allowing for custom templates to be used.
*
* @param string $asset_uri The default asset URI path.
* @param string $file_name The name of the template part file.
* @return string The modified asset URI path.
*/
function my_tincanny_custom_template_path( $asset_uri, $file_name ) {
// Check if we want to override a specific template part.
if ( 'specific-template-part.php' === $file_name ) {
// Define a new path to a custom template within your theme.
// It's good practice to use a theme-specific directory for overrides.
$custom_path = get_stylesheet_directory() . '/tincanny-templates/override/' . $file_name;
// Ensure the custom file actually exists before returning its path.
if ( file_exists( $custom_path ) ) {
return $custom_path;
}
}
// If we don't want to override, or the custom file doesn't exist, return the original path.
return $asset_uri;
}
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/shortcode-tincanny/shortcode-tincanny.php:643
public static function get_part( $file_name ) {
$asset_uri = dirname( UO_REPORTING_FILE ) . '/src/reporting/learndash/templates/' . $file_name;
$asset_uri = apply_filters( 'tinccanny_get_part_path', $asset_uri, $file_name );
return $asset_uri;
}