• When activating the plugin, it seems that texturizing is not working properly any longer.

    For example, PRE elements will be ignored by wptexturize() when you add source code examples within a PRE element and double minus signs. However after activating WP YouTube Lyte, the double minus signs inside the PRE element get replaced by a long minus sign followed by a space.

    The cause of this strange effect is these code fragments:

            if ( apply_filters( 'lyte_kinda_textureize', true ) ) {
                $char_codes = array('×','–','\u002d');
                $replacements = array("x", "--", "-");
                $the_content=str_replace($char_codes, $replacements, $the_content);
            }
    
    
        if ( apply_filters( 'lyte_kinda_textureize', true ) ) {
            // replace remaining double dash but restore it in comment tags (this is getting ugly though).
            $the_content = str_replace( array( ' -- ', '-- ', ' --' ), ' – ', $the_content );
            $the_content = str_replace( '<! –', '<!--', $the_content );
            $the_content = str_replace( '– >', '-->', $the_content );
        }
    

    Why are the global replacements in the content done in the first place? This may cause any kind of trouble and the second code block seems to be a hack to restore comment tags which got damaged with the first replacement. Especially it is not correct to always replace -- with . This is clearly just not ok.

    As a workaround I disabled the stuff with a custom filter:

    
    function disable_lyte_kinda_textureize( $enabled )
    {
    	return false;
    }
    add_filter('lyte_kinda_textureize', 'disable_lyte_kinda_textureize');
    

    However I’d like to understand, why the replacement was done at all.

    • This topic was modified 5 years, 6 months ago by Arno Welzel.
    • This topic was modified 5 years, 6 months ago by Arno Welzel.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    As a workaround I disabled the stuff with a custom filter:

    that’s exactly what lyte_kinda_textureize was added for 🙂

    However I’d like to understand, why the replacement was done at all.

    honestly? i don’t remember, has been in there for ages and it *might* even not be needed any more, which is as a first step I added the filter 🙂

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Just for fun I checked the source code of the very first version of LYTE (from 10 years ago) and it indeed had those replacements already; https://plugins.trac.ww.wp.xz.cn/browser/wp-youtube-lyte/tags/0.1/wp-youtube-lyte.php

    If I remember correctly it was based on what the then popular Smart Youtube plugin did as well (and I still see it in their source code).

    All of which does not say this is (still) needed .. We’ll see if/ when I can make the filter default false in the future as a next step.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Damaging content in PRE elements’ is closed to new replies.