Support » Plugin: Public Post Preview » Public Preview Marker persists after publish

  • When enabling public preview on a draft post, it adds a marker in the posts list, but when the post is finally published it persists. I would expect it to disappear, and no UI controls to disable public preview are present on published posts

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Dominik Schilling

    (@ocean90)

    WordPress Core Developer

    Hello @tjnowell, can you please provide some more details? Are there any other plugins active? Does it still happen with all plugins disabled and a default theme activated? What’s the previous status of the post?

    To reproduce:

    • Create a draft post and save
    • set the post for public preview and save
    • publish the post

    I believe the culprit is this function:

    
    	/**
    	 * Adds "Public Preview" to the list of display states used in the Posts list table.
    	 *
    	 * @since 2.4.0
    	 *
    	 * @param array   $post_states An array of post display states.
    	 * @param WP_Post $post        The current post object.
    	 * @return Filtered array of post display states.
    	 */
    	public static function display_preview_state( $post_states, $post ) {
    		if ( in_array( $post->ID, self::get_preview_post_ids() ) ) {
    			$post_states['ppp_enabled'] = __( 'Public Preview', 'public-post-preview' );
    		}
    
    		return $post_states;
    	}
    

    No check is made to see if the post has already been published

    The issue dissapears when this modification is made to the function mentioned above:

    
            public static function display_preview_state( $post_states, $post ) {
                    if ( 'publish' === $post->post_status ) {
                            return $post_states;
                    }
    

    But it would seem the root issue is that either unregister_public_preview_on_status_change is not being called, or it is but then register_public_preview is called afterwards. Regardless of the cause I think adding the check is a good step

    There are other plugins active, but I can’t deactivate on a live site, I can debug in a proper environment locally tomorrow

    Plugin Author Dominik Schilling

    (@ocean90)

    WordPress Core Developer

    @tjnowell Do you have any news here?

    I’ve nothing new to report, I don’t think I ever got around to debugging and the fix I posted earlier meant this hasn’t been an issue since. I’d recommend including the check in the next update

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Public Preview Marker persists after publish’ is closed to new replies.