Skip to content

Commit

Permalink
Fix up issue with preview.
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Jennings on Mac committed Oct 23, 2013
1 parent 2195b6e commit ac462ad
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions modules/custom-status/custom-status.php
Expand Up @@ -104,7 +104,6 @@ function init() {
add_action( 'wp_insert_post', array( $this, 'fix_post_name' ), 10, 2 );
add_action( 'edit_form_after_title', array( $this, 'action_edit_form_after_title' ) );
add_filter( 'editable_slug', array( $this, 'fix_editable_slug' ) );
add_filter( 'preview_post_link', array( $this, 'fix_preview_link_part_one' ) );
add_filter( 'post_link', array( $this, 'fix_preview_link_part_two' ), 10, 3 );
add_filter( 'page_link', array( $this, 'fix_preview_link_part_two' ), 10, 3 );
add_filter( 'post_type_link', array( $this, 'fix_preview_link_part_two' ), 10, 3 );
Expand Down Expand Up @@ -1418,46 +1417,6 @@ public function fix_editable_slug( $slug ) {

}

/**
* Another hack! hack! hack! until core better supports custom statuses
*
* @since 0.7.4
*
* The preview link for an unpublished post should always be ?p=
*/
public function fix_preview_link_part_one( $preview_link ) {
global $pagenow;

$post = get_post( get_the_ID() );

// Only modify if we're using a pre-publish status on a supported custom post type
$status_slugs = wp_list_pluck( $this->get_custom_statuses(), 'slug' );
if ( ! $post
|| ! is_admin()
|| 'post.php' != $pagenow
|| ! in_array( $post->post_status, $status_slugs )
|| ! in_array( $post->post_type, $this->get_post_types_for_module( $this->module ) ) )
return $preview_link;

if ( 'page' == $post->post_type ) {
$args = array(
'page_id' => $post->ID,
);
} else if ( 'post' == $post->post_type ) {
$args = array(
'p' => $post->ID,
);
} else {
$args = array(
'p' => $post->ID,
'post_type' => $post->post_type,
);
}
$args['preview'] = 'true';
$preview_link = add_query_arg( $args, home_url() );
return $preview_link;
}

/**
* Another hack! hack! hack! until core better supports custom statuses
*
Expand Down

0 comments on commit ac462ad

Please sign in to comment.