WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#35183 closed defect (bug) (wontfix)

Nested shortcode breaks wp.shortcode.replace() functionality

Reported by: prionkor Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Shortcodes Keywords:
Focuses: ui, javascript, administration Cc:
PR Number:

Description

I am going to give two simple examples of what I've found so far. Also note that this bug may be present in PHP api too (not tested) if the regex is same.

// the code below will work perfectly fine

var text = "This is some content with shortcode. [foo title="Call Us"]this is content[/foo]

text = wp.shortcode.replace('foo', text, function(tag){
    
    return '<p>Foo shortcode preview</p>';

});
// the shortcode tag inside callbacks gets wrong and broken value when there is a shortcode inside attribute value.

var text = "This is some content with shortcode. [foo title="Call Us at [phone]"]this is content[/foo]

text = wp.shortcode.replace('foo', text, function(tag){
    
    // attributes and content values are broken.

    return '<p>Foo shortcode preview</p>';

});

It seems if we have any nested shortcode inside the attribute value the attributes and contents are broken inside the shortcode object.

Change History (3)

#1 @Asgaros
4 years ago

I am not sure if shortcodes inside attributes have ever worked but the codex says that:

The shortcode parser does not accept square brackets within attributes.

See: http://codex.wordpress.org/Shortcode_API#Square_Brackets

#2 @prionkor
4 years ago

  • Keywords close added
  • Resolution set to wontfix
  • Status changed from new to closed

Yes, you are right. Putting shortcode inside attributes aren't allowed.

#3 @swissspidy
4 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.