Shortcode attribute value with dash (hyphen)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
3
down vote

favorite












Is it safe to use hyphen in shortcode attribute value?



For example:



[foo something="fo-bar"]






share|improve this question
















  • 1




    You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
    – Fayaz
    Aug 20 at 15:28
















up vote
3
down vote

favorite












Is it safe to use hyphen in shortcode attribute value?



For example:



[foo something="fo-bar"]






share|improve this question
















  • 1




    You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
    – Fayaz
    Aug 20 at 15:28












up vote
3
down vote

favorite









up vote
3
down vote

favorite











Is it safe to use hyphen in shortcode attribute value?



For example:



[foo something="fo-bar"]






share|improve this question












Is it safe to use hyphen in shortcode attribute value?



For example:



[foo something="fo-bar"]








share|improve this question











share|improve this question




share|improve this question










asked Aug 20 at 14:01









Toniq

171111




171111







  • 1




    You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
    – Fayaz
    Aug 20 at 15:28












  • 1




    You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
    – Fayaz
    Aug 20 at 15:28







1




1




You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
– Fayaz
Aug 20 at 15:28




You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
– Fayaz
Aug 20 at 15:28










2 Answers
2






active

oldest

votes

















up vote
-2
down vote



accepted










It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.




Take caution when using hyphens in the name of your shortcodes. In the
following instance WordPress may see the second opening shortcode as
equivalent to the first (basically WordPress sees the first part
before the hyphen):




[tag]
[tag-a]



It all depends on which shortcode is defined first. If you are going
to use hyphens then define the shortest shortcode first.



To avoid this, use an underscore or simply no separator:




[tag_a]





share|improve this answer
















  • 5




    Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
    – Fayaz
    Aug 20 at 15:30






  • 2




    @Fayaz Thanks for the comment. I would have missed that.
    – fredsbend
    Aug 20 at 22:36

















up vote
7
down vote














tl;dr; Dash (hyphen) - is safe to use within shortcode attribute values.





Rules for Shortcode attribute values:



For shortcode attribute values, anything other than the following four is usually fine:



  1. There shouldn't be any square brackets [ or ], e.g. [foo bar='baa]z']

  2. There shouldn't be single quote within single quote, e.g. [foo bar='baa'z']

  3. There shouldn't be double quote within double quote, e.g. [foo bar="baa"z"]

  4. Back slash will be escaped.


So the following example shortcode attribute values are just fine:



// dash or hyphen is fine
[foo bar='baa-z']
// Double quote within single quote is fine
[foo bar='baa"z']
// single quote within double quote is fine
[foo bar="baa'z"]
// space is fine
[foo bar='baa z']
// use double back slash to get single back slash
[foo bar='baa\z']


Quote from codex:




Attribute values must never contain the following characters:



Square braces: [ ]



Quotes: " '



Unquoted values also must never contain spaces.



HTML characters < and > have only limited support in attributes.



The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.



Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.



The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:



No-break space: xC2xA0



Zero-width space: xE2x80x8B







