Created
June 17, 2018 17:01
-
-
Save badabingbreda/4149128b42a51e011fe08a7167489e94 to your computer and use it in GitHub Desktop.
Toolbox Example - Custom Text Codefield Filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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