Make WordPress Core


Ignore:
Timestamp:
09/15/2015 04:14:23 AM (9 years ago)
Author:
wonderboymusic
Message:

Create a function, get_preview_post_link(), to DRY the logic for applying the 'preview_post_link' filter to a URL.

Props TomHarrigan, wonderboymusic.
Fixes #24345.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r34109 r34170  
    900900    global $wp_rewrite;
    901901    $post = get_post();
     902    $query_args = array();
    902903
    903904    if ( 1 == $i ) {
     
    913914
    914915    if ( is_preview() ) {
    915         $url = add_query_arg( array(
    916             'preview' => 'true'
    917         ), $url );
    918916
    919917        if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
    920             $url = add_query_arg( array(
    921                 'preview_id'    => wp_unslash( $_GET['preview_id'] ),
    922                 'preview_nonce' => wp_unslash( $_GET['preview_nonce'] )
    923             ), $url );
    924         }
     918            $query_args['preview_id'] = wp_unslash( $_GET['preview_id'] );
     919            $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
     920        }
     921
     922        $url = get_preview_post_link( $post, $query_args, $url );
    925923    }
    926924
Note: See TracChangeset for help on using the changeset viewer.