496 | | $wp_admin_bar->add_menu( array( |
497 | | 'id' => 'view', |
498 | | 'title' => $post_type_object->labels->view_item, |
499 | | 'href' => get_permalink( $post->ID ) |
500 | | ) ); |
| 496 | if( 'draft' == $post->post_status ) { |
| 497 | $preview_link = set_url_scheme( get_permalink( $post->ID ) ); |
| 498 | /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
| 499 | $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) ); |
| 500 | $wp_admin_bar->add_menu( array( |
| 501 | 'id' => 'preview', |
| 502 | 'title' => __( 'Preview' ), |
| 503 | 'href' => $preview_link |
| 504 | ) ); |
| 505 | } else { |
| 506 | $wp_admin_bar->add_menu( array( |
| 507 | 'id' => 'view', |
| 508 | 'title' => $post_type_object->labels->view_item, |
| 509 | 'href' => get_permalink( $post->ID ) |
| 510 | ) ); |
| 511 | } |