Pass $post object to 'preview_post_link' filter.

props danielbachhuber.
fixes #28729.
Built from https://develop.svn.wordpress.org/trunk@28969


git-svn-id: http://core.svn.wordpress.org/trunk@28758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-07-03 14:42:15 +00:00
parent ece86c380b
commit 4e75d406ec
4 changed files with 10 additions and 8 deletions

View File

@ -661,9 +661,10 @@ class WP_Posts_List_Table extends WP_List_Table {
if ( $post_type_object->public ) { if ( $post_type_object->public ) {
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
if ( $can_edit_post ) { if ( $can_edit_post ) {
$preview_link = set_url_scheme( get_permalink( $post->ID ) );
/** This filter is documented in wp-admin/includes/meta-boxes.php */ /** This filter is documented in wp-admin/includes/meta-boxes.php */
$actions['view'] = '<a href="' . esc_url( apply_filters( 'preview_post_link', set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>'; $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
$actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
} }
} elseif ( 'trash' != $post->post_status ) { } elseif ( 'trash' != $post->post_status ) {
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>'; $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';

View File

@ -47,9 +47,10 @@ if ( 'publish' == $post->post_status ) {
* *
* @since 2.0.5 * @since 2.0.5
* *
* @param string $preview_link URI the user will be directed to for a post preview. * @param string $preview_link URI the user will be directed to for a post preview.
* @param WP_Post $post Post object.
*/ */
$preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) ); $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ) );
$preview_button = __( 'Preview' ); $preview_button = __( 'Preview' );
} }
?> ?>

View File

@ -1220,7 +1220,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
if( 'draft' == $post->post_status ) { if( 'draft' == $post->post_status ) {
$preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = set_url_scheme( get_permalink( $post->ID ) );
/** This filter is documented in wp-admin/includes/meta-boxes.php */ /** This filter is documented in wp-admin/includes/meta-boxes.php */
$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ); $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
$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"; $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";
} else { } else {
$return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n"; $return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
@ -1404,7 +1404,7 @@ function _admin_notice_post_locked() {
} }
/** This filter is documented in wp-admin/includes/meta-boxes.php */ /** This filter is documented in wp-admin/includes/meta-boxes.php */
$preview_link = apply_filters( 'preview_post_link', $preview_link ); $preview_link = apply_filters( 'preview_post_link', $preview_link, $post );
/** /**
* Filter whether to allow the post lock to be overridden. * Filter whether to allow the post lock to be overridden.
@ -1606,7 +1606,7 @@ function post_preview() {
$url = add_query_arg( $query_args, get_permalink( $post->ID ) ); $url = add_query_arg( $query_args, get_permalink( $post->ID ) );
/** This filter is documented in wp-admin/includes/meta-boxes.php */ /** This filter is documented in wp-admin/includes/meta-boxes.php */
return apply_filters( 'preview_post_link', $url ); return apply_filters( 'preview_post_link', $url, $post );
} }
/** /**

View File

@ -496,7 +496,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
if( 'draft' == $post->post_status ) { if( 'draft' == $post->post_status ) {
$preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = set_url_scheme( get_permalink( $post->ID ) );
/** This filter is documented in wp-admin/includes/meta-boxes.php */ /** This filter is documented in wp-admin/includes/meta-boxes.php */
$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ); $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
$wp_admin_bar->add_menu( array( $wp_admin_bar->add_menu( array(
'id' => 'preview', 'id' => 'preview',
'title' => __( 'Preview' ), 'title' => __( 'Preview' ),