• Resolved Tim Reeves

    (@tim-reeves)


    Dear Chris,

    many many thanks for this great plugin. I am really so thankful that I can use it. The flexibility and the amount of options is outstanding.

    But I have one problem: I’m using SEOPress and have selected its option to activate TinyMCE for the tag descriptions. I have a couple of websites where I make heavy use of several WP inbuilt features, like tags and commenting. I’m using the tags for example on my teachings page, which is why I have formatted them nicely with HTML.

    My problem, as you can see when you do a mouse hover over a term in the tag cloud in my right sidebar, is that HTML is not being stripped from the ‘title’ attribute of the hyperlink. So when the tooltip comes up, it’s not much pleasure to read.

    I can imagine three options which would help:

    1. Option to strip htl tags from the link’s title attribute
    2. Option to only allow max. ‘n’ characters in the title
    3. Option to completely suppress the title attribute

    The latter option may even be the best in my case – since I’ve written quite long descriptions for my tags, I’m fearing that Google may recognise repetition on my website: The teachings page will have all the same texts twice…

    Hope you can help. If it’s in the premium version, I’ll gladly buy a license.

    Cheers, Tim

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Tim,

    Thank you for that feedback!

    I installed SEOPress but I cannot find the option where to activate TinyMCE for tag descriptions. Could you give me a hint (if the issue still persists)?

    By default the plugin filters tag descriptions and you can enable HTML in the Tag Groups -> Front End -> Themes and Appearance settings. This, however, will be overridden by plugins that use the “unfiltered_html” filter for the particular user, which is probably the case for SEOPress.

    I therefore recommend to use the tag_groups_tag_title filter. Example: (add it in your child theme’s functions.php)

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

    That filter also allows you to reduce the length of the title.

    If you need to suppress the title completely, it should also work to use the parameter custom_title with an empty string (custom_title="").

    Thread Starter Tim Reeves

    (@tim-reeves)

    Dear Chris,

    many thanks for your prompt reply!

    Re SEOPress: SEO | Advanced | Advanced
    Then it’s the first checkbox: Add WP Editor to taxonomy description textarea

    Your filter works fine – when you know that SEOPress has ‘gone before’ and converted angle brackets to HTML entities )-:

    So my filter ended up looking like this:

    function tokenTruncate($string, $your_desired_width) {
      $parts = preg_split('/([\s\n\r]+)/u', $string, null, PREG_SPLIT_DELIM_CAPTURE);
      $parts_count = count($parts);
      $length = 0;
      $last_part = 0;
      for (; $last_part < $parts_count; ++$last_part) {
        $length += strlen($parts[$last_part]);
        if ($length > $your_desired_width) { break; }
      }
      return implode(array_slice($parts, 0, $last_part));
    }
    
    function tag_groups_sanitize_tag_title($title) {
    	$max_len = 88;
    	$htmltxt = html_entity_decode($title, ENT_NOQUOTES, 'UTF-8');
    	$txtonly = wp_strip_all_tags($htmltxt);
    	if (strlen($txtonly) <= $max_len) return $txtonly;
    	return tokenTruncate($txtonly, $max_len) . '&hellip;';
    }
    add_filter( 'tag_groups_tag_title', 'tag_groups_sanitize_tag_title' );

    So it’s a bit crazy, but it works ?? The tokenTruncate() function I found on the net.

    I’m really grateful!

    Tim

    Thanks for sharing!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Need options for tag link titles’ is closed to new replies.