Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#19378 closed defect (bug) (fixed)

post_preview() does not apply the preview_post_link filter

Reported by: atetlaw Owned by: SergeyBiryukov
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.2.1
Component: Administration Keywords: has-patch 3.6-early commit
Focuses: Cc:


The post_preview() function (line # 1367 in wp-admin/includes/post.php) does not apply the preview_post_link filter and it probably should.

The code to generate the anchor tag for the post preview button DOES apply the filter and the correct URL is generated. However the button, via javascript, ignores that URL and submits the post form, triggering the 'preview' action in the redirect_post() function. The redirect_post() function obtains the redirect URL from the post_preview() function.

The upshot of that is although the correct URL is generated for the anchor tag for the Preview button, clicking the button opens the standard preview URL.

Attachments (2)

19378.patch (425 bytes) - added by SergeyBiryukov 3 years ago.
19378.2.patch (1.6 KB) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (12)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to Administration
  • Keywords has-patch added

#2 @danielbachhuber
3 years ago

Just ran into this too. Seems like an easy win. 3.6-early?

#3 @danielbachhuber
3 years ago

  • Cc danielbachhuber added

#4 @SergeyBiryukov
3 years ago

  • Keywords 3.6-early added
  • Milestone changed from Awaiting Review to Future Release

#5 @danielbachhuber
3 years ago

For other people that need an intermediate solution, here's a workaround I came up with that you can modify to your needs: https://github.com/danielbachhuber/Edit-Flow/commit/79a70d55a2ae482ef9d6df6061dbde12d821e836

#7 @danielbachhuber
3 years ago

19378.2.patch looks pretty good. Thanks SergeyBiryukov

#8 @SergeyBiryukov
3 years ago

  • Milestone changed from Future Release to 3.6

#9 @SergeyBiryukov
3 years ago

  • Keywords commit added

#10 @SergeyBiryukov
3 years ago

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

In 23560:

Consistently apply 'preview_post_link' filter. fixes #19378.

Note: See TracTickets for help on using tickets.