ACF Table Field Pro Add-on Docs Last updated:

Parent sources

On this page

Since version: v1.8.0

Release Candidate 1.8.0-RC1

This page documents version 1.8.0, which is available as Release Candidate 1.8.0-RC1 for manual installation. The current public version is 1.7.6, automatic plugin updates still deliver that version.

Download the Release Candidate from your account (Download the plugin) and install it manually (Install the plugin). Details may still change until the final release.

Filter acf_tablefield/formatting/cell_tokens

New since version 1.8.0

This filter is new.

This filter changes the formatting tokens of a table cell before they are output as the attribute data-acftf-format. See Cell formatting.

The tokens are the resolved values of the nine formatting options, see formatting options and values. A token is the prefix of the option plus the public value: va-middle, ha-start, fw-700, fs-italic, td-underline, tt-uppercase, ws-nowrap and nv-tabular. The font size is the prefix plus the stored key of the size: fz-l. An option that resolves to the theme or is not set anywhere has no token. The tokens come in the order of the options as listed here.

If the filter returns an empty array, the cell gets no attribute and does not load the stylesheet.

Set the PHP and the JavaScript filter the same way

This filter changes the table output on the website. The table editor in the WordPress admin resolves the tokens with JavaScript and has its own counterpart: the JS filter formatting / cell_tokens. To get the same look in the editor and on the website, set both filters the same way.

Parameters

add_filter( 'acf_tablefield/formatting/cell_tokens', function( $tokens, $table_data, $section_key, $row_index, $col_index ) { 
 
	// replace the token for the font weight 700 with an own token 
	foreach ( $tokens as $index => $token ) { 
 
		if ( 'fw-700' === $token ) { 
 
			$tokens[ $index ] = 'fw-heavy'; 
		} 
	} 
 
	return $tokens; 
}, 10, 5 );
    • $tokens
    • (array)
    • The formatting tokens of the cell, for example array( 'va-middle', 'fw-700' ). Options that resolve to the theme or have no value have no token.

    • $table_data
    • (array)
    • The raw data of the table, as it is stored (with the short keys).

    • $section_key
    • (string)
    • The key of the table section: h (header), b (body) or f (footer).

    • $row_index
    • (integer)
    • The index of the row within its section, starting at 0.

    • $col_index
    • (integer)
    • The index of the column, starting at 0.

Result

<td data-acftf-format="fw-heavy"></td>

Previous and Next Sources

Parent sources