Created
February 29, 2024 22:53
-
-
Save danielmcclure/cd247c4a2e2e910a9d1eca6a1ab79f7b to your computer and use it in GitHub Desktop.
Add Prefix to Search & Filter Option Labels
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 prefix to Search & Filter Option Labels | |
function filter_input_object($input_object, $sfid) { | |
//* Exclude all non-targeted fields | |
if(($input_object['name']!='_sft_field_name')) { | |
return $input_object; | |
} | |
//* Exclude fields without options | |
if(!isset($input_object['options'])) { | |
return $input_object; | |
} | |
// Add prefix to each option | |
foreach($input_object['options'] as $option) { | |
$option->label = "Prefix Text ".$option->label; | |
} | |
return $input_object; | |
} | |
add_filter('sf_input_object_pre', 'filter_input_object', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment