Post Type Switcher - Version 1.3

Version Description

Download this release

Release Info

Developer johnjamesjacoby
Plugin Icon 128x128 Post Type Switcher
Version 1.3
Comparing to
See all releases

Code changes from version 1.2.1 to 1.3

Files changed (2) hide show
  1. post-type-switcher.php +17 -11
  2. readme.txt +4 -1
post-type-switcher.php CHANGED
@@ -13,7 +13,7 @@
13
  * Plugin Name: Post Type Switcher
14
  * Plugin URI: http://wordpress.org/extend/post-type-switcher/
15
  * Description: Allow switching of a post type while editing a post (in post publish section)
16
- * Version: 1.2
17
  * Author: johnjamesjacoby
18
  * Author URI: http://johnjamesjacoby.com
19
  */
@@ -210,33 +210,39 @@ final class Post_Type_Switcher {
210
  * @param object $post
211
  * @return If any number of condtions are met
212
  */
213
- function save_post( $post_id, $post ) {
214
 
215
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
216
- die( 'autosave' );
217
  return;
218
  }
219
 
220
- if ( ! isset( $_REQUEST['pts-nonce-select'] ) )
221
  return;
 
222
 
223
- if ( ! wp_verify_nonce( $_REQUEST['pts-nonce-select'], 'post-type-selector' ) )
224
  return;
 
225
 
226
- if ( ! current_user_can( 'edit_post', $post_id ) )
227
  return;
 
228
 
229
- if ( empty( $_REQUEST['pts_post_type'] ) )
230
  return;
 
231
 
232
- if ( in_array( $post->post_type, array( $_REQUEST['pts_post_type'], 'revision' ) ) )
233
  return;
 
234
 
235
- if ( ! $new_post_type_object = get_post_type_object( $_REQUEST['pts_post_type'] ) )
236
  return;
 
237
 
238
- if ( ! current_user_can( $new_post_type_object->cap->publish_posts ) )
239
  return;
 
240
 
241
  set_post_type( $post_id, $new_post_type_object->name );
242
  }
@@ -247,7 +253,7 @@ final class Post_Type_Switcher {
247
  * @since PostTypeSwitcher (0.3)
248
  * @return If on post-new.php
249
  */
250
- function admin_head() {
251
  ?>
252
 
253
  <script type="text/javascript">
13
  * Plugin Name: Post Type Switcher
14
  * Plugin URI: http://wordpress.org/extend/post-type-switcher/
15
  * Description: Allow switching of a post type while editing a post (in post publish section)
16
+ * Version: 1.3
17
  * Author: johnjamesjacoby
18
  * Author URI: http://johnjamesjacoby.com
19
  */
210
  * @param object $post
211
  * @return If any number of condtions are met
212
  */
213
+ public function save_post( $post_id, $post ) {
214
 
215
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
 
216
  return;
217
  }
218
 
219
+ if ( ! isset( $_REQUEST['pts-nonce-select'] ) ) {
220
  return;
221
+ }
222
 
223
+ if ( ! wp_verify_nonce( $_REQUEST['pts-nonce-select'], 'post-type-selector' ) ) {
224
  return;
225
+ }
226
 
227
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
228
  return;
229
+ }
230
 
231
+ if ( empty( $_REQUEST['pts_post_type'] ) ) {
232
  return;
233
+ }
234
 
235
+ if ( in_array( $post->post_type, array( $_REQUEST['pts_post_type'], 'revision' ) ) ) {
236
  return;
237
+ }
238
 
239
+ if ( ! $new_post_type_object = get_post_type_object( $_REQUEST['pts_post_type'] ) ) {
240
  return;
241
+ }
242
 
243
+ if ( ! current_user_can( $new_post_type_object->cap->publish_posts ) ) {
244
  return;
245
+ }
246
 
247
  set_post_type( $post_id, $new_post_type_object->name );
248
  }
253
  * @since PostTypeSwitcher (0.3)
254
  * @return If on post-new.php
255
  */
256
+ public function admin_head() {
257
  ?>
258
 
259
  <script type="text/javascript">
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: johnjamesjacoby, beatpanda
3
  Tags: post type
4
  Requires at least: 3.0
5
  Tested up to: 3.9
6
- Stable tag: 1.2.1
7
 
8
  A simple way to change a post's type in WordPress
9
 
@@ -22,6 +22,9 @@ Now with bulk editing, thanks to Matthew Gerring!
22
 
23
  == Changelog ==
24
 
 
 
 
25
  = Version 1.2.1 =
26
  * Improved WordPress 3.9 integration (added dashicon to publish metabox)
27
 
3
  Tags: post type
4
  Requires at least: 3.0
5
  Tested up to: 3.9
6
+ Stable tag: 1.3
7
 
8
  A simple way to change a post's type in WordPress
9
 
22
 
23
  == Changelog ==
24
 
25
+ = Version 1.3 =
26
+ * Fix saving of autodrafts
27
+
28
  = Version 1.2.1 =
29
  * Improved WordPress 3.9 integration (added dashicon to publish metabox)
30