See video usage example

Filters (hooks) in WordPress are a sort of callback functions which can be defined by user, and are applied  to certain values – strings, integers, objects, etc. It is a simple way to adjust output of some code without actually modifying this code: basically you add some function on top of existing one, so you can override the logic. When the plugin is updated later, you don’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.

wpdatatables_filter_table_metadata( $table_metadata, $table_id )

This filter is applied to the table metadata returned from the DB (table settings, link to the data source file or MySQL query). $table_metadata is an array of values. $table_id is the id from database.

wpdatatables_filter_columns_metadata( $columns_metadata, $table_id )

This filter is applied to the columns metadata returned from the DB (table settings, link to the data source file or MySQL query). $table_metadata is an array of values. $table_id is the table ID from the database.

wpdatatables_filter_rendered_table( $table_content, $table_id )

This filter is applied to the rendered table HTML. $table ID is the table identifier from the database.

wpdatatables_get_system_fonts( $system_fonts )

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 “Save settings” button is pressed in the admin panel, before the actual saving is done.

wpdatatables_filter_browse_page( $browse_page )

This filter is applied to the HTML content of the Admin browse page before it is rendered. $browse_page is the default HTML content.

wpdatatables_filter_new_table_page( $new_table_page )

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

wpdatatables_filter_edit_page( $edit_table_page );

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

wpdatatables_filter_settings_page( $settings_page )

This filter is applied to the HTML content of the admin settings page before it is rendered. $settings_page is the default HTML content.

wpdatatables_before_save_table( $_POST )

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

wpdatatables_before_save_columns( $_POST )

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

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, $table_id )

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

wpdatatables_filter_update_column_array( $update_array, $table_id, $column )

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.

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

$table_id is the table identifier from the database.

$column is the column object (source/class.column.php and its children).

wpdatatables_filter_insert_column_array( $insert_array, $table_id, $column )

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.

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

$table_id is the table identifier from the database.

$column is the column object (source/class.column.php and its children).

wpdatatables_filter_insert_table_array( $insert_array )

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

wpdatatables_filter_update_table_array( $update_array, $table_id )

This filter will be applied to the array which will be sent to the $wpdb->update() method when updating table settings. $update_array is an associative array, $table_id is the table identifier from the DB.

wpdatatables_filter_browse_tables( $all_tables )

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( $all_charts )

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, $table_id )

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

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

wpdatatables_filter_json( $json, $table_id )

This filter is applied to the JSON string before building a table based on it. $json is the JSON string itself, $table_id is the table identifier from the MySQL table  (wp_wpdatatables).

wpdatatables_filter_simplexml( $simplexml_object, $table_id )

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. $simplexml_object is the SimpleXML object, $table_id is the table identifier from the MySQL table  (wp_wpdatatables).

wpdatatables_filter_excel_array( $parsed_array, $table_id, $file_path )

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. $parsed_array is the array which is parsed out of the Excel file, $table_id is the table id entifier from the MySQL table (wp_wpdatatables), $file_path is the path to Excel file.

wpdatatables_link_to_skin_css( $skin_css_url, $table_id )

This filter is applied to the URL of Skin CSS file before it is inserted in the page. $skin_css_url is the URL to the current skin CSS file, $table_id is the table identifier from the MySQL table (wp_wpdatatables)

wpdatatables_filter_table_description( $object, $table_id );

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, , $table_id is the table identifier from the MySQL table (wp_wpdatatables)

wpdatatables_filter_style_block( $style_block_html, $table_id )

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.

$style_block_html is the rendered HTML, $table_id is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_frontend_formdata( $formdata, $table_id )

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( $allow_edit, $allowed_editor_roles, $table_id )

This filter is applied to the results of check which defines if 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. $allow_edit is the Boolean value returned by the original check. $allow_editor_roles is an array of role names that are allowed to edit the table, $table_id is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_filter_cell_val( $val )

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

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 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 )

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.

wpdatatables_filter_email_cell( $formattedValue )

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.

wpdatatables_filter_int_cell( $formattedValue )

This filter is applied to the value of an integerсd .. column before it is passed to the front-end. $formattedValue is the value of the cell.

wpdatatables_filter_float_cell ( $formattedValue )

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.

wpdatatables_filter_image_cell( $formattedValue )

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.

wpdatatables_filter_link_cell( $formattedValue )

This filter is applied to the value of an URL link column before it is passed to the front-end. $formattedValue is the value of the cell.

wpdatatables_filter_string_cell( $formattedValue )

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.

wpdatatables_filter_column_classes( $classes, $columnHeader )

This filter is applied to the set of CSS classes of the column before it is passed to the front-end. $classes is the string with CSS classes (space separated), $columnHeader is the original header of the column (e.g. MySQL table column name in case of MySQL-based table).

wpdatatables_filter_table_classes( $classes, $table_id)

This filter is applied to the set of CSS classes of the table before it is passed to the front-end. $classes is the string with CSS classes (space separated), $table_id is the table identifier from the MySQL table (wp_wpdatatables).

wpdatatables_before_generate_constructed_table_name( $table_name )

This filter is applied to the name which will be used as a MySQL table name when it is generated by a Table constructor. $table_name is the default name generated by the plugin (wp_wpdatatable_{index}).

wpdatatables_filter_table_title( $table_title, $table_id )

This filter is applied to the table title (displayed in the frontend and used in the tables browse page to identify the table). $table_title is the title string, $table_id is the wpDataTable ID.

wpdatatables_filter_editor_page( $editor_page_html )

This filter is applied to the HTML of the back-end editor before it’s rendered and can be used e.g. to add more input elements.  $editor_page_html is the string with HTML of the editor page

wpdatatables_filter_server_side_data( $json, $table_id, $_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, $table_id 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, $column_title )

This filter is applied to the array of CSS classes a column has. $classes is an array of strings with CSS classes names, $column_title is the original header of a column.

wpdatatables_filter_table_cssClassArray( $classes, $table_id )

This filter is applied to the array of CSS classes that a table has. $classes is an array of strings with CSS classes names, $table_id is the wpDataTable identifier from the database.

wpdatatables_filter_query_before_limit( $query, $table_id )

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_chart( $chart_render_data, $series_headers, $series_values, $chart_id )

This filter is applied to the generated chart data before it is sent to the rendering engine. Handy if you need to hook into it and modify some rendering rules. $chart_render_data is an array of data needed for the chart rendering, $series_headers is an array of series labels, $series_values is a 2D array of values used for chart rendering, $chart_id is the chart identifier from the database.

wpdatatables_filter_template_file_location( $template_file_location )

This filter will render template file location for inserting custom template for any wpDataTable template. You can use this filter to override default template for tables.

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.

Never miss new features!

Join 2000+ newsletter subscribers

Never miss notifications about new cool features, promotions, giveaways or freebies - subscribe to our newsletter! We send about one mail per month, and do our best to keep our announcements interesting.

We never spam or disclose your address to anyone.