• Resolved t33b33

    (@t33b33)


    I am using a shortcode to (intentionally) create text with HTML entities. The wp-Typography the_content filter seems to convert these entities back to the corresponding characters, regardless of whether the CSS class noType is defined for a tag in question or not. Is my observation correct? And if so, what can be done to preserve the HTML entities when using wp-Typography?

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

    (@pputzer)

    The content is parsed as HTML5 before the rules for not processing certain elements can be checked. What is your goal here? If you want to show the entities string in the browser, they need to be properly escaped.

    Thread Starter t33b33

    (@t33b33)

    I would like to obfuscate email addresses using antispambot(), although it is questionable whether this technique is even useful nowadays.
    My best solution so far is to use an additional the_content shortcode filter after the wp-Typography filter, which might work like this:

    add_filter( ‘the_content’, function( $content ) {
    add_shortcode( ‘some_tag’, ‘some_callback’ );
    $content = do_shortcode( $content );
    remove_shortcode( ‘some_tag’ );
    return $content;
    }, 10000 );

    Admittedly, that’s not really nice. Do you have any better ideas?

    Plugin Author pepe

    (@pputzer)

    Yes, postponing the shortcode processing until after wp-Typography is done is probably the only way to do this. (I think that’s a perfectly fine use of filter priorities, BTW). Just note that the priority might be PHP_INT_MAX if you have NextGen Gallery installed. In that case, adding the filter would have to rely on order of execution, so you would need to delay the add_filter call until after the init action.

    Thread Starter t33b33

    (@t33b33)

    Essentially, this is how I will do it then. Thank you for your quick reply and especially for your great plugin.

    Plugin Author pepe

    (@pputzer)

    Thank you. Feel free to reopen if you any further questions on this topic.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Preserving html entities’ is closed to new replies.