Black friday Black friday Black friday Cyber monday Cyber monday Cyber monday
Up to 70% off Up to 70% off
Grab Yours

wpDataTables filters (hooks) to use in WordPress

Table of Contents

wpDataTables filters: Filter hooks for customizations

Filters (hooks) in WordPress are a type of callback functions that can be defined by the user, and are applied to certain values – strings, integers, objects, etc. It is a simple way to adjust code output without actually having to modify the code. Essentially, you add a given function on top of an existing one, to override the logic. Then, when the plugin is updated later, you won’t lose any of your changes.

You can get a detailed description on WordPress hooks here in WP Codex. In this section we will go through all the filters available in wpDataTables.

Please note that using hooks requires certain level of programming skills and included support refers only to advice.

wpdatatables_filter_table_metadata( $tableMetadata, $tableId )

This filter is applied to the table metadata returned from the DB (table settings, link to the data source file or MySQL query).

$tableMetadata is an array of values.

$tableId is the id from database.

wpdatatables_filter_columns_metadata( $columnsMetadata, $tableId )

This filter is applied to the columns metadata returned from the DB (table settings, link to the data source file or MySQL query).

$columnsMetadata is an array of values.

$tableId is the table ID from the database.

wpdatatables_filter_rendered_table( $tableContent, $tableId )

This filter is applied to the rendered table HTML.

$content is the HTML of the table.

$tableId is the table identifier from the database.

wpdatatables_get_system_fonts( $systemFonts )

This filter is applied to the array of fonts available for the style generator in the wpDataTables settings page.

wpdatatables_before_save_settings( $_POST )

This filter is applied to the contents of the $_POST array when the “Apply” button is pressed in the admin panel, and before the actual saving is done.

wpdatatables_filter_charts_table_page( $wpDataChartsPage )

This filter is applied to the HTML content of the Admin “wpDataCharts” page before it is rendered. $wpDataChartsPage is the default HTML content.

wpdatatables_filter_constructor_page( $createTablePage );

This filter is applied to the HTML content of the admin “Create a table” page before it is rendered. $createTablePage is the default HTML content.

wpdatatables_filter_edit_page( $tableConfigurationPage );

This filter is applied to the HTML content of the admin “Table configuration” page before it is rendered. $tableConfigurationPage is the default HTML content.

wpdatatables_filter_browse_page( $wpDataTablesPage )

This filter is applied to the HTML content of the Admin “wpDataTables” page before it is rendered. $wpDataTablesPage is the default HTML content.

wpdatatables_filter_chart_wizard_page( $createChartPage )

This filter is applied to the HTML content of the Admin “Create a Chart” page before it is rendered. $createChartPage is the default HTML content.

wpdatatables_filter_settings_page( $settingsPage )

This filter is applied to the HTML content of the admin “Settings” page before it is rendered. $settingsPage is the default HTML content.

wpdatatables_try_generate_table_result ( $result )

This filter is applied to the result of the initial table which is generated when a new wpDataTable is first saved (this method tries to generate a table and prepares the metadata in case of success).

wpdatatables_filter_column_before_save( $column, $tableId )

This filter is applied to the $column object (source/class.wpdatacolumn.php and its children) before it is saved to the database. $tableId is the table identifier from MySQL.

wpdatatables_filter_update_column_array( $columnConfig, $tableId )

This filter is applied to the array which is inserted in the database (by $wpdb->update()) when the columns are first generated and saved for a new table.

$columnConfig is an array of keys and values with column settings which will be saved to the database.

$tableId is the table identifier from the database.

wpdatatables_filter_insert_column_array( $columnConfig, $tableId )

This filter is applied to the array which is inserted in the database (by $wpdb->insert()) when the columns are first generated and saved for a new table.

$columnConfig is an array of keys and values which will be inserted to the database.

$tableId is the table identifier from the database.

wpdatatables_filter_insert_table_array( $tableConfig )

This filter is applied to the array which will be sent to the $wpdb->insert() method when creating and saving a new table.

$tableConfig is an associative array.

wpdatatables_filter_browse_tables( $allTables )

This filter is applied to the array of tables returned from MySQL when the existing tables are fetched from the database.

wpdatatables_filter_browse_charts( $allCharts )

This filter is applied to the array of charts returned from MySQL when the existing charts are fetched from the database.

wpdatatables_filter_mysql_query( $query, $tableId )

This filter is applied to the MySQL query before it is sent to MySQL server.

$query is the query text

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_json( $json, $tableId )

This filter is applied to the JSON string before building a table based on it.

$json is the JSON string itself

$tableId is the table identifier from the MySQL table  (wp_wpdatatables).

wpdatatables_filter_simplexml( $simpleXmlObject, $tableId )

This filter is applied to the parsed XML (SimpleXML library is used for parsing the XML files), a SimpleXML object, before creating a table based on it.

$simpleXmlObject is the SimpleXML object

$tableId is the table identifier from the MySQL table  (wp_wpdatatables).

