-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish-view.php
More file actions
67 lines (57 loc) · 2.49 KB
/
Copy pathpublish-view.php
File metadata and controls
67 lines (57 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* Plugin Name: Publish & View
* Plugin URI: http://launchinteractive.com.au/wordpress/publish-view.zip
* Description: Adds a button so you can Publish and View Pages, Posts etc. in one step.
* Version: 1.3
* Author: Marc Castles
* Author URI: http://launchinteractive.com.au
* License: GPL2
*/
/*
Copyright 2014 Marc Castles (email : marc@launchinteractive.com.au)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
function publish_view_enqueue() {
global $post;
if(isset($post) && $post->post_type != 'acf' && in_array($post->post_status,array('auto-draft','draft','publish'))) {
global $wp_version;
if($wp_version < 3.8) {
wp_register_style( 'publish-view-dashicons', plugins_url('publish-view-dashicons.css', __FILE__) );
wp_enqueue_style( 'publish-view-dashicons' );
}
wp_register_style( 'publish-view', plugins_url('publish-view.css', __FILE__) );
wp_enqueue_style( 'publish-view' );
}
}
add_action( 'admin_enqueue_scripts', 'publish_view_enqueue' );
function publish_view_submitbox_start(){
global $post;
global $wp_version;
if($post->post_type != 'acf') {
if($post->post_status == 'auto-draft' || $post->post_status == 'draft') {
submit_button('','primary','publish',false, array('onclick'=>"jQuery(this).after('<input type=\"hidden\" name=\"publishview\" value=\"Y\" />')",'title'=>'Publish & View','id'=>'publishview'));
} else if($post->post_status == 'publish') {
submit_button('','primary','publish',false, array('onclick'=>"jQuery(this).after('<input type=\"hidden\" name=\"publishview\" value=\"Y\" />')",'title'=>'Update & View','id'=>'publishview'));
}
}
}
add_action( 'post_submitbox_start', 'publish_view_submitbox_start' );
function publish_view_redirect($location)
{
global $post;
if (isset($_POST['publishview'])) {
$location = get_permalink($post->ID);
}
return $location;
}
add_filter('redirect_post_location', 'publish_view_redirect');