Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#21257 closed defect (bug) (duplicate)

Shortcode not working when another earlier defined shortcode contains new shortcode

Reported by: dannydehaan Owned by:
Priority: normal Milestone:
Component: Shortcodes Version:
Severity: normal Keywords:
Cc: Focuses:

Description

Hi All,

Hope my summary is clear enough.

The problem.

When you want to register a new shortcode and another shortcode that contains the new shortcode string is registered earlier, the earlier shortcode will be used by WordPress.

To make it more clear, here's an example.

add_shortcode( 'this-is-a-shortcode', 'this_is_a_shortcode' );
add_shortcode( 'this-is-a-shortcode-1', 'this_is_a_shortcode_1' );

function this_is_a_shortcode() {
	return 'Shortcode Used';
}

function this_is_a_shortcode_1() {
	return 'Shortcode 1 Used';
}

When i use the above and i call [this-is-a-shortcode-1] in my content, i get Shortcode Used instead of Shortcode 1 Used.

When you change the order of the shortcode registration, WordPress will return Shortcode 1 Used like it should be.

add_shortcode( 'this-is-a-shortcode-1', 'this_is_a_shortcode_1' );
add_shortcode( 'this-is-a-shortcode', 'this_is_a_shortcode' );

function this_is_a_shortcode() {
	return 'Shortcode Used';
}

function this_is_a_shortcode_1() {
	return 'Shortcode 1 Used';
}

I already searched in the wp-includes/shortcodes.php, but i saw a regex there and thougt... This isn't a fix for me ;)

Change History (2)

#1 @ocean90
14 years ago

  • Keywords close added; dev-feedback needs-patch removed

#2 @ocean90
14 years ago

  • Keywords close removed
  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed
  • Version 3.4.1
Note: See TracTickets for help on using tickets.