Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1272087

    I have a webpage with tabs and the tab titles have accents (they are written in French – using WPML). The links are automatically generated by removing the letters that have the accent. For example, when having ‘Préparation’ as tab title, the link becomes ‘/prparation’. I would prefer that the link contains all the letters without the accents (so, in this case, ‘/preparation’). Would it be possible? Thank you!

    • This topic was modified 3 years, 10 months ago by albertgarduno.
    #1273163

    Hey albertgarduno,
    Sorry for the very late reply, try adding this code to the end of your functions.php file in Appearance > Editor:

    function custom_script() { ?>
        <script>
    (function($){
      $(document).ready(function(){
      $('html[lang="fr-FR"] #av-tab-section-1 > div > div.av-tab-section-tab-title-container a:first').each(function(){
        var tabtitle = 'preparation';
        $(this).attr('href', '#' + tabtitle);
    
    });
    });
    })(jQuery);
    </script>
        <?php
    }
    add_action('wp_footer', 'custom_script');

    Then clear your browser cache and check.

    Best regards,
    Mike

    #1274164

    Hi Mike,
    Thank you for your reply. I thought there could be an easier way to do it than editing the functions.php file. Also, because it’s not only the “preparation” tab but also the rest of the French ones. And in the future, there could be others. Is there anyway to edit those slugs without editing the functions.php file?
    Thank you in advance.
    Best,

    Albert

    #1274667

    Hi,
    Sorry for the late reply and good point, sorry I misunderstood. I have submitted this issue to the dev team for review and will reply when we hear back from the dev team. Thank you for your patience.

    Best regards,
    Mike

    #1275004

    Hi,
    Thank you for your patience, the dev team writes that this would not be able to be added to the core, but you can use a filter to adjust the tab section link, so for the example Préparation , the filter to add to your functions.php is:

    add_filter('avf_save_string_translated','avf_save_string_translated_mod');
    function avf_save_string_translated_mod($link){ 
    	if (strpos($link, 'prparation') !== false) {
    		return 'preparation';
    	}
    	else {return $link;}
    }

    you will note in the example the filter is looking for the text prparation , this is because at this point WordPress has already striped the é away. I tried to add a character conversion to the filter but I was not successful.

    Best regards,
    Mike

    #1275231

    Thank you Mike, I will try it this week. If I have any issue, I will let you know.
    Best,

    Albert

    #1275251

    Hi,
    Very good, the dev team has also added two new filters in the next update:

    added: filter ‘avf_tab_section_link_hash’: filter hash value for ALB tab section (e.g. replace non ASCII with custom value instead of removing)
    added: filter ‘avf_valid_href’: allows to replace invalid removed characters

    The filter above should continue to work, or you could use this filter with v4.8:

    add_filter('avf_tab_section_link_hash','avf_tab_section_link_hash_mod');
    function avf_tab_section_link_hash_mod($link){ 
    	if (strpos($link, 'prparation') !== false) {
    		return 'preparation';
    	}
    	else {return $link;}
    }

    We believe the next update will be around the end of Jan.

    Best regards,
    Mike

    #1275253

    Hi Mike,

    Thanks for the information! So, if I understood correctly, at the end of this month there will be an update that will solve my issue, right? Then, I will just wait for it :)

    Best,

    Albert

    #1275272

    Hi,
    Not exactly, in my tests with the beta, by the time the text is in the filter the é has already been removed, so using regex to replace the é , or any non ASCII character won’t work, thus the searching for the word missing the character prparation in the filter above.
    But the I am encouraged by the update notes, posted above, because the beta I’m testing with is not the final version.

    Best regards,
    Mike

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.