Divi uses the values entered in a module's settings to generate the HTML output for the module. While Divi provides filters to modify the module setting values before they are used, it doesn't typically provide a way of modifying the values as they are finally used in the HTML. As such, it's not possible to make changes to the way Divi processes these values. For example, if you want to include some HTML in a field (perhaps adding a span tag to allow styling of part of a module title), Divi will encode the HTML so that it is displayed to the user, rather than included as part of the page structure, and offers no easy way to change this behavior. Here's what to do about it.
Filter the Output of Module Fields using Divi Shortcode Enabler
Divi Shortcode Enabler allows you to use shortcodes in a variety of module fields, where it's not normally possible to do so. The shortcode output is placed into the module field prior to Divi generating the HTML of the page. This normally works well and allows for dynamic pages and easy integration with a many plugins. However, if the shortcode being used includes HTML in its output, as many do, this HTML will usually be displayed to the user rather than being included in the page structure as would be expected.
To address this I've started adding a feature in Divi Shortcode Enabler which enables filtering of the final output of fields. This allows, for example, HTML in a field to be decoded in the final module output so that it becomes part of the module HTML structure, rather than just text displaying HTML tags.
Here are examples of the PHP code needed to decode HTML in various fields.
I've only added this filtering to a limited number of fields at the moment – if you need it on another field, let me know in the comments. Note that with Divi Shortcode Enabler installed, you can use these output filters, even if you aren't using shortcodes in your fields.
Related Post: Adding PHP to the Divi Theme
Accordion Module
add_filter('dbsce_accordion_item_title', 'html_entity_decode');
Button Module
add_filter('dbsce_button_button_text', 'html_entity_decode');
Contact Form Module
add_filter('dbsce_contact_form_success_message', 'html_entity_decode');
CTA Module
add_filter('dbsce_cta_button_text', 'html_entity_decode');
Pricing Table Module
add_filter('dbsce_pricing_table_button_text', 'html_entity_decode');
add_filter('dbsce_pricing_table_price', 'html_entity_decode');
add_filter('dbsce_pricing_table_frequency', 'html_entity_decode');
add_filter('dbsce_pricing_table_currency', 'html_entity_decode');
add_filter('dbsce_pricing_table_subtitle', 'html_entity_decode');
add_filter('dbsce_pricing_table_title', 'html_entity_decode');
Toggle Module
add_filter('dbsce_toggle_title', 'html_entity_decode');
0 Comments