Linkify Text and Advanced Custom Fields

<?php /** * Linkify Text * https://de.wordpress.org/plugins/linkify-text/ * * Advanced Custom Fields Pro * https://www.advancedcustomfields.com/pro/ * * Genesis * https://my.studiopress.com/themes/genesis/ * * Motivation: Linkify Text uses WP Filters (defaults: the_content, the_excerpt, widget_text). * Filters can be added like this: $filters[] = 'the_meta' (reference: https://de.wordpress.org/plugins/linkify-text/) * However Advanced Custom Fields does not use a default filter but has it's own. * With the following workaround you can access ACF and apply the Linkify filter to it's content to make it actually work * * Use Linkify Text (1.9.1) with Advanced Custom Fields Pro and Genesis in Wordpress (4.9.8) * * functions.php (child theme) * */ function acf_load_value( $value ) { if(is_string($value)) { $instance = \c2c_LinkifyText::get_instance(); $value = $instance->linkify_text($value); } return $value; } // acf/load_value - filter for every wysiwyg value load (https://www.advancedcustomfields.com/resources/acf-load_value/) add_filter('acf/load_value/type=wysiwyg', __NAMESPACE__. '\acf_load_value', 10);
Access Advanced Custom Fields Filter with Linify Text in Genesis Framework (Wordpress)

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.