CM Tooltip (CMTG) - Extras - Advanced Custom Fields (ACF) Support
How it works
ACF is only supported in the Pro version of the CM Tooltip Glossary plugin.
By default the CM Tooltip Glossary parses the content of posts/pages in search of the defined Glossary Terms using the "the_content" filter.
However, the ACF fields are not using this filter for the output, which means that despite the fact that they can contain complex HTML structures and many site owners are using them to built their layouts, they won't highlight the terms by default. To enable the parsing of the ACF fields, we have identified the code that ACF uses instead of "the_content", and we have prepared a set of options allowing you to setup the parsing.
After enabling it, the terms are parsed using exactly the same logic as the post/page content.
| Sometimes a site needs input from the community it serves.
With the Glossary Community Terms add-on users can help to build your glossary as you watch your key content grow.
The ACF settings are available in a section under Admin Dashboard → CM Tooltip → Settings → General Settings.
Below: Currently the Settings consist of four parts, but only one of them is really crucial: Highlight terms in ACF fields? Others just change the behavior.
In the settings section you can setup the following:
- Highlight terms in ACF Fields - This switch enables the whole functionality, regardless of what you set in the others after unchecking this the terms won't be highlighted in the ACF fields.
- Types of fields to highlight - Advanced Custom Fields come with many different field types, from which we've identified the 4 types which will most likely contain the terms to highlight.
- Types of fields to remove the WP functions - By default WordPress uses the functions which automatically wrap texts with paragraphs and adds newlines. These functions are often unwanted in case
of ACF fields and removed with the 'hacks'. After enabling the parser they were reapplied, so this setting allows to again remove those functions adding paragraphs and newlines.
- Don't use the DOM parser for ACF fields? - Warning: this setting should only be changed in case of problems. This setting allows to change our complicated HTML aware DOM parser with much simpler method of highlighting the terms.
- Excluded ACF Field IDs - using this field you can exclude a single field or group of fields from being parsed using either field name or field key:
- Field Name - example "item_desc_accordion_issue"
- Field Key - example "field_5888e68d97aa8"
How to obtain a Field Name and Field Key
Both can be obtained from the screen where you define the Advanced Custom Fields.
Field Names are displayed by default, and they always are a lowercased string concatenated with underscores(_).
Field Keys are not displayed by default, to show them you have to enable it in the Screen Settings.
Other settings which may affect the functionality
After enabling the feature and setting it up it will work using the same methods as the normal parsing, which means that all of the settings which would affect tooltips, will affect also the ones found in ACF fields.