Forums Forums Search & Filter Pro using string to translate text in within filter

Viewing 6 posts - 21 through 26 (of 26 total)
  • Anonymous
    #214552

    Hello Yes they both appeared but when I refreshed my browser Brochures got replaced with Test so I removed your echo code I added and it was still there so it must have been some kind of caching issue.

    At least I know now the codes works in the correct place. May I ask how I can add multiple text replacements in this?

    Thanks

    Anonymous
    #214554

    Ignore my last message I believe it was because I changed the _sft_file_type[] to _sft_file_type.

    I have also worked out how add multiple text. I have tried the same code trying to replace the text on the dropdown menus. I cant seem to get these to work can you help me with those aswell.

    Thanks

    Ross Moderator
    #214655

    Hi again

    Can you confirm that the orginal label change is now working?

    If so, then please provide your updated code, with explanations (comments) of what each part is supposed to do, and I’ll try to tell you where it looks like its going wrong.

    Thanks

    Anonymous
    #214759

    Hello to update this I have now got the the code working correctly. Here shows 2 text replacement one after the other.

    function my_plugin_search_filter_change_label($input_object, $sfid) {
     if ($sfid == 845 && $input_object['name'] == '_sft_category') {
          
      foreach ($input_object['options'] as $key => $option) {
          if ($option->label == 'All Categories') {
    
            $input_object['options'][$key]->label = 'Toutes Catégories';
          }
        }
      foreach ($input_object['options'] as $key => $option) {
          if ($option->label == 'Accessories and Cables') {
    
            $input_object['options'][$key]->label = 'Accessoires et Câbles';
          }
        }
      }
     return $input_object;
    }
    
    add_filter('sf_input_object_pre', 'my_plugin_search_filter_change_label', 10, 2);
    Anonymous
    #214761

    Thanks for you help on this 🙂

    Trevor
    #214765

    Could you not do that inside a single foreach, and use switch instead of multiple ifs?

Viewing 6 posts - 21 through 26 (of 26 total)