Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save badabingbreda/4149128b42a51e011fe08a7167489e94 to your computer and use it in GitHub Desktop.
Save badabingbreda/4149128b42a51e011fe08a7167489e94 to your computer and use it in GitHub Desktop.
Toolbox Example - Custom Text Codefield Filter
<?php
add_filter( 'toolbox/helpers/get_acf_field/type=text', 'my_text_codefield_filter', 10, 5 );
/**
* Your custom filter for a text-field with the name 'codefield'
*/
public static function my_text_codefield_filter( $string , $field_object , $value , $atts = null , $postid = null ) {
// check if the requested fieldname is 'codefield' and the type of the field_object is 'text'
// if so, append and prepend the string by <code></code>
if ( $atts['field'] == 'codefield' && $field_object[ 'type' ] == 'text' ) return '<code>' . $string . '</code>';
// if not, pass the input-string to the next filter
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment