Version Description
Download this release
Release Info
| Developer | johnjamesjacoby |
| Plugin | |
| Version | 1.4 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3 to 1.4
- js/quickedit.js +1 -1
- post-type-switcher.php +26 -10
- readme.txt +5 -2
js/quickedit.js
CHANGED
|
@@ -9,7 +9,7 @@ function pts_quick_edit() {
|
|
| 9 |
|
| 10 |
_edit.apply( this, args );
|
| 11 |
|
| 12 |
-
if ( typeof( id )
|
| 13 |
id = this.getId( id );
|
| 14 |
}
|
| 15 |
|
| 9 |
|
| 10 |
_edit.apply( this, args );
|
| 11 |
|
| 12 |
+
if ( typeof( id ) === 'object' ) {
|
| 13 |
id = this.getId( id );
|
| 14 |
}
|
| 15 |
|
post-type-switcher.php
CHANGED
|
@@ -13,13 +13,13 @@
|
|
| 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.
|
| 17 |
* Author: johnjamesjacoby
|
| 18 |
* Author URI: http://johnjamesjacoby.com
|
| 19 |
*/
|
| 20 |
|
| 21 |
// Exit if accessed directly
|
| 22 |
-
|
| 23 |
|
| 24 |
/**
|
| 25 |
* The main post type switcher class
|
|
@@ -71,8 +71,15 @@ final class Post_Type_Switcher {
|
|
| 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 |
<div class="misc-pub-section misc-pub-section-last post-type-switcher">
|
| 78 |
<label for="pts_post_type"><?php _e( 'Post Type:' ); ?></label>
|
|
@@ -89,7 +96,9 @@ final class Post_Type_Switcher {
|
|
| 89 |
|
| 90 |
<?php foreach ( $post_types as $post_type => $pt ) : ?>
|
| 91 |
|
| 92 |
-
<?php if ( ! current_user_can( $pt->cap->publish_posts ) )
|
|
|
|
|
|
|
| 93 |
|
| 94 |
<option value="<?php echo esc_attr( $pt->name ); ?>" <?php selected( get_post_type(), $post_type ); ?>><?php echo esc_html( $pt->labels->singular_name ); ?></option>
|
| 95 |
|
|
@@ -158,8 +167,9 @@ final class Post_Type_Switcher {
|
|
| 158 |
* @since PostTypeSwitcher (1.2)
|
| 159 |
*/
|
| 160 |
public function quickedit_script( $hook = '' ) {
|
| 161 |
-
if ( 'edit.php'
|
| 162 |
return;
|
|
|
|
| 163 |
|
| 164 |
wp_enqueue_script( 'pts_quickedit', plugins_url( 'js/quickedit.js', __FILE__ ), array( 'jquery' ), '', true );
|
| 165 |
}
|
|
@@ -180,7 +190,9 @@ final class Post_Type_Switcher {
|
|
| 180 |
|
| 181 |
<?php foreach ( $post_types as $post_type => $pt ) : ?>
|
| 182 |
|
| 183 |
-
<?php if ( ! current_user_can( $pt->cap->publish_posts ) )
|
|
|
|
|
|
|
| 184 |
|
| 185 |
<option value="<?php echo esc_attr( $pt->name ); ?>" <?php selected( get_post_type(), $post_type ); ?>><?php echo esc_html( $pt->labels->singular_name ); ?></option>
|
| 186 |
|
|
@@ -236,7 +248,8 @@ final class Post_Type_Switcher {
|
|
| 236 |
return;
|
| 237 |
}
|
| 238 |
|
| 239 |
-
|
|
|
|
| 240 |
return;
|
| 241 |
}
|
| 242 |
|
|
@@ -319,12 +332,15 @@ final class Post_Type_Switcher {
|
|
| 319 |
global $pagenow;
|
| 320 |
|
| 321 |
// Only for admin area
|
| 322 |
-
if ( ! is_admin() )
|
| 323 |
return false;
|
|
|
|
| 324 |
|
| 325 |
// Allowed admin pages
|
| 326 |
$pages = apply_filters( 'pts_allowed_pages', array(
|
| 327 |
-
'post.php',
|
|
|
|
|
|
|
| 328 |
) );
|
| 329 |
|
| 330 |
// Only show switcher when editing
|
| 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
|
| 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>
|
| 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 |
|
| 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 |
}
|
| 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 |
|
| 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 |
|
| 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
|
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:
|
| 6 |
-
Stable tag: 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.3 =
|
| 26 |
* Fix saving of autodrafts
|
| 27 |
|
| 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 |
|
| 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
|
| 30 |
|
