automator_core_class_logs_list_table
Filters the class logs list table mode before it is displayed to allow customization of the logs view.
add_filter( 'automator_core_class_logs_list_table', $callback, 10, 2 );
Description
Filters the CSS classes applied to the Uncanny Automator logs list table. Developers can use this hook to add or remove classes, altering the table's appearance. It fires when the table classes are being generated, allowing for dynamic styling adjustments before the table is rendered.
Usage
add_filter( 'automator_core_class_logs_list_table', 'your_function_name', 10, 2 );
Parameters
-
$mode_class(mixed) - This parameter contains a string representing the current view mode of the logs table, used to apply specific CSS classes.
-
$this(mixed) - This parameter holds a string representing the current display mode of the logs table, which is used to apply CSS classes for styling.
Return Value
The filtered value.
Examples
/**
* Add a custom class to the Uncanny Automator logs table if a specific user role is detected.
*
* @param array $table_classes The existing array of table classes.
* @param object $this The current instance of the Logs_List_Table class.
* @return array The modified array of table classes.
*/
add_filter( 'automator_core_class_logs_list_table', function( $table_classes, $list_table_instance ) {
// Check if the current user has the 'administrator' role.
if ( current_user_can( 'manage_options' ) ) {
// Add a custom class if the user is an administrator.
$table_classes[] = 'automator-admin-logs-enhanced';
}
return $table_classes;
}, 10, 2 );
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/core/admin/admin-logs/wp-list-table/class-logs-list-table.php:1063
protected function get_table_classes() {
$mode = get_user_setting( 'posts_list_mode', 'list' );
$mode_class = esc_attr( 'table-view-' . $mode );
return apply_filters(
'automator_core_class_logs_list_table',
array( 'uncanny-automator', 'widefat', 'striped', $mode_class, $this->_args['plural'] ),
$this
);
}
Internal Usage
Found in src/core/admin/admin-logs/tabs/recipe.php:16:
add_filter( 'automator_core_class_logs_list_table', array( $this, 'modify_table_classes' ), 10, 2 );
Found in src/core/admin/admin-logs/tabs/trigger.php:16:
add_filter( 'automator_core_class_logs_list_table', array( $this, 'modify_table_classes' ), 10, 2 );
Found in src/core/admin/admin-logs/tabs/action.php:16:
add_filter( 'automator_core_class_logs_list_table', array( $this, 'modify_table_classes' ), 10, 2 );