wpdatatables_filter_excel_array( $parsedArray, $tableId, $filePath )

This filter is applied to the array which is generated based on the Excel file. First each excel file is parsed to the array, which you can later modify with this filter.

$parsedArray is the array which is parsed out of the Excel file

$tableId is the table id identifier from the MySQL table (wp_wpdatatables)

$filePath is the path to Excel file.

wpdatatables_filter_table_description( $object, $tableId, wpDataTableObject )

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.

$object is the PHP StdObj which contains all the necessary fields for initializing the table

$tableId is the table identifier from the MySQL table (wp_wpdatatables)

$wpDataTableObject is the WPDataTable object

wpdatatables_filter_style_block( $styleBlockHtml, $tableId )

This filter is applied to the <style></style> HTML block that is generated based on the settings that users provide in the plugin settings admin page.

$styleBlockHtml is the rendered HTML

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_frontend_formdata( $formData, $tableId )

This filter is applied to the data sent from the front-end editable table.

$formData contains the keys and values that will be inserted or updated in the table

$table_id is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_allow_edit_table( $userCanEdit, $editorRoles, $tableId )

This filter is applied to the results of check which defines if the current user can or can’t edit the table (only for editable tables). The default logic is: if editor roles aren’t defined for the table, anyone can edit it. If they are then only the users that have one of these roles can edit it, but you can override the logic using this filter.

$userCanEdit is the Boolean value returned by the original check.

$editorRoles is an array of role names that are allowed to edit the table

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_cell_val( $val, $tableId )

This filter is applied to the value of the cell before it is returned to the front-end.

$val is the cell value

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_column_js_definition( $jsDef, $columnHeader )

This filter is applied to the object that will be later passed to the front-end DataTables library in a JSON format with column properties. You can use it to assign some specific classes, or something else.

$jsDef is the current object

$columnHeader is the original column header (e.g. MySQL column name for MySQL-based columns).

wpdatatables_filter_date_cell( $formattedValue, $tableId )

This filter is applied to the value of a date cell before it is returned to the front-end.

$formattedValue is the value of the cell.

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_datetime_cell( $formattedValue, $tableId )

This filter is applied to the value of a datetime cell before it is returned to the front-end.

$formattedValue is the value of the cell.

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_time_cell( $formattedValue, $tableId )

This filter is applied to the value of a time cell before it is returned to the front-end.

$formattedValue is the value of the cell.

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_email_cell( $formattedValue, $tableId )

This filter is applied to the value of an e-mail column before it is passed to the front-end.

$formattedValue is the value of an e-mail cell.

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_int_cell( $formattedValue, $tableId )

This filter is applied to the value of an integer column before it is passed to the front-end.

$formattedValue is the value of the cell.

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_float_cell ( $formattedValue, $tableId )

This filter is applied to the value of a float column before it is passed to the front-end.

$formattedValue if the value of the cell.

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_image_cell( $formattedValue, $tableId )

This filter is applied to the value of an image column before it is passed to the front-end.

$formattedValue is the value of the cell.

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_string_cell( $formattedValue, $tableId )

This filter is applied to the value of a string column before it is passed to the front-end.

$formattedValue is the value of the cell.

$tableId is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_before_generate_constructed_table_name( $tableName )

This filter is applied to the name which will be used as a MySQL table name when it is generated by a Table constructor.

$tableName is the default name generated by the plugin (wp_wpdatatable_{index}).

wpdatatables_filter_table_title( $tableTitle, $tableId )

This filter is applied to the table title: It is displayed in the frontend and used in the tables browse page to identify the table.

$tableTitle is the title string

$tableId is the wpDataTable ID.

wpdatatables_filter_server_side_data( $json, $tableId, $_GET )

This filter is applied to the JSON object with the data returned for an AJAX request for tables with server-side processing.

$json is the currently generated JSON output

$tableId is the table identifier from the database

$_GET has the contents of $_GET request (page, filtering and searching parameters, etc.)

wpdatatables_filter_column_cssClassArray( $classes, $columnTitle )

This filter is applied to the array of CSS classes a column has.

$classes is an array of strings with CSS classes names

$columnTitle is the original header of a column.

wpdatatables_filter_table_cssClassArray( $classes, $tableId )

This filter is applied to the array of CSS classes that a table has.

$classes is an array of strings with CSS classes names,

$tableId is the wpDataTable identifier from the database.

wpdatatables_filter_query_before_limit( $query, $tableId )

This filter is applied to a generated MySQL query before a ‘LIMIT’ for pagination is added and before it is sent to the MySQL server. Handy for customizing tables with server-side processing.

wpdatatables_filter_initial_table_construct( $tbl )

This filter is applied on the table object after table data is read from data source and columns are generated. It can be used for creating a new table type.

Wait, Before You Download!

To get your hands on wpDataTables Lite, please enter your email address below. We’ll send you a direct download link and keep you updated on existing features along with helpful tips and tricks!

By continuing, I accept Privacy Policy and T&C
Mail Box