[wp-trac] [WordPress Trac] #32954: "View post" link should not change when sample permalink changes

WordPress Trac noreply at wordpress.org
Fri Jul 10 01:03:53 UTC 2015


#32954: "View post" link should not change when sample permalink changes
-------------------------------+------------------------------
 Reporter:  johnbillion        |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  4.2
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |     Focuses:  administration
-------------------------------+------------------------------
Changes (by boonebgorges):

 * keywords:  needs-patch => has-patch


Comment:

 The reasoning behind [32002] was to make View Post point to a pretty
 permalink for scheduled posts; `get_permalink()` only returns a pretty
 permalink for posts with `post_status=publish`. The error in that
 changeset was to trust the `$post_name` variable, which is the *updated*
 post slug, rather than the one stored in the database. As you suggest, the
 saved slug should always be used.

 See [attachment:32954.diff], where I suggest using `$post->post_name`
 rather than `$post_name` in the `str_replace()` that generates the pretty
 permalink. I put in a special case `if ( 'publish' === $post->post_status
 ) { $pretty_permalink = get_permalink( $post ); }`; I'm pretty sure this
 is equivalent to the `str_replace()` in the `else` clause, but perhaps it
 makes it a bit clearer what's going on.

 @johnbillion Does this seem right to you?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/32954#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list