Skip to content

Instantly share code, notes, and snippets.

@danielmcclure
Created February 29, 2024 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielmcclure/cd247c4a2e2e910a9d1eca6a1ab79f7b to your computer and use it in GitHub Desktop.
Save danielmcclure/cd247c4a2e2e910a9d1eca6a1ab79f7b to your computer and use it in GitHub Desktop.
Add Prefix to Search & Filter Option Labels
<?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