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
1221           $return .= '‎'; // Fix bi-directional text display defect in RTL languages.
1222           $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";
1223           $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
1224      }
1225
1226      if ( isset( $view_post ) ) {
1227           if( 'draft' == $post->post_status ) {
1228                $preview_link = set_url_scheme( get_permalink( $post->ID ) );
1229                /** This filter is documented in wp-admin/includes/meta-boxes.php */
1230                $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
1231                $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";
1232           } else {
1233                $return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
1234           }
1235      }
1236
1237      /**
1238       * Filter the sample permalink HTML markup.
1239       *
 
Line Code
1405                     // Latest content is in autosave
1406                     $nonce = wp_create_nonce( 'post_preview_' . $post->ID );
1407                     $preview_link = add_query_arg( array( 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), $preview_link );
1408                }
1409           } else {
1410                $preview_link = '';
1411           }
1412
1413           /** This filter is documented in wp-admin/includes/meta-boxes.php */
1414           $preview_link = apply_filters( 'preview_post_link', $preview_link, $post );
1415
1416           /**
1417            * Filter whether to allow the post lock to be overridden.
1418            *
1419            * Returning a falsey value to the filter will disable the ability
1420            * to override the post lock.
1421            *
1422            * @since 3.6.0
1423            *
 
Line Code
1607           $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID );
1608
1609           if ( isset( $_POST['post_format'] ) )
1610                $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] );
1611      }
1612
1613      $url = add_query_arg( $query_args, get_permalink( $post->ID ) );
1614
1615      /** This filter is documented in wp-admin/includes/meta-boxes.php */
1616      return apply_filters( 'preview_post_link', $url, $post );
1617 }
1618
1619 /**
1620  * Save a post submitted with XHR
1621  *
1622  * Intended for use with heartbeat and autosave.js
1623  *
1624  * @since 3.9.0
1625  *