tincanny_reporting_tabs
Filters the array of reporting tabs used by the Tincanny plugin.
add_filter( 'tincanny_reporting_tabs', $callback, 10, 1 );
Description
Customize the reporting tabs displayed in the Tincanny admin area. Developers can add, remove, or modify reporting tabs by filtering this array to control the available reporting sections.
Usage
add_filter( 'tincanny_reporting_tabs', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
add_filter( 'tincanny_reporting_tabs', 'my_custom_tincanny_reporting_tabs', 10, 1 );
/**
* Adds custom reporting tabs to the Tincanny reporting section.
*
* This function demonstrates how to add new tabs to the Tincanny reporting interface
* by filtering the 'tincanny_reporting_tabs' hook. It defines a new tab with a title,
* a unique ID, and a corresponding URL slug.
*
* @param array $tabs An array of existing reporting tabs.
* @return array An updated array of reporting tabs including the new custom tab.
*/
function my_custom_tincanny_reporting_tabs( $tabs ) {
// Define a new custom tab.
$custom_tab = new stdClass();
$custom_tab->title = __( 'My Custom Report', 'text-domain' ); // Translatable string for the tab title.
$custom_tab->id = 'my-custom-report'; // A unique identifier for the tab.
$custom_tab->page = 'my-custom-report'; // The slug used in the URL for this tab.
// Add the custom tab to the existing array of tabs.
$tabs[] = $custom_tab;
return $tabs;
}
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:745
public static function add_header_and_tabs() {
$tabs = apply_filters( 'tincanny_reporting_tabs', array() );
// Add admin header and tabs
// Check for the "page" get parameter to activate the correct tab
foreach ( $tabs as $tab ) {
if ( self::$current_report_tab === $tab->page ) {
$tab_active = $tab->id;
break;
}
}
// Define classes
$css_classes = array();
$css_classes[] = is_admin() ? 'tclr-header--admin' : 'tclr-header--frontend';
include __DIR__ . '/header.php';
}