uo_ceu_credit_report_column_config
Filters the configuration for the CEU credit report columns to customize displayed data.
add_filter( 'uo_ceu_credit_report_column_config', $callback, 10, 2 );
Description
Allows developers to modify the configuration array for the course completion report columns. This filter fires after default columns and rendering functions are set, enabling customization of column order, titles, or the addition of custom columns. Developers can manipulate the `$columns` array to tailor the report's display.
Usage
add_filter( 'uo_ceu_credit_report_column_config', 'your_function_name', 10, 2 );
Parameters
-
$this(mixed) - This parameter is the array of column configurations that will be applied to the course report.
-
$this(mixed) - This parameter, `$this`, refers to the current instance of the `Course_Report` class, providing access to its methods and properties.
Return Value
The filtered value.
Examples
add_filter( 'uo_ceu_credit_report_column_config', 'my_custom_ceu_report_columns', 10, 2 );
/**
* Customizes the columns displayed in the CEU credit report.
*
* This example adds a new "Instructor Notes" column and makes the "Date" column not orderable.
*
* @param array $columns The existing column configuration.
* @param object $course_report_instance The instance of the course report class.
* @return array The modified column configuration.
*/
function my_custom_ceu_report_columns( $columns, $course_report_instance ) {
// Add a new column for instructor notes.
$columns['instructor_notes'] = array(
'name' => 'instructor_notes',
'title' => __( 'Instructor Notes', 'your-text-domain' ),
'data' => 'instructor_notes', // Assuming this data will be available.
'orderable' => true,
'export' => true,
'visible' => true,
'render' => 'renderInstructorNotes', // A hypothetical render function.
);
// Make the 'date' column not orderable.
if ( isset( $columns['date'] ) ) {
$columns['date']['orderable'] = false;
}
return $columns;
}
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/classes/course-report.php:627
public function set_column_config( $columns ) {
// Default render functions for each default column.
$render_functions = array(
'user' => 'renderUser',
'course' => 'renderCourse',
'date' => 'renderDate',
'ceus_earned' => 'renderCeusEarned',
'total' => 'renderTotal',
);
// Add Checkbox as default column.
$this->columns = array(
'checkbox' => array(
'name' => 'checkbox',
'title' => '',
'data' => null,
'orderable' => false,
'render' => 'renderCheckbox',
'export' => false,
),
);
foreach ( $columns as $key => $label ) {
if ( 'checkbox' === $key ) {
continue;
}
$data_key = key_exists( $key, $render_functions ) && 'total' !== $key
? null
: $key;
$this->columns[ $key ] = array(
'name' => $key, // column name
'title' => $label, // column title
'data' => $data_key, // data key
'orderable' => true, // orderable
'export' => true, // exportable
'visible' => true, // visible
);
// Set render function if available.
if ( isset( $render_functions[ $key ] ) ) {
$this->columns[ $key ]['render'] = $render_functions[ $key ];
}
}
// Add columns for export data.
$this->columns = $this->maybe_insert_export_columns( $this->columns );
// Allow configuration filtering.
$this->columns = apply_filters( 'uo_ceu_credit_report_column_config', $this->columns, $this );
// Re-index the columns array for JS.
$this->columns = array_values( $this->columns );
}