is_preview example

$url = get_permalink();
    } else {
        if ( ! get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) {
            $url = add_query_arg( 'page', $iget_permalink() );
        } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) {
            $url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' );
        } else {
            $url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' );
        }
    }

    if ( is_preview() ) {

        if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id']$_GET['preview_nonce'] ) ) {
            $query_args['preview_id']    = wp_unslash( $_GET['preview_id'] );
            $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
        }

        $url = get_preview_post_link( $post$query_args$url );
    }

    return '<a href="' . esc_url( $url ) . '" class="post-page-numbers">';
}


    public function is_preview() {
        global $wp_customize;
        return ( isset( $wp_customize ) && $wp_customize->is_preview() );
    }

    /** * Generates the actual widget content (Do NOT override). * * Finds the instance and calls WP_Widget::widget(). * * @since 2.8.0 * * @param array $args Display arguments. See WP_Widget::widget() for information * on accepted arguments. * @param int|array $widget_args { * Optional. Internal order number of the widget instance, or array of multi-widget arguments. * Default 1. * * @type int $number Number increment used for multiples of the same widget. * } */
function redirect_canonical( $requested_url = null, $do_redirect = true ) {
    global $wp_rewrite$is_IIS$wp_query$wpdb$wp;

    if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ), true ) ) {
        return;
    }

    /* * If we're not in wp-admin and the post has been published and preview nonce * is non-existent or invalid then no need for preview in query. */
    if ( is_preview() && get_query_var( 'p' ) && 'publish' === get_post_status( get_query_var( 'p' ) ) ) {
        if ( ! isset( $_GET['preview_id'] )
            || ! isset( $_GET['preview_nonce'] )
            || ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] )
        ) {
            $wp_query->is_preview = false;
        }
    }

    if ( is_admin() || is_search() || is_preview() || is_trackback() || is_favicon()
        || ( $is_IIS && ! iis7_supports_permalinks() )
    ) {
        

function wp_post_preview_js() {
    global $post;

    if ( ! is_preview() || empty( $post ) ) {
        return;
    }

    // Has to match the window name used in post_submit_meta_box().     $name = 'wp-preview-' . (int) $post->ID;

    ?> <script> ( function() { var query = document.location.search; if ( query && query.indexOf( 'preview=true' ) !== -1 ) { window.name = '

function is_preview() {
    global $wp_query;

    if ( ! isset( $wp_query ) ) {
        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
        return false;
    }

    return $wp_query->is_preview();
}

/** * Is the query for the robots.txt file? * * @since 2.1.0 * * @global WP_Query $wp_query WordPress Query object. * * @return bool Whether the query is for the robots.txt file. */

function is_customize_preview() {
    global $wp_customize;

    return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
}

/** * Makes sure that auto-draft posts get their post_date bumped or status changed * to draft to prevent premature garbage-collection. * * When a changeset is updated but remains an auto-draft, ensure the post_date * for the auto-draft posts remains the same so that it will be * garbage-collected at the same time by `wp_delete_auto_drafts()`. Otherwise, * if the changeset is updated to be a draft then update the posts * to have a far-future post_date so that they will never be garbage collected * unless the changeset post itself is deleted. * * When a changeset is updated to be a persistent draft or to be scheduled for * publishing, then transition any dependent auto-drafts to a draft status so * that they likewise will not be garbage-collected but also so that they can * be edited in the admin before publishing since there is not yet a post/page * editing flow in the Customizer. See #39752. * * @link https://core.trac.wordpress.org/ticket/39752 * * @since 4.8.0 * @access private * @see wp_delete_auto_drafts() * * @global wpdb $wpdb WordPress database abstraction object. * * @param string $new_status Transition to this post status. * @param string $old_status Previous post status. * @param \WP_Post $post Post data. */
if ( $this->registered ) {
            return;
        }
        $this->registered = true;

        /* * Note that the widgets component in the customizer will also do * the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). */
        add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) );

        if ( $this->is_preview() ) {
            add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );
        }

        /* * Note that the widgets component in the customizer will also do * the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). */
        add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) );

        add_filter( 'display_media_states', array( $this, 'display_media_state' ), 10, 2 );
    }

    

    public function _register_one( $number = -1 ) {
        parent::_register_one( $number );
        if ( $this->registered ) {
            return;
        }
        $this->registered = true;

        if ( $this->is_preview() ) {
            add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );
        }

        /* * Note that the widgets component in the customizer will also do * the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). */
        add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) );

        /* * Note that the widgets component in the customizer will also do * the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). */

    }

    /** * If the theme to be previewed isn't the active theme, add filter callbacks * to swap it out at runtime. * * @since 3.4.0 */
    public function start_previewing_theme() {
        // Bail if we're already previewing.         if ( $this->is_preview() ) {
            return;
        }

        $this->previewing = true;

        if ( ! $this->is_theme_active() ) {
            add_filter( 'template', array( $this, 'get_template' ) );
            add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
            add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) );

            // @link: https://core.trac.wordpress.org/ticket/20027
Home | Imprint | This part of the site doesn't use cookies.