• Resolved Argumentum

    (@argumentum0)


    When I use a shortcode with a variable, and the variable value contain quotation marks, the variable is ignored — i.e., nothing appears on the page.

    Here are some tests I have made.

    1. Variable value containing plain text and quotation marks
    Example: [shortcode variable="I am "testing" quotation marks"]
    Result: Variable is ignored; nothing appears on the page.

    2. Variable value containing plain text and HTML code for quotation marks
    Example 1: [shortcode variable="I am "testing" quotation marks"]
    Example 2: [shortcode variable="I am &34;testing&34; quotation marks"]
    Result: Variable works; page shows I am "testing" quotation marks

    3. Variable value containing HTML tag and attribute value between quotation marks
    Example: [shortcode variable="<span class="test">I am testing quotation marks</span>"]
    Result: Variable is ignored; nothing appears on the page.

    4. Variable value containing HTML tag and attribute value with HTML code for quotation marks
    Example: [shortcode variable="<span class=&quot;test&quot;>I am testing quotation marks</span>"]
    Example: [shortcode variable="<span class=&34;test&34;>I am testing quotation marks</span>"]
    Result: Variable works incorrectly; in the example case, the class name itself gets quotation marks, so the text appears on the page without the style for the class named test. The source code will show the HTML codes (&quot; and &34;) as part of the class name, exactly as wrote in the shortcode; the element inspector will show <span class=""test"">I am testing quotation marks</span> (note the four quotation marks after class=).

    5. Variable value containing HTML tag and attribute value without quotation marks
    Example: [shortcode variable="<span class=test>I am testing quotation marks</span>"]
    Result: Variable works; page shows I am testing quotation marks with the correct style for the class named test.

    Would it be possible to update the plugin in order to get the quotation marks working properly?

    Thanks in advance.

    https://wordpress.org/plugins/post-snippets/

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

    This is outside the plugin’s control. The shortcode variables gets parsed by WordPress before the plugin receives them. WordPress’ shortcode system is not able to handle "..." inside shortcode variables already encapsulated in "...". So the plugin never receives any variables in that case as WordPress can’t handle it. WordPress shortcode shortcode system needs to be updated to handle what you request, so it is out of the scope of this plugin.

    For what you are looking for to work, WordPress needs to update the do_shortcode_tag() function in the Shortcodes API. Posting a request for that here might be a start, or creating a ticket in trac.

    In you specific examples, you can always go with a workaround, and use ' to encapsulate the variable.
    ie.
    [shortcode variable='I am "testing" quotation marks']
    which would work.

    Thread Starter Argumentum

    (@argumentum0)

    Thanks for the prompt answer, again.

    Sorry, I didn’t know about this limitation. I should have read the Codex first, it’s all there.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Variables content cannot contain quotation marks’ is closed to new replies.