tincanny_reporting_before_header
Fires before the Tincanny reporting header is output, allowing modifications.
add_action( 'tincanny_reporting_before_header', $callback, 10, 1 );
Description
Fires before the Tincanny reporting header is rendered. Developers can use this hook to add content or modify the header structure before it appears. It's part of the core reporting functionality, executed just before the main header div is output.
Usage
add_action( 'tincanny_reporting_before_header', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Example function to demonstrate the 'tincanny_reporting_before_header' action hook.
* This function adds a custom class to the header based on a user role.
*/
add_action( 'tincanny_reporting_before_header', 'my_custom_tincanny_header_logic', 10 );
function my_custom_tincanny_header_logic() {
// Check if the current user has the 'administrator' role.
if ( current_user_can( 'administrator' ) ) {
// If they are an administrator, add a specific class to the header.
// This assumes the 'tclr-header' element is the target.
// In a real scenario, you might pass data back through the action,
// but actions are typically for side effects. For modifying output,
// a filter is more appropriate. However, since this is an action,
// we'll simulate adding a class by echoing some HTML or modifying a global.
// For this example, let's simulate adding a class by outputting a hidden element
// or modifying a global that the header might read.
// A more robust approach would be to use a filter if available, or
// have the action hook modify an array that the original code then uses.
// For demonstration, let's echo a data attribute to the body tag,
// which could be read by JavaScript.
echo '<script>document.body.setAttribute("data-tincanny-admin", "true");</script>';
// Alternatively, if there was a mechanism to pass data back:
// For example, if the original code expected a global variable to be set:
// $GLOBALS['tincanny_header_classes'][] = 'tclr-header-admin-highlight';
}
}
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/header.php:9
namespace uncanny_learndash_reporting;
if ( ! defined( 'WPINC' ) ) {
die;
}
do_action( 'tincanny_reporting_before_header' );
?>
<div class="tclr-header <?php echo esc_attr( $css_classes[0] ); ?>">
<?php if ( is_admin() ) { ?>
<div class="tclr-header-top">