Created
March 15, 2021 18:55
-
-
Save georgestephanis/b374713c984583e05a4220e7a044cbb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'ppp_preview_link', 'my_ppp_preview_link', 10, 2 ); | |
function my_ppp_preview_link( $link, $post_id ) { | |
$found = preg_match( '#_ppp=([0-9A-F]{10})#i', $link, $matches ); | |
if ( ! $found ) { | |
return $link; | |
} | |
$args = array( | |
'preview' => '1', | |
'_ppp' => $matches[1], | |
); | |
list( $permalink, $postname ) = get_sample_permalink( $post_id ); | |
$raw_permalink = str_replace( '%postname%', $postname, $permalink ); | |
return add_query_arg( $args, $raw_permalink ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment