• Resolved budasy

    (@budasy)


    WordPress 5.4.1
    Display Posts Version 3.0.2

    This an FYI, not a support request.

    While setting up a new list I was experimenting with options. To keep things simple and readable I began to use linefeeds to format the attributes in the shortcode. Using linefeeds in the shortcode generates odd results.

    The confusing thing is that a lot of things continue to work but some things break. This threw up some red-herrings, fortunately I didn’t need to do too much testing before I found the problem.

    When using linefeeds within the shortcode seems as though the value for some specified attributes is over-ridden with an empty value. When that happens the CSS inheritance chain is broken and stuff gets ugly.

    I didn’t see anything in the Shortcode API that prohibits the use of linefeed or carriage return when calling shortcodes.

    If your plugin shortcode was able to treat linefeeds and carriage returns as white space it would be more robust.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    Thank you for the feedback.

    I did some testing and this appears to be an issue with WordPress core. The Shortcode API is responsible for parsing the shortcode’s attributes and providing them to the shortcode’s function.

    Before WordPress runs do_shortcode() to render shortcodes, it runs wpautop() (“WP auto P”) which creates paragraphs, and converts new lines / carriage returns into HTML line breaks (<br />). The line breaks mess up the parsing of the shortcode attributes.

    I tried two different versions of the Display Posts shortcode: the first with new lines between attributes, and the second with spaces. I then looked to see what attributes were sent to the Display Posts function: https://a.cl.ly/9ZuE79GR

    Unfortunately I don’t think there’s anything Display Posts can do about this. The issue occurs before Display Posts runs.

    Thread Starter budasy

    (@budasy)

    Interesting! thanks for that info.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using carriage returns inside shortcode brackets really messes things up’ is closed to new replies.