Created
February 26, 2022 20:46
-
-
Save xnau/2dd81f85758094bd1028bb412b94f2bd to your computer and use it in GitHub Desktop.
Sows how to add a custom summary tag to a Participants Database log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: PDB Custom Summary Tag | |
* Description: provides a custom tag to the "cars" log | |
*/ | |
add_filter( 'pdblog-summary_tags', 'xnau_add_custom_summary_tag', 10, 2 ); | |
/** | |
* adds a custom summary tag to the "cars" log | |
* | |
* @param array $tags | |
* @param string $log_name | |
*/ | |
function xnau_add_custom_summary_tag( $tags, $log_name ) | |
{ | |
if ( $log_name === 'cars' ) | |
{ | |
$tags['average_score'] = $tags['sum'] / $tags['count']; | |
} | |
return $tags; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This filter adds an [average_score] tag that can be used in the summary template for the selected log.
This assumes that the log sum is configured as the sum of all scores. The tag makes it possible to display the average score in the summary display.