Post Type Switcher - Version 1.5

Version Description

Download this release

Release Info

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

Code changes from version 1.4 to 1.5

Files changed (2) hide show
  1. post-type-switcher.php +364 -350
  2. readme.txt +6 -3
post-type-switcher.php CHANGED
@@ -1,350 +1,364 @@
1
- <?php
2
-
3
- /**
4
- * Post Type Switcher
5
- *
6
- * Allow switching of a post type while editing a post (in post publish section)
7
- *
8
- * @package PostTypeSwitcher
9
- * @subpackage Main
10
- */
11
-
12
- /**
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.4
17
- * Author: johnjamesjacoby
18
- * Author URI: http://johnjamesjacoby.com
19
- */
20
-
21
- // Exit if accessed directly
22
- defined( 'ABSPATH' ) || exit;
23
-
24
- /**
25
- * The main post type switcher class
26
- *
27
- * @package PostTypeSwitcher
28
- */
29
- final class Post_Type_Switcher {
30
-
31
- /**
32
- * Setup the actions needed to execute class methods where needed
33
- *
34
- * @since PostTypeSwitcher (1.1)
35
- */
36
- public function __construct() {
37
-
38
- if ( ! $this->is_allowed_page() )
39
- return;
40
-
41
- // @todo Remove this; since it's janky to need to do this.
42
- add_action( 'manage_posts_columns', array( $this, 'add_column' ) );
43
- add_action( 'manage_pages_columns', array( $this, 'add_column' ) );
44
- add_action( 'manage_posts_custom_column', array( $this, 'manage_column' ), 10, 2 );
45
- add_action( 'manage_pages_custom_column', array( $this, 'manage_column' ), 10, 2 );
46
-
47
- add_action( 'post_submitbox_misc_actions', array( $this, 'metabox' ) );
48
- add_action( 'quick_edit_custom_box', array( $this, 'quickedit' ), 10, 2 );
49
- add_action( 'bulk_edit_custom_box', array( $this, 'quickedit' ), 10, 2 );
50
- add_action( 'admin_enqueue_scripts', array( $this, 'quickedit_script' ), 10, 1 );
51
- add_action( 'save_post', array( $this, 'save_post' ), 999, 2 ); // Late priority for plugin friendliness
52
- add_action( 'admin_head', array( $this, 'admin_head' ) );
53
- }
54
-
55
- /**
56
- * pts_metabox()
57
- *
58
- * Adds post_publish metabox to allow changing post_type
59
- *
60
- * @since PostTypeSwitcher (0.3)
61
- */
62
- public function metabox() {
63
-
64
- // Allow types to be filtered, just incase you really need to switch
65
- // between crazy types of posts.
66
- $args = (array) apply_filters( 'pts_post_type_filter', array(
67
- 'public' => true,
68
- 'show_ui' => true
69
- ) );
70
- $post_types = get_post_types( $args, 'objects' );
71
- $cpt_object = get_post_type_object( get_post_type() );
72
-
73
- // Bail if object does not exist or produces an error
74
- if ( empty( $cpt_object ) || is_wp_error( $cpt_object ) ) {
75
- return;
76
- }
77
-
78
- // Force-add current post type if it's not in the list
79
- // https://wordpress.org/support/topic/dont-show-for-non-public-post-types?replies=4#post-5849287
80
- if ( ! in_array( $cpt_object, $post_types ) ) {
81
- $post_types[ get_post_type() ] = $cpt_object;
82
- } ?>
83
-
84
- <div class="misc-pub-section misc-pub-section-last post-type-switcher">
85
- <label for="pts_post_type"><?php _e( 'Post Type:' ); ?></label>
86
- <span id="post-type-display"><?php echo esc_html( $cpt_object->labels->singular_name ); ?></span>
87
-
88
- <?php if ( current_user_can( $cpt_object->cap->publish_posts ) ) : ?>
89
-
90
- <a href="#" id="edit-post-type-switcher" class="hide-if-no-js"><?php _e( 'Edit' ); ?></a>
91
-
92
- <?php wp_nonce_field( 'post-type-selector', 'pts-nonce-select' ); ?>
93
-
94
- <div id="post-type-select">
95
- <select name="pts_post_type" id="pts_post_type">
96
-
97
- <?php foreach ( $post_types as $post_type => $pt ) : ?>
98
-
99
- <?php if ( ! current_user_can( $pt->cap->publish_posts ) ) :
100
- continue;
101
- endif; ?>
102
-
103
- <option value="<?php echo esc_attr( $pt->name ); ?>" <?php selected( get_post_type(), $post_type ); ?>><?php echo esc_html( $pt->labels->singular_name ); ?></option>
104
-
105
- <?php endforeach; ?>
106
-
107
- </select>
108
- <a href="#" id="save-post-type-switcher" class="hide-if-no-js button"><?php _e( 'OK' ); ?></a>
109
- <a href="#" id="cancel-post-type-switcher" class="hide-if-no-js"><?php _e( 'Cancel' ); ?></a>
110
- </div>
111
-
112
- <?php endif; ?>
113
-
114
- </div>
115
-
116
- <?php
117
- }
118
-
119
- /**
120
- * Adds the post type column
121
- *
122
- * @since PostTypeSwitcher (1.2)
123
- */
124
- public function add_column( $columns ) {
125
- return array_merge( $columns, array( 'post_type' => __( 'Type' ) ) );
126
- }
127
-
128
- /**
129
- * Manages the post type column
130
- *
131
- * @since PostTypeSwitcher (1.1.1)
132
- */
133
- public function manage_column( $column, $post_id ) {
134
- switch( $column ) {
135
- case 'post_type' :
136
- $post_type = get_post_type_object( get_post_type( $post_id ) ); ?>
137
-
138
- <span data-post-type="<?php echo esc_attr( $post_type->name ); ?>"><?php echo esc_html( $post_type->labels->singular_name ); ?></span>
139
-
140
- <?php
141
- break;
142
- }
143
- }
144
-
145
- /**
146
- * Adds quickedit button for bulk-editing post types
147
- *
148
- * @since PostTypeSwitcher (1.2)
149
- */
150
- public function quickedit( $column_name, $post_type ) {
151
- ?>
152
- <fieldset class="inline-edit-col-right">
153
- <div class="inline-edit-col">
154
- <label class="alignleft">
155
- <span class="title"><?php _e( 'Post Type' ); ?></span>
156
- <?php wp_nonce_field( 'post-type-selector', 'pts-nonce-select' ); ?>
157
- <?php $this->select_box(); ?>
158
- </label>
159
- </div>
160
- </fieldset>
161
- <?php
162
- }
163
-
164
- /**
165
- * Adds quickedit script for getting values into quickedit box
166
- *
167
- * @since PostTypeSwitcher (1.2)
168
- */
169
- public function quickedit_script( $hook = '' ) {
170
- if ( 'edit.php' !== $hook ) {
171
- return;
172
- }
173
-
174
- wp_enqueue_script( 'pts_quickedit', plugins_url( 'js/quickedit.js', __FILE__ ), array( 'jquery' ), '', true );
175
- }
176
-
177
- /**
178
- * Output a post-type dropdown
179
- *
180
- * @since PostTypeSwitcher (1.2)
181
- */
182
- public function select_box() {
183
- $args = (array) apply_filters( 'pts_post_type_filter', array(
184
- 'public' => true,
185
- 'show_ui' => true
186
- ) );
187
- $post_types = get_post_types( $args, 'objects' ); ?>
188
-
189
- <select name="pts_post_type" id="pts_post_type">
190
-
191
- <?php foreach ( $post_types as $post_type => $pt ) : ?>
192
-
193
- <?php if ( ! current_user_can( $pt->cap->publish_posts ) ) :
194
- continue;
195
- endif; ?>
196
-
197
- <option value="<?php echo esc_attr( $pt->name ); ?>" <?php selected( get_post_type(), $post_type ); ?>><?php echo esc_html( $pt->labels->singular_name ); ?></option>
198
-
199
- <?php endforeach; ?>
200
-
201
- </select>
202
-
203
- <?php
204
- }
205
-
206
- /**
207
- * Set the post type on save_post but only when editing
208
- *
209
- * We do a bunch of sanity checks here, to make sure we're only changing the
210
- * post type when the user explicitly intends to.
211
- *
212
- * - Not during autosave
213
- * - Check nonce
214
- * - Check user capabilities
215
- * - Check $_POST input name
216
- * - Check if revision or current post-type
217
- * - Check new post-type exists
218
- * - Check that user can publish posts of new type
219
- *
220
- * @since PostTypeSwitcher (0.3)
221
- * @param int $post_id
222
- * @param object $post
223
- * @return If any number of condtions are met
224
- */
225
- public function save_post( $post_id, $post ) {
226
-
227
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
228
- return;
229
- }
230
-
231
- if ( ! isset( $_REQUEST['pts-nonce-select'] ) ) {
232
- return;
233
- }
234
-
235
- if ( ! wp_verify_nonce( $_REQUEST['pts-nonce-select'], 'post-type-selector' ) ) {
236
- return;
237
- }
238
-
239
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
240
- return;
241
- }
242
-
243
- if ( empty( $_REQUEST['pts_post_type'] ) ) {
244
- return;
245
- }
246
-
247
- if ( in_array( $post->post_type, array( $_REQUEST['pts_post_type'], 'revision' ) ) ) {
248
- return;
249
- }
250
-
251
- $new_post_type_object = get_post_type_object( $_REQUEST['pts_post_type'] );
252
- if ( empty( $new_post_type_object ) ) {
253
- return;
254
- }
255
-
256
- if ( ! current_user_can( $new_post_type_object->cap->publish_posts ) ) {
257
- return;
258
- }
259
-
260
- set_post_type( $post_id, $new_post_type_object->name );
261
- }
262
-
263
- /**
264
- * Adds needed JS and CSS to admin header
265
- *
266
- * @since PostTypeSwitcher (0.3)
267
- * @return If on post-new.php
268
- */
269
- public function admin_head() {
270
- ?>
271
-
272
- <script type="text/javascript">
273
- jQuery( document ).ready( function( $ ) {
274
- jQuery( '.misc-pub-section.curtime.misc-pub-section-last' ).removeClass( 'misc-pub-section-last' );
275
- jQuery( '#edit-post-type-switcher' ).click( function(e) {
276
- jQuery( this ).hide();
277
- jQuery( '#post-type-select' ).slideDown();
278
- e.preventDefault();
279
- });
280
-
281
- jQuery( '#save-post-type-switcher' ).click( function(e) {
282
- jQuery( '#post-type-select' ).slideUp();
283
- jQuery( '#edit-post-type-switcher' ).show();
284
- jQuery( '#post-type-display' ).text( jQuery( '#pts_post_type :selected' ).text() );
285
- e.preventDefault();
286
- });
287
-
288
- jQuery( '#cancel-post-type-switcher' ).click( function(e) {
289
- jQuery( '#post-type-select' ).slideUp();
290
- jQuery( '#edit-post-type-switcher' ).show();
291
- e.preventDefault();
292
- });
293
- });
294
- </script>
295
- <style type="text/css">
296
- #post-type-select {
297
- line-height: 2.5em;
298
- margin-top: 3px;
299
- display: none;
300
- }
301
- #post-type-display {
302
- font-weight: bold;
303
- }
304
-
305
- #post-body .post-type-switcher::before {
306
- content: '\f109';
307
- font: 400 20px/1 dashicons;
308
- speak: none;
309
- display: inline-block;
310
- padding: 0 2px 0 0;
311
- top: 0;
312
- left: -1px;
313
- position: relative;
314
- vertical-align: top;
315
- -webkit-font-smoothing: antialiased;
316
- -moz-osx-font-smoothing: grayscale;
317
- text-decoration: none !important;
318
- color: #888;
319
- }
320
- </style>
321
-
322
- <?php
323
- }
324
-
325
- /**
326
- * Whether or not the current file requires the post type switcher
327
- *
328
- * @since PostTypeSwitcher (1.1)
329
- * @return bool True if it should load, false if not
330
- */
331
- private static function is_allowed_page() {
332
- global $pagenow;
333
-
334
- // Only for admin area
335
- if ( ! is_admin() ) {
336
- return false;
337
- }
338
-
339
- // Allowed admin pages
340
- $pages = apply_filters( 'pts_allowed_pages', array(
341
- 'post.php',
342
- 'edit.php',
343
- 'admin-ajax.php'
344
- ) );
345
-
346
- // Only show switcher when editing
347
- return (bool) in_array( $pagenow, $pages );
348
- }
349
- }
350
- new Post_Type_Switcher();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Post Type Switcher
5
+ *
6
+ * Allow switching of a post type while editing a post (in post publish section)
7
+ *
8
+ * @package PostTypeSwitcher
9
+ * @subpackage Main
10
+ */
11
+
12
+ /**
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.5
17
+ * Author: johnjamesjacoby
18
+ * Author URI: http://johnjamesjacoby.com
19
+ */
20
+
21
+ // Exit if accessed directly
22
+ defined( 'ABSPATH' ) || exit;
23
+
24
+ /**
25
+ * The main post type switcher class
26
+ *
27
+ * @package PostTypeSwitcher
28
+ */
29
+ final class Post_Type_Switcher {
30
+
31
+ /**
32
+ * Setup the actions needed to execute class methods where needed
33
+ *
34
+ * @since PostTypeSwitcher (1.1)
35
+ */
36
+ public function __construct() {
37
+
38
+ if ( ! $this->is_allowed_page() ) {
39
+ return;
40
+ }
41
+
42
+ // @todo Remove this; since it's janky to need to do this.
43
+ add_action( 'manage_posts_columns', array( $this, 'add_column' ) );
44
+ add_action( 'manage_pages_columns', array( $this, 'add_column' ) );
45
+ add_action( 'manage_posts_custom_column', array( $this, 'manage_column' ), 10, 2 );
46
+ add_action( 'manage_pages_custom_column', array( $this, 'manage_column' ), 10, 2 );
47
+
48
+ add_action( 'post_submitbox_misc_actions', array( $this, 'metabox' ) );
49
+ add_action( 'quick_edit_custom_box', array( $this, 'quickedit' ), 10, 2 );
50
+ add_action( 'bulk_edit_custom_box', array( $this, 'quickedit' ), 10, 2 );
51
+ add_action( 'admin_enqueue_scripts', array( $this, 'quickedit_script' ), 10, 1 );
52
+ add_action( 'save_post', array( $this, 'save_post' ), 999, 2 ); // Late priority for plugin friendliness
53
+ add_action( 'admin_head', array( $this, 'admin_head' ) );
54
+ }
55
+
56
+ /**
57
+ * pts_metabox()
58
+ *
59
+ * Adds post_publish metabox to allow changing post_type
60
+ *
61
+ * @since PostTypeSwitcher (0.3)
62
+ */
63
+ public function metabox() {
64
+
65
+ // Allow types to be filtered, just incase you really need to switch
66
+ // between crazy types of posts.
67
+ $args = (array) apply_filters( 'pts_post_type_filter', array(
68
+ 'public' => true,
69
+ 'show_ui' => true
70
+ ) );
71
+ $post_types = get_post_types( $args, 'objects' );
72
+ $cpt_object = get_post_type_object( get_post_type() );
73
+
74
+ // Bail if object does not exist or produces an error
75
+ if ( empty( $cpt_object ) || is_wp_error( $cpt_object ) ) {
76
+ return;
77
+ }
78
+
79
+ // Force-add current post type if it's not in the list
80
+ // https://wordpress.org/support/topic/dont-show-for-non-public-post-types?replies=4#post-5849287
81
+ if ( ! in_array( $cpt_object, $post_types ) ) {
82
+ $post_types[ get_post_type() ] = $cpt_object;
83
+ } ?>
84
+
85
+ <div class="misc-pub-section misc-pub-section-last post-type-switcher">
86
+ <label for="pts_post_type"><?php _e( 'Post Type:' ); ?></label>
87
+ <span id="post-type-display"><?php echo esc_html( $cpt_object->labels->singular_name ); ?></span>
88
+
89
+ <?php if ( current_user_can( $cpt_object->cap->publish_posts ) ) : ?>
90
+
91
+ <a href="#" id="edit-post-type-switcher" class="hide-if-no-js"><?php _e( 'Edit' ); ?></a>
92
+
93
+ <?php wp_nonce_field( 'post-type-selector', 'pts-nonce-select' ); ?>
94
+
95
+ <div id="post-type-select">
96
+ <select name="pts_post_type" id="pts_post_type">
97
+
98
+ <?php foreach ( $post_types as $post_type => $pt ) : ?>
99
+
100
+ <?php if ( ! current_user_can( $pt->cap->publish_posts ) ) :
101
+ continue;
102
+ endif; ?>
103
+
104
+ <option value="<?php echo esc_attr( $pt->name ); ?>" <?php selected( get_post_type(), $post_type ); ?>><?php echo esc_html( $pt->labels->singular_name ); ?></option>
105
+
106
+ <?php endforeach; ?>
107
+
108
+ </select>
109
+ <a href="#" id="save-post-type-switcher" class="hide-if-no-js button"><?php _e( 'OK' ); ?></a>
110
+ <a href="#" id="cancel-post-type-switcher" class="hide-if-no-js"><?php _e( 'Cancel' ); ?></a>
111
+ </div>
112
+
113
+ <?php endif; ?>
114
+
115
+ </div>
116
+
117
+ <?php
118
+ }
119
+
120
+ /**
121
+ * Adds the post type column
122
+ *
123
+ * @since PostTypeSwitcher (1.2)
124
+ */
125
+ public function add_column( $columns ) {
126
+ return array_merge( $columns, array( 'post_type' => __( 'Type' ) ) );
127
+ }
128
+
129
+ /**
130
+ * Manages the post type column
131
+ *
132
+ * @since PostTypeSwitcher (1.1.1)
133
+ */
134
+ public function manage_column( $column, $post_id ) {
135
+ switch( $column ) {
136
+ case 'post_type' :
137
+ $post_type = get_post_type_object( get_post_type( $post_id ) ); ?>
138
+
139
+ <span data-post-type="<?php echo esc_attr( $post_type->name ); ?>"><?php echo esc_html( $post_type->labels->singular_name ); ?></span>
140
+
141
+ <?php
142
+ break;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Adds quickedit button for bulk-editing post types
148
+ *
149
+ * @since PostTypeSwitcher (1.2)
150
+ */
151
+ public function quickedit( $column_name, $post_type ) {
152
+
153
+ // Bail to prevent multiple dropdowns in each column
154
+ if ( $column_name !== 'post_type' ) {
155
+ return;
156
+ } ?>
157
+
158
+ <fieldset class="inline-edit-col-right">
159
+ <div class="inline-edit-col">
160
+ <label class="alignleft">
161
+ <span class="title"><?php _e( 'Post Type' ); ?></span>
162
+ <?php wp_nonce_field( 'post-type-selector', 'pts-nonce-select' ); ?>
163
+ <?php $this->select_box(); ?>
164
+ </label>
165
+ </div>
166
+ </fieldset>
167
+
168
+ <?php
169
+ }
170
+
171
+ /**
172
+ * Adds quickedit script for getting values into quickedit box
173
+ *
174
+ * @since PostTypeSwitcher (1.2)
175
+ */
176
+ public function quickedit_script( $hook = '' ) {
177
+ if ( 'edit.php' !== $hook ) {
178
+ return;
179
+ }
180
+
181
+ wp_enqueue_script( 'pts_quickedit', plugins_url( 'js/quickedit.js', __FILE__ ), array( 'jquery' ), '', true );
182
+ }
183
+
184
+ /**
185
+ * Output a post-type dropdown
186
+ *
187
+ * @since PostTypeSwitcher (1.2)
188
+ */
189
+ public function select_box() {
190
+ $args = (array) apply_filters( 'pts_post_type_filter', array(
191
+ 'public' => true,
192
+ 'show_ui' => true
193
+ ) );
194
+ $post_types = get_post_types( $args, 'objects' ); ?>
195
+
196
+ <select name="pts_post_type" id="pts_post_type">
197
+
198
+ <?php foreach ( $post_types as $post_type => $pt ) : ?>
199
+
200
+ <?php if ( ! current_user_can( $pt->cap->publish_posts ) ) :
201
+ continue;
202
+ endif; ?>
203
+
204
+ <option value="<?php echo esc_attr( $pt->name ); ?>" <?php selected( get_post_type(), $post_type ); ?>><?php echo esc_html( $pt->labels->singular_name ); ?></option>
205
+
206
+ <?php endforeach; ?>
207
+
208
+ </select>
209
+
210
+ <?php
211
+ }
212
+
213
+ /**
214
+ * Set the post type on save_post but only when editing
215
+ *
216
+ * We do a bunch of sanity checks here, to make sure we're only changing the
217
+ * post type when the user explicitly intends to.
218
+ *
219
+ * - Not during autosave
220
+ * - Check nonce
221
+ * - Check user capabilities
222
+ * - Check $_POST input name
223
+ * - Check if revision or current post-type
224
+ * - Check new post-type exists
225
+ * - Check that user can publish posts of new type
226
+ *
227
+ * @since PostTypeSwitcher (0.3)
228
+ * @param int $post_id
229
+ * @param object $post
230
+ * @return If any number of condtions are met
231
+ */
232
+ public function save_post( $post_id, $post ) {
233
+
234
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
235
+ return;
236
+ }
237
+
238
+ if ( ! isset( $_REQUEST['pts-nonce-select'] ) ) {
239
+ return;
240
+ }
241
+
242
+ if ( ! wp_verify_nonce( $_REQUEST['pts-nonce-select'], 'post-type-selector' ) ) {
243
+ return;
244
+ }
245
+
246
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
247
+ return;
248
+ }
249
+
250
+ if ( empty( $_REQUEST['pts_post_type'] ) ) {
251
+ return;
252
+ }
253
+
254
+ if ( in_array( $post->post_type, array( $_REQUEST['pts_post_type'], 'revision' ) ) ) {
255
+ return;
256
+ }
257
+
258
+ $new_post_type_object = get_post_type_object( $_REQUEST['pts_post_type'] );
259
+ if ( empty( $new_post_type_object ) ) {
260
+ return;
261
+ }
262
+
263
+ if ( ! current_user_can( $new_post_type_object->cap->publish_posts ) ) {
264
+ return;
265
+ }
266
+
267
+ set_post_type( $post_id, $new_post_type_object->name );
268
+ }
269
+
270
+ /**
271
+ * Adds needed JS and CSS to admin header
272
+ *
273
+ * @since PostTypeSwitcher (0.3)
274
+ * @return If on post-new.php
275
+ */
276
+ public function admin_head() {
277
+ ?>
278
+
279
+ <script type="text/javascript">
280
+ jQuery( document ).ready( function( $ ) {
281
+ jQuery( '.misc-pub-section.curtime.misc-pub-section-last' ).removeClass( 'misc-pub-section-last' );
282
+ jQuery( '#edit-post-type-switcher' ).on( 'click', function(e) {
283
+ jQuery( this ).hide();
284
+ jQuery( '#post-type-select' ).slideDown();
285
+ e.preventDefault();
286
+ });
287
+
288
+ jQuery( '#save-post-type-switcher' ).on( 'click', function(e) {
289
+ jQuery( '#post-type-select' ).slideUp();
290
+ jQuery( '#edit-post-type-switcher' ).show();
291
+ jQuery( '#post-type-display' ).text( jQuery( '#pts_post_type :selected' ).text() );
292
+ e.preventDefault();
293
+ });
294
+
295
+ jQuery( '#cancel-post-type-switcher' ).on( 'click', function(e) {
296
+ jQuery( '#post-type-select' ).slideUp();
297
+ jQuery( '#edit-post-type-switcher' ).show();
298
+ e.preventDefault();
299
+ });
300
+ });
301
+ </script>
302
+ <style type="text/css">
303
+ #post-type-select {
304
+ line-height: 2.5em;
305
+ margin-top: 3px;
306
+ display: none;
307
+ }
308
+ #post-type-select select#pts_post_type {
309
+ margin-right: 2px;
310
+ }
311
+ #post-type-select a#save-post-type-switcher {
312
+ vertical-align: middle;
313
+ margin-right: 2px;
314
+ }
315
+ #post-type-display {
316
+ font-weight: bold;
317
+ }
318
+
319
+ #post-body .post-type-switcher::before {
320
+ content: '\f109';
321
+ font: 400 20px/1 dashicons;
322
+ speak: none;
323
+ display: inline-block;
324
+ padding: 0 2px 0 0;
325
+ top: 0;
326
+ left: -1px;
327
+ position: relative;
328
+ vertical-align: top;
329
+ -webkit-font-smoothing: antialiased;
330
+ -moz-osx-font-smoothing: grayscale;
331
+ text-decoration: none !important;
332
+ color: #888;
333
+ }
334
+ </style>
335
+
336
+ <?php
337
+ }
338
+
339
+ /**
340
+ * Whether or not the current file requires the post type switcher
341
+ *
342
+ * @since PostTypeSwitcher (1.1)
343
+ * @return bool True if it should load, false if not
344
+ */
345
+ private static function is_allowed_page() {
346
+ global $pagenow;
347
+
348
+ // Only for admin area
349
+ if ( ! is_admin() ) {
350
+ return false;
351
+ }
352
+
353
+ // Allowed admin pages
354
+ $pages = apply_filters( 'pts_allowed_pages', array(
355
+ 'post.php',
356
+ 'edit.php',
357
+ 'admin-ajax.php'
358
+ ) );
359
+
360
+ // Only show switcher when editing
361
+ return (bool) in_array( $pagenow, $pages );
362
+ }
363
+ }
364
+ new Post_Type_Switcher();
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: johnjamesjacoby, beatpanda
3
  Tags: post type
4
  Requires at least: 3.0
5
- Tested up to: 4.1
6
- Stable tag: 1.4
7
 
8
  A simple way to change a post's type in WordPress
9
 
@@ -22,8 +22,11 @@ Now with bulk editing, thanks to Matthew Gerring!
22
 
23
  == Changelog ==
24
 
 
 
 
25
  = Version 1.4 =
26
- * Improve handling of non-public post-types.
27
 
28
  = Version 1.3 =
29
  * Fix saving of autodrafts
2
  Contributors: johnjamesjacoby, beatpanda
3
  Tags: post type
4
  Requires at least: 3.0
5
+ Tested up to: 4.2
6
+ Stable tag: 1.5
7
 
8
  A simple way to change a post's type in WordPress
9
 
22
 
23
  == Changelog ==
24
 
25
+ = Version 1.5 - norcross =
26
+ * Fix multiple quickedit dropdowns
27
+
28
  = Version 1.4 =
29
+ * Improve handling of non-public post types
30
 
31
  = Version 1.3 =
32
  * Fix saving of autodrafts