WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#31151 closed enhancement (fixed)

Pass $instance variable to post_gallery, post_playlist filters

Reported by: justincwatt Owned by: SergeyBiryukov
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.1
Component: Media Keywords: has-patch
Focuses: Cc:

Description

gallery_shortcode() and wp_playlist_shortcode() keep track of the number of times they're called with a static variable, $instance. This variable is important so that content (e.g. CSS) can be included only on the first function call, or so that unique IDs can be generated for HTML tags.

The problem is that this instance variable is not made available to their respective filters, post_gallery and post_playlist, unlike their shortcode siblings, wp_audio_shortcode() and wp_video_shortcode(), both of which pass the instance variable to their filters. Which means that any plugins seeking to adapt the behavior of these shortcodes do not have access to the same data as core.

Attachments (2)

media.php.diff (1.3 KB) - added by justincwatt 7 years ago.
Passing $instance variable to post_gallery and post_playlist filters
31151.diff (690 bytes) - added by ninnypants 7 years ago.
Add changelogs

Download all attachments as: .zip

Change History (8)

@justincwatt
7 years ago

Passing $instance variable to post_gallery and post_playlist filters

#1 @SergeyBiryukov
7 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.2

#2 @SergeyBiryukov
7 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 31304:

Pass the current shortcode instance ID to post_gallery and post_playlist filters.

props justincwatt.
fixes #31151.

#3 @SergeyBiryukov
7 years ago

In 31305:

Rename $instances to $instance in wp_audio_shortcode() and wp_video_shortcode() for consistency with gallery_shortcode() and wp_playlist_shortcode().

see #31151.

@ninnypants
7 years ago

Add changelogs

#4 @ninnypants
7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

There's a patch to add change log entries

Last edited 7 years ago by ninnypants (previous) (diff)

#5 @SergeyBiryukov
7 years ago

Good catch, thanks.

#6 @DrewAPicture
7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 31309:

Add changelog entries to the post_gallery and post_playlist hook docs for the $instance variable that was added in [31304].

Props ninnypants for the initial patch.
Fixes #31151.

Note: See TracTickets for help on using tickets.