uotc_unique_verbs
Filters the list of unique verbs used in the plugin's core functionality, allowing for modification before they are applied.
add_filter( 'uotc_unique_verbs', $callback, 10, 1 );
Description
Filters the unique LRS verbs retrieved from the database. Developers can use this hook to modify the array of verbs before they are returned, allowing for customization or filtering of LRS data. This filter fires after the database query has been executed.
Usage
add_filter( 'uotc_unique_verbs', 'your_function_name', 10, 1 );
Parameters
-
$verbs(mixed) - A list of unique verbs retrieved from the reporting database table.
Return Value
The filtered value.
Examples
// Example: Add a custom verb to the list of unique verbs retrieved from the database.
add_filter( 'uotc_unique_verbs', function( $verbs ) {
// Ensure $verbs is an array before attempting to add to it.
if ( ! is_array( $verbs ) ) {
$verbs = array(); // Initialize as an empty array if it's not already.
}
// Add a custom verb if it's not already present.
$custom_verb = 'http://adlnet.gov/expapi/verbs/completed'; // Example of a common xAPI verb
if ( ! in_array( $custom_verb, $verbs ) ) {
$verbs[] = $custom_verb;
}
// You could also remove existing verbs if needed.
// For example, to remove all verbs that contain 'attempt':
// $verbs = array_filter( $verbs, function( $verb ) {
// return strpos( $verb, 'attempt' ) === false;
// });
return $verbs;
}, 10, 1 ); // Priority 10, accepts 1 argument.
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/uncanny-tincan/classes/Database.php:673
public static function get_unique_verbs() {
global $wpdb;
$table = $wpdb->prefix . self::TABLE_REPORTING;
$query = "SELECT distinct(verb) FROM ".$table;
$verbs = $wpdb->get_col( $query );
return apply_filters( 'uotc_unique_verbs', $verbs );
}