wpdatatables_filter_table_description

Contents

Description

This filter is applied to an object (PHP’s StdObj), which is later printed as a table’s data attribute (json_encoded), and used to initialize the DataTables instance, and to describe other table settings and parameters that are used by the frontend JS library.

Usage

add_filter( 'wpdatatables_filter_table_description', 'filter_table_description', 10, 3 );

Parameters

  • $object object
    PHP StdObj object.
  • $tableId integer
    ID of table from database.
  • $wpDataTableObject object
    WPDataTable object.

Examples

Example 1

// Callback function for the wpdatatables_filter_table_description filter hook
function filter_table_description( $object, $tableId, $wpDataTableObject ) { 
    $object->dataTableParams->aLengthMenu = array(
        array(
            10,
            25,
            50,
            75,
            100
        ),
        array(
            10,
            25,
            50,
            75,
            100
        )
    );
    return $object;
}

add_action( 'wpdatatables_filter_table_description', 'filter_table_description', 10, 3);

Example 2

// Callback function for the wpdatatables_filter_table_description filter hook
function filter_table_description( $object, $tableId, $wpDataTableObject ) { 
   if ($table_id == 1){
     $object->dataTableParams->oSearch = array('bSmart' => true, 'bRegex' => true, 'sSearch' => wpDataTableOBJ->getDefaultSearchValue());
   }
    return $object;
}

add_action( 'wpdatatables_filter_table_description', 'filter_table_description', 10, 3);