wpdatatables_filter_simple_table_cell_meta

Contents

Description

The filter allows you to modify the CSS classes and metadata of individual cells in a simple table before they are rendered.

Usage

add_filter('wpdatatables_filter_simple_table_cell_meta', 'custom_cell_meta_classes', 10, 4);

Parameters

  • $cellMetaClasses string
    The default CSS classes for the current table cell.
  • $rowIndex int
    The index of the current row.
  • $colIndex int
    The index of the current column.
  • $tableId int
    The ID of the table.

Examples

// Callback function for the wpdatatables_filter_simple_table_cell_meta filter
function custom_cell_meta_classes($cellMetaClasses, $rowIndex, $colIndex, $tableId) {
    // Example: Add a custom class to the first cell of every row
    if ($colIndex === 0) {
        $cellMetaClasses .= ' first-column-cell';
    }

    // Example: Add a custom class to the third row of a specific table
    if ($tableId == 1 && $rowIndex == 2) {
        $cellMetaClasses .= ' highlight-row-3';
    }

    // Example: Add a custom class to all cells in a specific table
    if ($tableId == 2) {
        $cellMetaClasses .= ' special-table-class';
    }

    return $cellMetaClasses;
}

add_filter('wpdatatables_filter_simple_table_cell_meta', 'custom_cell_meta_classes', 10, 4);