Changeset 354158
- Timestamp:
- 03/02/2011 03:23:45 PM (15 years ago)
- Location:
- live-drafts/trunk
- Files:
-
- 1 added
- 2 edited
-
liveDrafts.php (modified) (7 diffs)
-
readme.txt (modified) (1 diff)
-
screenshot-1.jpg (added)
Legend:
- Unmodified
- Added
- Removed
-
live-drafts/trunk/liveDrafts.php
r341286 r354158 5 5 Author: Stephen Sandison 6 6 Author URL: http://www.designbuildhost.co.uk/ 7 Version: 3.0 7 Version: 3.0.1 8 8 */ 9 9 /* Copyright 2011 Stephen Sandison (email : stephen.sandison@gmail.com) … … 37 37 38 38 } 39 40 /* Activation function */ 41 function activate () { 42 43 // Nothing to see here, yet! 44 45 } 46 39 47 40 function adminHead () { 48 41 global $post; 49 42 50 43 // Only show on published pages 51 if ( ($post->post_type == 'page' || $post->post_type == 'post') && $post->post_status == 'publish') {44 if (in_array($post->post_type, array('post', 'page')) && $post->post_status == 'publish') { 52 45 ?> 53 46 <script type="text/javascript" > … … 72 65 return $id; 73 66 67 // Only continue if this request is for the post or page post type 68 if (!in_array($_POST['post_type'], array('post', 'page'))) { 69 return $id; 70 } 71 74 72 // Check permissions 75 if ( 'page' == $_POST['post_type'] ) { 76 if ( !current_user_can( 'edit_page', $id ) ) 77 return $id; 78 } else { 79 if ( !current_user_can( 'edit_post', $id ) ) 80 return $id; 81 } 82 73 if (!current_user_can('edit_' . ($_POST['post_type'] == 'posts' ? 'posts' : 'page'), $id )) { 74 return $id; 75 } 76 83 77 // Catch only when a draft is saved of a live page 84 if ( ($_REQUEST['post_type'] == 'page' || $_REQUEST['post_type'] == 'post') &&$_REQUEST['save'] == 'Save Draft' && $_REQUEST['post_status'] == 'publish') {78 if ($_REQUEST['save'] == 'Save Draft' && $_REQUEST['post_status'] == 'publish') { 85 79 86 80 // Duplicate post and set as a draft … … 119 113 120 114 // Send user to new edit page 121 header('Location: '.get_option('siteurl').'/wp-admin/post.php?action=edit&post=' . $newId);115 wp_redirect(admin_url('post.php?action=edit&post=' . $newId)); 122 116 exit(); 123 117 … … 125 119 126 120 // Catch draft pages that need to replace a live page 127 if (isset($_REQUEST['publish']) && ($_REQUEST['post_type'] == 'page' || $_REQUEST['post_type'] == 'post') &&$_REQUEST['post_status'] == 'draft') {121 if (isset($_REQUEST['publish']) && $_REQUEST['post_status'] == 'draft') { 128 122 129 123 // Check for post meta that identifies this as a 'live draft' … … 174 168 175 169 // Send user to live edit page 176 header('Location: '.get_option('siteurl').'/wp-admin/post.php?action=edit&post=' . $_pc_liveId);170 wp_redirect(admin_url('post.php?action=edit&post=' . $_pc_liveId)); 177 171 exit(); 178 172 … … 186 180 } 187 181 188 // Create an object from the class when WP runs the INIT action. 189 if (is_admin()) { 190 add_action ('init', create_function('', 'global $liveDrafts; $liveDrafts = new liveDrafts();')); 191 register_activation_hook(__FILE__, array('liveDrafts', 'activate')); 192 } 182 // Create an object from the class when the admin_init action fires 183 add_action ('admin_init', create_function('', 'global $liveDrafts; $liveDrafts = new liveDrafts();')); 193 184 194 185 } -
live-drafts/trunk/readme.txt
r341287 r354158 14 14 == Changelog == 15 15 16 = 3.0.1 = 17 * Code improvements as kindly suggested by Peter Westwood. 18 16 19 = 3.0 = 17 20 * Initial public version. 21 22 == Screenshots == 23 24 1. The save draft button will now appear on published pages.
Note: See TracChangeset
for help on using the changeset viewer.