share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "110"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f311956%2fshortcode-attribute-value-with-dash-hyphen%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    -2
    down vote



    accepted










    It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.




    Take caution when using hyphens in the name of your shortcodes. In the
    following instance WordPress may see the second opening shortcode as
    equivalent to the first (basically WordPress sees the first part
    before the hyphen):




    [tag]
    [tag-a]



    It all depends on which shortcode is defined first. If you are going
    to use hyphens then define the shortest shortcode first.



    To avoid this, use an underscore or simply no separator:




    [tag_a]





    share|improve this answer
















    • 5




      Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
      – Fayaz
      Aug 20 at 15:30






    • 2




      @Fayaz Thanks for the comment. I would have missed that.
      – fredsbend
      Aug 20 at 22:36














    up vote
    -2
    down vote



    accepted










    It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.




    Take caution when using hyphens in the name of your shortcodes. In the
    following instance WordPress may see the second opening shortcode as
    equivalent to the first (basically WordPress sees the first part
    before the hyphen):




    [tag]
    [tag-a]



    It all depends on which shortcode is defined first. If you are going
    to use hyphens then define the shortest shortcode first.



    To avoid this, use an underscore or simply no separator:




    [tag_a]





    share|improve this answer
















    • 5




      Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
      – Fayaz
      Aug 20 at 15:30






    • 2




      @Fayaz Thanks for the comment. I would have missed that.
      – fredsbend
      Aug 20 at 22:36












    up vote
    -2
    down vote



    accepted







    up vote
    -2
    down vote



    accepted






    It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.




    Take caution when using hyphens in the name of your shortcodes. In the
    following instance WordPress may see the second opening shortcode as
    equivalent to the first (basically WordPress sees the first part
    before the hyphen):




    [tag]
    [tag-a]



    It all depends on which shortcode is defined first. If you are going
    to use hyphens then define the shortest shortcode first.



    To avoid this, use an underscore or simply no separator:




    [tag_a]





    share|improve this answer












    It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.




    Take caution when using hyphens in the name of your shortcodes. In the
    following instance WordPress may see the second opening shortcode as
    equivalent to the first (basically WordPress sees the first part
    before the hyphen):




    [tag]
    [tag-a]



    It all depends on which shortcode is defined first. If you are going
    to use hyphens then define the shortest shortcode first.



    To avoid this, use an underscore or simply no separator:




    [tag_a]






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Aug 20 at 14:07









    Castiblanco

    1,73221020




    1,73221020







    • 5




      Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
      – Fayaz
      Aug 20 at 15:30






    • 2




      @Fayaz Thanks for the comment. I would have missed that.
      – fredsbend
      Aug 20 at 22:36












    • 5




      Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
      – Fayaz
      Aug 20 at 15:30






    • 2




      @Fayaz Thanks for the comment. I would have missed that.
      – fredsbend
      Aug 20 at 22:36







    5




    5




    Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
    – Fayaz
    Aug 20 at 15:30




    Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
    – Fayaz
    Aug 20 at 15:30




    2




    2




    @Fayaz Thanks for the comment. I would have missed that.
    – fredsbend
    Aug 20 at 22:36




    @Fayaz Thanks for the comment. I would have missed that.
    – fredsbend
    Aug 20 at 22:36












    up vote
    7
    down vote














    tl;dr; Dash (hyphen) - is safe to use within shortcode attribute values.





    Rules for Shortcode attribute values:



    For shortcode attribute values, anything other than the following four is usually fine:



    1. There shouldn't be any square brackets [ or ], e.g. [foo bar='baa]z']

    2. There shouldn't be single quote within single quote, e.g. [foo bar='baa'z']

    3. There shouldn't be double quote within double quote, e.g. [foo bar="baa"z"]

    4. Back slash will be escaped.


    So the following example shortcode attribute values are just fine:



    // dash or hyphen is fine
    [foo bar='baa-z']
    // Double quote within single quote is fine
    [foo bar='baa"z']
    // single quote within double quote is fine
    [foo bar="baa'z"]
    // space is fine
    [foo bar='baa z']
    // use double back slash to get single back slash
    [foo bar='baa\z']


    Quote from codex:




    Attribute values must never contain the following characters:



    Square braces: [ ]



    Quotes: " '



    Unquoted values also must never contain spaces.



    HTML characters < and > have only limited support in attributes.



    The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.



    Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.



    The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:



    No-break space: xC2xA0



    Zero-width space: xE2x80x8B







    share|improve this answer


























      up vote
      7
      down vote














      tl;dr; Dash (hyphen) - is safe to use within shortcode attribute values.





      Rules for Shortcode attribute values:



      For shortcode attribute values, anything other than the following four is usually fine:



      1. There shouldn't be any square brackets [ or ], e.g. [foo bar='baa]z']

      2. There shouldn't be single quote within single quote, e.g. [foo bar='baa'z']

      3. There shouldn't be double quote within double quote, e.g. [foo bar="baa"z"]

      4. Back slash will be escaped.


      So the following example shortcode attribute values are just fine:



      // dash or hyphen is fine
      [foo bar='baa-z']
      // Double quote within single quote is fine
      [foo bar='baa"z']
      // single quote within double quote is fine
      [foo bar="baa'z"]
      // space is fine
      [foo bar='baa z']
      // use double back slash to get single back slash
      [foo bar='baa\z']


      Quote from codex:




      Attribute values must never contain the following characters:



      Square braces: [ ]



      Quotes: " '



      Unquoted values also must never contain spaces.



      HTML characters < and > have only limited support in attributes.



      The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.



      Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.



      The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:



      No-break space: xC2xA0



      Zero-width space: xE2x80x8B







      share|improve this answer
























        up vote
        7
        down vote










        up vote
        7
        down vote










        tl;dr; Dash (hyphen) - is safe to use within shortcode attribute values.





        Rules for Shortcode attribute values:



        For shortcode attribute values, anything other than the following four is usually fine:



        1. There shouldn't be any square brackets [ or ], e.g. [foo bar='baa]z']

        2. There shouldn't be single quote within single quote, e.g. [foo bar='baa'z']

        3. There shouldn't be double quote within double quote, e.g. [foo bar="baa"z"]

        4. Back slash will be escaped.


        So the following example shortcode attribute values are just fine:



        // dash or hyphen is fine
        [foo bar='baa-z']
        // Double quote within single quote is fine
        [foo bar='baa"z']
        // single quote within double quote is fine
        [foo bar="baa'z"]
        // space is fine
        [foo bar='baa z']
        // use double back slash to get single back slash
        [foo bar='baa\z']


        Quote from codex:




        Attribute values must never contain the following characters:



        Square braces: [ ]



        Quotes: " '



        Unquoted values also must never contain spaces.



        HTML characters < and > have only limited support in attributes.



        The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.



        Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.



        The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:



        No-break space: xC2xA0



        Zero-width space: xE2x80x8B







        share|improve this answer















        tl;dr; Dash (hyphen) - is safe to use within shortcode attribute values.





        Rules for Shortcode attribute values:



        For shortcode attribute values, anything other than the following four is usually fine:



        1. There shouldn't be any square brackets [ or ], e.g. [foo bar='baa]z']

        2. There shouldn't be single quote within single quote, e.g. [foo bar='baa'z']

        3. There shouldn't be double quote within double quote, e.g. [foo bar="baa"z"]

        4. Back slash will be escaped.


        So the following example shortcode attribute values are just fine:



        // dash or hyphen is fine
        [foo bar='baa-z']
        // Double quote within single quote is fine
        [foo bar='baa"z']
        // single quote within double quote is fine
        [foo bar="baa'z"]
        // space is fine
        [foo bar='baa z']
        // use double back slash to get single back slash
        [foo bar='baa\z']


        Quote from codex:




        Attribute values must never contain the following characters:



        Square braces: [ ]



        Quotes: " '



        Unquoted values also must never contain spaces.



        HTML characters < and > have only limited support in attributes.



        The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.



        Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.



        The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:



        No-break space: xC2xA0



        Zero-width space: xE2x80x8B








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 20 at 16:24

























        answered Aug 20 at 15:26









        Fayaz

        5,12811228




        5,12811228



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f311956%2fshortcode-attribute-value-with-dash-hyphen%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery