Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author pepe

    (@pputzer)

    Hello @magikweb!

    Please have a look at the first question in the FAQ. It should provide what you need to adapt your templates to use the_title_attribute instead of the_title. (It’s not about post titles in your case, but the underlying problem is the same.)

    • This reply was modified 7 years, 10 months ago by pepe.
    Thread Starter Vincent Poirier

    (@magikweb)

    Thank you for the help. I checked and the right function is called (I’m using Theme X).
    To fix the issue, I added the entry-thumb class in the “Ignore CSS classes” field and it fixed it.

    Thanks again!

    Plugin Author pepe

    (@pputzer)

    That’s slightly weird, because if that &shy; is resulting from filtering the_content, attribute nodes (like the title attribute of the <a> tag) should not be modified by the parser. What does the template generating that HTML code look like?

    Thread Starter Vincent Poirier

    (@magikweb)

    I may have looked at the wrong template file since there are many, but all occurrences had the right function used as far as I could see.
    This is where the issue was happening: https://www.magikweb.ca/blogue

    And this is the HTML code of that template (good luck to my markdown and no preview):

    switch ( is_singular() ) {
        case true:
          printf( '<div class="entry-thumb">%s</div>', $thumb );
          break;
        case false:
          printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
            esc_url( get_permalink() ),
            esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
            $thumb
          );
          break;
      }

    If you’d like more details to validate and make sure it’s not a bug, I can help you out. Like I said, it might be my own error that I am not looking at the right place, but I hardly think I’d be in the wrong file since it’s the only one with the class “entry-thumb”.

    Plugin Author pepe

    (@pputzer)

    Yeah, I’d like to check what’s going one there. Can you tell me more about the context of that template snippet? Is there some kind of output buffering or something? I still see the &shy;s in Chrome, BTW. Have you disabled your fix again?

    Plugin Author pepe

    (@pputzer)

    (BTW, why are the conditional hyphens in the title a problem? Entities should be perfectly harmless in an attribute.)

    Thread Starter Vincent Poirier

    (@magikweb)

    You’ve made me realize something important, it’s apparently not fixed! I tested it on Firefox on which it’s already OK, but on Chrome it doesn’t work, even with the CSS class ignored.

    On Google Chrome it’s the same.

    It’s visually an issue when optimizing our SEO, like “uti-li-ser” is the word “utiliser”.

    I’ll have to look into it furthermore…

    I don’t mind giving you access in private (email) if you’d like to check it out. It’s nothing big, but if the plugin can be improved, that’ll help us at the same time.

    Plugin Author pepe

    (@pputzer)

    You should not see “uti-li-ser” on hover. As for SEO, Google is smart enough to know the meaning of &shy; (i.e. to ignore it). But still, from that template snippet, the soft hyphens should not be there at all. I don’t need access to your site, but it’s probably easier if we discuss this via mail. Just leave me a comment on https://code.mundschenk.at/wp-typography/ if you’d like to get in touch.

    Plugin Author pepe

    (@pputzer)

    @magikweb I’ve not gotten your contact info yet.

    Plugin Author pepe

    (@pputzer)

    @magikweb: I’ve looked at the code again and I realized why it works the way it works: the_title_attribute does not circumvent all the filters hanging on the_title, it just uses strip_tags to remove HTML tags afterwards.

    What strip_tags does not remove is the soft hyphens (&shy;) added by hyphenation (which you can disable for post titles, by the way). If you want those gone, you would have to run the output of the_title_attribute through str_replace to remove those added characters:

    $clean_title = str_replace( array( \PHP_Typography\Strings::uchr( 173 ), \PHP_Typography\Strings::uchr( 8203 ) ), '', the_title_attribute( 'echo=0' ) );

    (The example is for the upcoming version 4.2.0, to use with 4.1.x, you have to use \PHP_Typography\uchr to access the same function. The snippet also removes any zero-width spaces that might be added by some of wp-Typography’s fixes.)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Title attribute processed’ is closed to new replies.