Make WordPress Core

Opened 11 years ago

Closed 9 years ago

#22127 closed defect (bug) (duplicate)

strange behaviour with shortcode with the_content filter

Reported by: thomask's profile thomask Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.2
Component: Shortcodes Keywords:
Focuses: Cc:

Description

let's say i have installed any lightbox/thickbox/... plugin (same behaviour with 'auto thickbox plus', 'lightview plus', 'jquery lightbox', 'fancybox plus', 'wp jquery lightbox' ...) and i have a shortcode, which uses the_content filter, e.g.

function test_shortcode( $atts, $content = null ) {
   return apply_filters('the_content', $content);
}
add_shortcode( 'test', 'test_shortcode' );

then if i use [test] shortcode anywhere in the post, the lightbox does not work. e.g.

[test]test[/test]

[caption ... /] // this is standard image

if the shortcode do not have the_content filter, or the shortcode is not use anywhere in the post, or i put the 'lightbox' etc. class to [a] directly than it works as a charm.

There may be a bug in the lightbox plugins, but it is strange, that it is in ALL lightbox plugins.

But even in that case for me it is very strange, that something what is INSIDE the shortcode affects OUTSIDE of the shortcode. That's why i think it is a bug of core.

Change History (2)

#1 @SergeyBiryukov
11 years ago

Possibly related: #19749

#2 @chriscct7
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #17817.

The key is that shortcodes are themselves implemented by a filter added to 'the_content'.
So you're effectively calling apply_filters( 'the_content' ) while 'the_content' filter is being applied.

Note: See TracTickets for help on using tickets.