• Resolved tizz

    (@tizz)


    Thank you very much for this nice plugin, which I am testing and I would like to use. Despite some issues (e.g. “accordion”, “tabbed”, and more, but at the moment I don’t care) I’m satisfied how the page with the “tag list” shortcode is rendered. The only problem is that the tooltip that appears when hovering over the link shows all the HTML tags and this is very bad because in those tag descriptions there are a lot of them, e.g. italics (so you see, for example, < em > … < /em >) that I use mainly for musical terminology in English (not the language in which I write), and also many links that send to my articles (i.e. all markup: < a title=”…” href=”…” target=”_blank” rel=”noopener” >…< /a> ).
    Other problems are that the description is visible in its entirety, but basically all of them are very long and I would like only an excerpt, like two or three lines – and also there is a number in brackets at the end, which I guess is the post_count, but I don’t want it. I’m not a coder at all, but looking here and there (your documentation) I managed to create this filter:

    function tag_groups_sanitize_tag_title($title) {
      return tag_description ($title);
    }
    add_filter( 'tag_groups_tag_title', 'tag_groups_sanitize_tag_title' );

    which is certainly poorly written and doesn’t do what I would like, but at least it makes the description invisible, i.e. completely eliminates the tooltip. This is the last resort for me if you can’t tell how to strip the HTML and get the excerpt, but possibly I was wondering if you can fix that function above, i.e. remove the tooltip completely from tag_groups_tag_list as it does, but with a correct code.
    However for me the ideal solution would be to have a function / filter that shows the tooltip without HTML tags and with an excerpt, without the post_count. Is it possible?
    Thanks very much for the attention.

    • This topic was modified 3 years, 2 months ago by tizz.
    • This topic was modified 3 years, 2 months ago by tizz.
