CM Tooltip (CMTG) - Extras - Advanced Custom Fields (ACF) Support
How it works
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've identified the ACF uses instead of "the_content" and we've prepared a set of options allowing to setup the parsing. After enabling it the terms are parsed using exactly the same logic as the post/page content.
This is only supported in the Pro version of the plugin
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.
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.