Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: preview_post_link

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
1301           $return .= '‎'; // Fix bi-directional text display defect in RTL languages.
1302           $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __( 'Edit' ) . "</a></span>\n";
1303           $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
1304      }
1305
1306      if ( isset( $view_post ) ) {
1307           if( 'draft' == $post->post_status ) {
1308                $preview_link = set_url_scheme( get_permalink( $post->ID ) );
1309                /** This filter is documented in wp-admin/includes/meta-boxes.php */
1310                $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
1311                $return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n";
1312           } else {
1313                if ( empty( $pretty_permalink ) ) {
1314                     $pretty_permalink = $permalink;
1315                }
1316
1317                $return .= "<span id='view-post-btn'><a href='" . $pretty_permalink . "' class='button button-small'>$view_post</a></span>\n";
1318           }
1319      }
 
Line Code
1489                     // Latest content is in autosave
1490                     $nonce = wp_create_nonce( 'post_preview_' . $post->ID );
1491                     $preview_link = add_query_arg( array( 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), $preview_link );
1492                }
1493           } else {
1494                $preview_link = '';
1495           }
1496
1497           /** This filter is documented in wp-admin/includes/meta-boxes.php */
1498           $preview_link = apply_filters( 'preview_post_link', $preview_link, $post );
1499
1500           /**
1501            * Filter whether to allow the post lock to be overridden.
1502            *
1503            * Returning a falsey value to the filter will disable the ability
1504            * to override the post lock.
1505            *
1506            * @since 3.6.0
1507            *
 
Line Code
1688           $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID );
1689
1690           if ( isset( $_POST['post_format'] ) )
1691                $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] );
1692      }
1693
1694      $url = add_query_arg( $query_args, get_permalink( $post->ID ) );
1695
1696      /** This filter is documented in wp-admin/includes/meta-boxes.php */
1697      return apply_filters( 'preview_post_link', $url, $post );
1698 }
1699
1700 /**
1701  * Save a post submitted with XHR
1702  *
1703  * Intended for use with heartbeat and autosave.js
1704  *
1705  * @since 3.9.0
1706  *