WordPress.org

Make WordPress Core

Ticket #20098: remove-preview.txt

File remove-preview.txt, 580 bytes (added by tamlyn, 3 years ago)

Remove preview button

Line 
1<?php
2
3if(preg_match('|wp-admin/post(-new)?\.php|', $_SERVER['REQUEST_URI'])) {
4        ob_start('my_filter_post_page');
5}
6function my_filter_post_page($content) {
7        global $post, $wp_post_types;
8        //remove preview button and view post message
9        if (!$wp_post_types[$post->post_type]->publicly_queryable) {
10                $content = preg_replace("/<div id=\"preview-action\">.*?<\/div>/mis", '', $content);
11                $content = preg_replace("/<div id=\"edit-slug-box\">.*?<\/div>/mis", '', $content);
12                $content = preg_replace("/<a href=\"[^\"]*\">View post<\/a>/mis", '', $content);
13        }
14
15        return $content;
16}
17
18?>