Add-On: TablePress Integration

This add-on integrates with the TablePress plugin by allowing you to use any Pod as a data source.

Requirements

Requires WordPress 5.5+, Pods 2.7+, TablePress 1.12+, and PHP 5.6+

What does this add-on do?

Power up the [table] shortcode with Pods integration

The shortcode integration allows for using any Pod as a data source. You MUST have a skeleton Table created with TablePress as the [table] shortcode won’t work without that.

This integration requires custom shortcode attributes to be used, it does not add any additional user interfaces when managing tables. It overrides the entire table column/row output.

Example: Show all fields for the pod

[table id=123 pods_name="your_pod"]

Example: Show specific fields for the pod (all items from the database).

Warning: Using queries that do not limit to a maximum number (default: 1000) can produce problematic performance issues on your site.

[table id=123 pods_name="your_pod" pods_limit="-1"]

Example: Show specific fields for the pod

[table id=123 pods_name="your_pod" pods_fields="post_title,field1,field2"]

Example: find() parameter support

See the find() doc page for more parameters. Each parameter in the shortcode should be prefixed with “pods_”.

[table id=123 pods_name="your_pod" pods_where="field1.meta_value = '1'"]

You can further customize the integration through filters

There are filters available to further customize the TablePress integration to suit your needs. See below for how those filters get used.

/**
 * Allow filtering the Pods limit parameter to be used.
 *
 * @since 1.0.1
 *
 * @param int    $default_limit  The default limit of items to retrieve from the database (default: 1000).
 * @param string $pod_name       The pod name.
 * @param array  $table          The TablePress information.
 * @param array  $render_options The TablePress render options.
 */
$default_limit = apply_filters( 'pods_pro_tablepress_find_default_limit', 1000, $pod_name, $table, $render_options );

/**
 * Allow filtering the Pods::find() parameters to be used.
 *
 * @since 1.0.0
 *
 * @param array  $params         The Pods::find() parameters to be used.
 * @param string $pod_name       The pod name.
 * @param array  $table          The TablePress information.
 * @param array  $render_options The TablePress render options.
 */
$params = apply_filters( 'pods_pro_tablepress_find_params', $params, $pod_name, $table, $render_options );

/**
 * Allow filtering the table columns to be used.
 *
 * @since 1.0.0
 *
 * @param array  $columns        The list of columns to be used.
 * @param string $pod_name       The pod name.
 * @param Pods   $pod            The Pods object.
 * @param array  $params         The Pods::find() parameters to be used.
 * @param array  $table          The TablePress information.
 * @param array  $render_options The TablePress render options.
 */
$columns = apply_filters( 'pods_pro_tablepress_data_columns', $columns, $pod_name, $pod, $params, $table, $render_options );

/**
 * Allow filtering the custom column templates to be used.
 *
 * @since 1.0.0
 *
 * @param array  $custom_column_templates The list of custom column templates to be used, with the field name as the key.
 * @param string $pod_name                The pod name.
 * @param Pods   $pod                     The Pods object.
 * @param array  $params                  The Pods::find() parameters to be used.
 * @param array  $table                   The TablePress information.
 * @param array  $render_options          The TablePress render options.
 */
$custom_column_templates = apply_filters( 'pods_pro_tablepress_data_custom_column_templates', $custom_column_templates, $pod_name, $pod, $params, $table, $render_options );

/**
 * Allow filtering the row value for a specific column.
 *
 * The $column variable is the column name.
 *
 * @since 1.0.1
 *
 * @param string $value          The column value.
 * @param string $column         The column name.
 * @param string $pod_name       The pod name.
 * @param Pods   $pod            The Pods object.
 * @param array  $params         The Pods::find() parameters to be used.
 * @param array  $table          The TablePress information.
 * @param array  $render_options The TablePress render options.
 */
$value = apply_filters( "pods_pro_tablepress_data_row_value_{$column}", $value, $column, $columns, $pod_name, $pod, $params, $table, $render_options );

/**
 * Allow filtering the row value for any column.
 *
 * @since 1.0.1
 *
 * @param string $value          The column value.
 * @param string $column         The column name.
 * @param string $pod_name       The pod name.
 * @param Pods   $pod            The Pods object.
 * @param array  $params         The Pods::find() parameters to be used.
 * @param array  $table          The TablePress information.
 * @param array  $render_options The TablePress render options.
 */
$value = apply_filters( 'pods_pro_tablepress_data_row_value', $value, $column, $columns, $pod_name, $pod, $params, $table, $render_options );

/**
 * Allow filtering the list of rows to be used.
 *
 * @since 1.0.0
 *
 * @param array  $rows           The list of rows to be used, with the field name as the key on each field in the row.
 * @param array  $columns        The list of columns to be used.
 * @param string $pod_name       The pod name.
 * @param Pods   $pod            The Pods object.
 * @param array  $params         The Pods::find() parameters to be used.
 * @param array  $table          The TablePress information.
 * @param array  $render_options The TablePress render options.
 */
$rows = apply_filters( 'pods_pro_tablepress_data_rows', $rows, $columns, $pod_name, $pod, $params, $table, $render_options );