Viewing 15 replies - 1 through 15 (of 15 total)
  • Please see this thread.

    So you could try:

    function tag_groups_sanitize_tag_title($title) {
      return wp_strip_all_tags($title);
    }
    add_filter( 'tag_groups_tag_title', 'tag_groups_sanitize_tag_title' );

    or

    function tag_groups_sanitize_tag_title($title) {
      return strip_tags($title);
    }
    add_filter( 'tag_groups_tag_title', 'tag_groups_sanitize_tag_title' );

    or

    function tag_groups_sanitize_tag_title($title) {
      return '';
    }
    add_filter( 'tag_groups_tag_title', 'tag_groups_sanitize_tag_title' );

    In the shortcode you can also try custom_title="".

    Thread Starter tizz

    (@tizz)

    Thank you very much @camthor for your prompty reply, but those functions are more or less the same from which I started, taking it from the same thread you reported.
    The first two does nothing at all, and does not strip HTML, does not do excerpt / does not remove final number in brackets from the tag description in tooltip.

    The third is the same like “mine”, with the only difference of an empty “return”, so it does the same: remove tooltip altogether.

    I’m not a programmer at all, but for what I asked it seemed logical to me find in the function / filter at least the words “HTML”, “excerpt”, “tag description”, and so on, otherwise I don’t see how it could work.

    As for the shortcode suggestion (my current shortcode looks like this: [tag_groups_tag_list column_count=3]), adding custom_title=”” removes tooltip altogether.
    Is there really nothing better to try before keeping it as a downside solution?

    One more option came up:

    function tag_groups_sanitize_tag_title($title) {
      return wp_strip_all_tags(html_entity_decode($title));
    }
    add_filter( 'tag_groups_tag_title', 'tag_groups_sanitize_tag_title' );

    I will also add an easier option in the next version (Front End settings).

    PS: Our two posts were overlapping. I think it could work with html_entity_decode(). This is a problem with the wp_strip_all_tags() and strip_tags() functions.

    Thread Starter tizz

    (@tizz)

    Hi Chris, the new code works perfectly for stripping HTML, thanks! Unfortunately, the issue now is that it removes also all the following words if quotation marks are present; e.g., I have this tag description:

    Deep Ellum (distorsione di “deep Elm Street”), and bla bla…

    that becomes:

    Deep Ellum (distorsione di

    If you replace wp_strip_all_tags by strip_tags, does it keep the inner parts?

    Thread Starter tizz

    (@tizz)

    Sorry, strip_tags does not keep the inner parts.
    Gives the same result as above.

    Actually, I think it doesn’t have to do with stripping tags. The problem could be that you use the same type of quotes that we use in the HTML. If the tag cloud does something like <a title=""> and you use a title that contains di "deep then it combines to <a title="di "deep"> and that means that the title="" closes too early (before deep). This is simply a problem of HTML.

    So you could replace all " by ':

    function tag_groups_sanitize_tag_title($title) {
      return str_replace( '"', "'", wp_strip_all_tags( html_entity_decode( $title ) ) );
    }
    add_filter( 'tag_groups_tag_title', 'tag_groups_sanitize_tag_title' );
    Thread Starter tizz

    (@tizz)

    Hi Chris, thank again for your time.
    When writing text I use the normal quotation marks that are always used, the ones that on the keyboard are above the “2” key, and they contain text, not a title tag.
    I don’t fully understand what you said about the HTML problem (< a title >, etc.), or maybe in part but I don’t think it has anything to do with it as the quotation marks are in the text, not inside the HTML, where I know that something like &quot; must be used inside an HTML tag to make the quotes, otherwise it will be stripped.

    In my site I use a footnotes plugin that creates tooltips when hovering the link of the note number in the text. I have never had issues with HTML markup, and quotation marks in the text are displayed how they should be, see here for example (please hover the mouse over the note no 3).
    In the example, however, we are dealing with articles, i.e. text written in the normal WP editor intended for writing posts as articles.

    Below, two images of the page in which I am testing (locally) your plugin. As you can see in the first (without any code, the situation that display HTML tags) the quoted text is normally seen, while in the second, with the code that strips the HTML, you see the break before the quotation marks.

    https://snipboard.io/h7E9rt.jpg

    https://snipboard.io/zDkw5A.jpg

    Your last function works fine, but it is not so correct replace quotation marks ” ” with ‘ ‘ and above all there should be no need because quotation marks, like other punctuation marks, should be rendered like they are.
    The only thing I can think about is: is it possible that the problem is the WP editor, the one used for the tag descriptions, not really suitable for handling texts in the same way as the normal editor for posts (classic or Gutemberg) does?

    Your first link demonstrates what I explained before. The HTML code is:
    <a href="#footnote_2_6297" id="identifier_2_6297" class="footnote-link footnote-identifier-link" title="“Eight to the bar” sono otto crome a battuta dato che, di solito, nel genere di musica di cui stiamo parlando e in cui si usa questa terminologia, la misura s’intende di quattro battiti.">3</a>

    As you can see there, the quotes have been converted to “...” – that’s why they don’t conflict with the " quotes from the HTML code. HTML doesn’t know if the double quotes are part of the text or part of the code. One opens the string and the next one closes it again. Quotes and some other special characters have a different meaning in HTML, unfortunately we cannot change that.

    In the last code that I sent you, you can replace "'" with anything else you like, for example "“" or """. If you want it more complicated, like a different quote before and after the word, you can certainly find a developer who will be happy to write the code for you.

    Thread Starter tizz

    (@tizz)

    OK thanks, I understand now what you mean, but anyway I don’t understand why elsewhere, i.e. in the tooltips of the footnotes, the normal quotes on the keyboard in that HTML are automatically converted into the other type of quotes, let’s say RTF, so to avoid conflict, while here, in the tooltips of the tag descriptions, it does not happen… unless you have a function like the one you kindly provided me (same thing I could say for the visible HTML: in the tooltips of the footnotes does not happen).
    So I thought it was because of the non-advanced WordPress editor where the tag description is written.

    I don’t want anything complicated, but rather the exact opposite: just that what I write is printed as it is, and I didn’t know that there in the function I had/could replace with : it isn’t a character on visible keyboard keys.

    The reason is that the footnote text is part of the text body of pages or posts. WordPress does the conversion with all the rest of the text. Tags need to inserted separately.

    The new version 1.43.6 is now out. You can try if Front End > Themes and Appearance “HTML in tag description: remove” helps you. But you may have to remove your custom code again.

    Thread Starter tizz

    (@tizz)

    Hi Chris, the option works fine.

    As for the excerpt, if you have any ideas/suggestion and this don’t bother you too much I would be happy to know at any time.

    Thank you.

    If you want to show only the tag description (what you write on the page where you edit the tags) without the post count, you use in the shortcode:

    ... custom_title="{description}" ...

    more information

    Thread Starter tizz

    (@tizz)

    Thanks again.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘HTML tags in tooltip’ is closed to new replies.