Version Description
Notices + small fixes and improvements
Download this release
Release Info
Developer | lopo |
Plugin | Duplicate Post |
Version | 3.0.3 |
Comparing to | |
See all releases |
Code changes from version 3.0.2 to 3.0.3
- duplicate-post-admin.php +37 -16
- duplicate-post-common.php +17 -15
- duplicate-post-options.php +1 -1
- duplicate-post.php +3 -5
- readme.txt +11 -2
duplicate-post-admin.php
CHANGED
@@ -9,7 +9,7 @@ require_once (dirname(__FILE__).'/duplicate-post-options.php');
|
|
9 |
* Wrapper for the option 'duplicate_post_version'
|
10 |
*/
|
11 |
function duplicate_post_get_installed_version() {
|
12 |
-
return
|
13 |
}
|
14 |
|
15 |
/**
|
@@ -116,17 +116,19 @@ function duplicate_post_plugin_upgrade() {
|
|
116 |
add_option('duplicate_post_show_submitbox','1');
|
117 |
|
118 |
// show notice about new features
|
119 |
-
|
120 |
|
121 |
} else if($installed_version_numbers[0] == 3){ // upgrading from 3.*
|
122 |
// hide notice, we assume people already know of new features
|
123 |
-
|
|
|
124 |
}
|
125 |
|
126 |
|
127 |
}
|
128 |
// Update version number
|
129 |
-
|
|
|
130 |
|
131 |
}
|
132 |
|
@@ -136,7 +138,7 @@ if (get_option('duplicate_post_show_row') == 1){
|
|
136 |
}
|
137 |
|
138 |
|
139 |
-
if (
|
140 |
/**
|
141 |
* Shows the update notice
|
142 |
*/
|
@@ -170,7 +172,7 @@ if (get_option('duplicate_post_show_notice') == 1){
|
|
170 |
add_action( 'wp_ajax_duplicate_post_dismiss_notice', 'duplicate_post_dismiss_notice' );
|
171 |
|
172 |
function duplicate_post_dismiss_notice() {
|
173 |
-
$result =
|
174 |
return $result;
|
175 |
wp_die();
|
176 |
}
|
@@ -228,6 +230,13 @@ function duplicate_post_save_as_new_post_draft(){
|
|
228 |
duplicate_post_save_as_new_post('draft');
|
229 |
}
|
230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
/*
|
232 |
* This function calls the creation of a new copy of the selected post (by default preserving the original publish status)
|
233 |
* then redirects to the post list
|
@@ -246,16 +255,16 @@ function duplicate_post_save_as_new_post($status = ''){
|
|
246 |
$new_id = duplicate_post_create_duplicate($post, $status);
|
247 |
|
248 |
if ($status == ''){
|
|
|
249 |
// Redirect to the post list screen
|
250 |
-
wp_redirect(
|
251 |
} else {
|
252 |
// Redirect to the edit screen for the new draft post
|
253 |
-
wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_id ) );
|
254 |
}
|
255 |
exit;
|
256 |
|
257 |
} else {
|
258 |
-
$post_type_obj = get_post_type_object( $post->post_type );
|
259 |
wp_die(__('Copy creation failed, could not find original:', 'duplicate-post') . ' ' . htmlspecialchars($id));
|
260 |
}
|
261 |
}
|
@@ -311,7 +320,6 @@ function duplicate_post_copy_post_meta_info($new_id, $post) {
|
|
311 |
|
312 |
/**
|
313 |
* Copy the attachments
|
314 |
-
* It simply copies the table entries, actual file won't be duplicated
|
315 |
*/
|
316 |
function duplicate_post_copy_attachments($new_id, $post){
|
317 |
// get thumbnail ID
|
@@ -351,7 +359,7 @@ function duplicate_post_copy_attachments($new_id, $post){
|
|
351 |
wp_update_post( $cloned_child );
|
352 |
|
353 |
$alt_title = get_post_meta($child->ID, '_wp_attachment_image_alt', true);
|
354 |
-
if($alt_title) update_post_meta($new_attachment_id,
|
355 |
|
356 |
// if we have cloned the post thumbnail, set the copy as the thumbnail for the new post
|
357 |
if($old_thumbnail_id == $child->ID){
|
@@ -440,11 +448,9 @@ add_action('dp_duplicate_page', 'duplicate_post_copy_post_taxonomies', 50, 2);
|
|
440 |
*/
|
441 |
function duplicate_post_create_duplicate($post, $status = '', $parent_id = '') {
|
442 |
|
443 |
-
$duplicate_post_types_enabled = get_option('duplicate_post_types_enabled');
|
444 |
-
|
445 |
if (!duplicate_post_is_post_type_enabled($post->post_type) && $post->post_type != 'attachment')
|
446 |
wp_die(__('Copy features for this post type are not enabled in options page', 'duplicate-post'));
|
447 |
-
|
448 |
if ($post->post_type != 'attachment'){
|
449 |
$prefix = sanitize_text_field(get_option('duplicate_post_title_prefix'));
|
450 |
$suffix = sanitize_text_field(get_option('duplicate_post_title_suffix'));
|
@@ -461,7 +467,7 @@ function duplicate_post_create_duplicate($post, $status = '', $parent_id = '') {
|
|
461 |
if ($title == ''){
|
462 |
// empty title
|
463 |
$title = __('Untitled');
|
464 |
-
}
|
465 |
|
466 |
|
467 |
if (get_option('duplicate_post_copystatus') == 0) $status = 'draft';
|
@@ -480,6 +486,7 @@ function duplicate_post_create_duplicate($post, $status = '', $parent_id = '') {
|
|
480 |
'ping_status' => $post->ping_status,
|
481 |
'post_author' => $new_post_author->ID,
|
482 |
'post_content' => (get_option('duplicate_post_copycontent') == '1') ? addslashes($post->post_content) : "" ,
|
|
|
483 |
'post_excerpt' => (get_option('duplicate_post_copyexcerpt') == '1') ? addslashes($post->post_excerpt) : "",
|
484 |
'post_mime_type' => $post->post_mime_type,
|
485 |
'post_parent' => $new_post_parent = empty($parent_id)? $post->post_parent : $parent_id,
|
@@ -535,4 +542,18 @@ function duplicate_post_add_plugin_links($links, $file) {
|
|
535 |
}
|
536 |
return $links;
|
537 |
}
|
538 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
* Wrapper for the option 'duplicate_post_version'
|
10 |
*/
|
11 |
function duplicate_post_get_installed_version() {
|
12 |
+
return get_site_option( 'duplicate_post_version' );
|
13 |
}
|
14 |
|
15 |
/**
|
116 |
add_option('duplicate_post_show_submitbox','1');
|
117 |
|
118 |
// show notice about new features
|
119 |
+
add_site_option('duplicate_post_show_notice','1');
|
120 |
|
121 |
} else if($installed_version_numbers[0] == 3){ // upgrading from 3.*
|
122 |
// hide notice, we assume people already know of new features
|
123 |
+
delete_option('duplicate_post_show_notice', 0);
|
124 |
+
update_site_option('duplicate_post_show_notice', 0);
|
125 |
}
|
126 |
|
127 |
|
128 |
}
|
129 |
// Update version number
|
130 |
+
delete_option('duplicate_post_version');
|
131 |
+
update_site_option( 'duplicate_post_version', duplicate_post_get_current_version() );
|
132 |
|
133 |
}
|
134 |
|
138 |
}
|
139 |
|
140 |
|
141 |
+
if (get_site_option('duplicate_post_show_notice') == 1){
|
142 |
/**
|
143 |
* Shows the update notice
|
144 |
*/
|
172 |
add_action( 'wp_ajax_duplicate_post_dismiss_notice', 'duplicate_post_dismiss_notice' );
|
173 |
|
174 |
function duplicate_post_dismiss_notice() {
|
175 |
+
$result = update_site_option('duplicate_post_show_notice', 0);
|
176 |
return $result;
|
177 |
wp_die();
|
178 |
}
|
230 |
duplicate_post_save_as_new_post('draft');
|
231 |
}
|
232 |
|
233 |
+
add_filter('removable_query_args', 'duplicate_post_add_removable_query_arg', 10, 1);
|
234 |
+
|
235 |
+
function duplicate_post_add_removable_query_arg( $removable_query_args ){
|
236 |
+
$removable_query_args[] = 'cloned';
|
237 |
+
return $removable_query_args;
|
238 |
+
}
|
239 |
+
|
240 |
/*
|
241 |
* This function calls the creation of a new copy of the selected post (by default preserving the original publish status)
|
242 |
* then redirects to the post list
|
255 |
$new_id = duplicate_post_create_duplicate($post, $status);
|
256 |
|
257 |
if ($status == ''){
|
258 |
+
$sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'cloned', 'ids'), wp_get_referer() );
|
259 |
// Redirect to the post list screen
|
260 |
+
wp_redirect( add_query_arg( array( 'cloned' => 1, 'ids' => $post->ID), $sendback ) );
|
261 |
} else {
|
262 |
// Redirect to the edit screen for the new draft post
|
263 |
+
wp_redirect( add_query_arg( array( 'cloned' => 1, 'ids' => $post->ID), admin_url( 'post.php?action=edit&post=' . $new_id ) ) );
|
264 |
}
|
265 |
exit;
|
266 |
|
267 |
} else {
|
|
|
268 |
wp_die(__('Copy creation failed, could not find original:', 'duplicate-post') . ' ' . htmlspecialchars($id));
|
269 |
}
|
270 |
}
|
320 |
|
321 |
/**
|
322 |
* Copy the attachments
|
|
|
323 |
*/
|
324 |
function duplicate_post_copy_attachments($new_id, $post){
|
325 |
// get thumbnail ID
|
359 |
wp_update_post( $cloned_child );
|
360 |
|
361 |
$alt_title = get_post_meta($child->ID, '_wp_attachment_image_alt', true);
|
362 |
+
if($alt_title) update_post_meta($new_attachment_id, '_wp_attachment_image_alt', $alt_title);
|
363 |
|
364 |
// if we have cloned the post thumbnail, set the copy as the thumbnail for the new post
|
365 |
if($old_thumbnail_id == $child->ID){
|
448 |
*/
|
449 |
function duplicate_post_create_duplicate($post, $status = '', $parent_id = '') {
|
450 |
|
|
|
|
|
451 |
if (!duplicate_post_is_post_type_enabled($post->post_type) && $post->post_type != 'attachment')
|
452 |
wp_die(__('Copy features for this post type are not enabled in options page', 'duplicate-post'));
|
453 |
+
|
454 |
if ($post->post_type != 'attachment'){
|
455 |
$prefix = sanitize_text_field(get_option('duplicate_post_title_prefix'));
|
456 |
$suffix = sanitize_text_field(get_option('duplicate_post_title_suffix'));
|
467 |
if ($title == ''){
|
468 |
// empty title
|
469 |
$title = __('Untitled');
|
470 |
+
}
|
471 |
|
472 |
|
473 |
if (get_option('duplicate_post_copystatus') == 0) $status = 'draft';
|
486 |
'ping_status' => $post->ping_status,
|
487 |
'post_author' => $new_post_author->ID,
|
488 |
'post_content' => (get_option('duplicate_post_copycontent') == '1') ? addslashes($post->post_content) : "" ,
|
489 |
+
'post_content_filtered' => (get_option('duplicate_post_copycontent') == '1') ? addslashes($post->post_content_filtered) : "" ,
|
490 |
'post_excerpt' => (get_option('duplicate_post_copyexcerpt') == '1') ? addslashes($post->post_excerpt) : "",
|
491 |
'post_mime_type' => $post->post_mime_type,
|
492 |
'post_parent' => $new_post_parent = empty($parent_id)? $post->post_parent : $parent_id,
|
542 |
}
|
543 |
return $links;
|
544 |
}
|
545 |
+
|
546 |
+
add_action( 'admin_notices', 'duplicate_post_action_admin_notice' );
|
547 |
+
|
548 |
+
function duplicate_post_action_admin_notice() {
|
549 |
+
if ( ! empty( $_REQUEST['cloned'] ) ) {
|
550 |
+
$copied_posts = intval( $_REQUEST['cloned'] );
|
551 |
+
printf( '<div id="message" class="updated fade"><p>' .
|
552 |
+
_n( '%s item copied.',
|
553 |
+
'%s items copied.',
|
554 |
+
$copied_posts,
|
555 |
+
'duplicate-post'
|
556 |
+
) . '</p></div>', $copied_posts );
|
557 |
+
remove_query_arg( 'cloned' );
|
558 |
+
}
|
559 |
+
}
|
duplicate-post-common.php
CHANGED
@@ -76,7 +76,6 @@ function duplicate_post_clone_post_link( $link = null, $before = '', $after = ''
|
|
76 |
if ( null === $link )
|
77 |
$link = __('Copy to a new draft', 'duplicate-post');
|
78 |
|
79 |
-
$post_type_obj = get_post_type_object( $post->post_type );
|
80 |
$link = '<a class="post-clone-link" href="' . $url . '" title="'
|
81 |
. esc_attr(__("Copy to a new draft", 'duplicate-post'))
|
82 |
.'">' . $link . '</a>';
|
@@ -91,7 +90,7 @@ function duplicate_post_clone_post_link( $link = null, $before = '', $after = ''
|
|
91 |
*/
|
92 |
function duplicate_post_get_original($id = 0 , $output = OBJECT){
|
93 |
if ( !$post = get_post( $id ) )
|
94 |
-
|
95 |
$original_ID = get_post_meta( $post->ID, '_dp_original');
|
96 |
if (empty($original_ID)) return null;
|
97 |
$original_post = get_post($original_ID[0], $output);
|
@@ -103,12 +102,12 @@ function duplicate_post_admin_bar_render() {
|
|
103 |
global $wp_admin_bar;
|
104 |
$current_object = get_queried_object();
|
105 |
if ( empty($current_object) )
|
106 |
-
|
107 |
if ( ! empty( $current_object->post_type )
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
{
|
113 |
$wp_admin_bar->add_menu( array(
|
114 |
'id' => 'new_draft',
|
@@ -119,11 +118,16 @@ function duplicate_post_admin_bar_render() {
|
|
119 |
}
|
120 |
|
121 |
function duplicate_post_add_css() {
|
122 |
-
$current_object = get_queried_object
|
123 |
-
if (
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
127 |
}
|
128 |
}
|
129 |
|
@@ -137,6 +141,4 @@ if (get_option ( 'duplicate_post_show_adminbar' ) == 1) {
|
|
137 |
*/
|
138 |
function duplicate_post_tax_obj_cmp($a, $b) {
|
139 |
return ($a->public < $b->public);
|
140 |
-
}
|
141 |
-
|
142 |
-
?>
|
76 |
if ( null === $link )
|
77 |
$link = __('Copy to a new draft', 'duplicate-post');
|
78 |
|
|
|
79 |
$link = '<a class="post-clone-link" href="' . $url . '" title="'
|
80 |
. esc_attr(__("Copy to a new draft", 'duplicate-post'))
|
81 |
.'">' . $link . '</a>';
|
90 |
*/
|
91 |
function duplicate_post_get_original($id = 0 , $output = OBJECT){
|
92 |
if ( !$post = get_post( $id ) )
|
93 |
+
return;
|
94 |
$original_ID = get_post_meta( $post->ID, '_dp_original');
|
95 |
if (empty($original_ID)) return null;
|
96 |
$original_post = get_post($original_ID[0], $output);
|
102 |
global $wp_admin_bar;
|
103 |
$current_object = get_queried_object();
|
104 |
if ( empty($current_object) )
|
105 |
+
return;
|
106 |
if ( ! empty( $current_object->post_type )
|
107 |
+
&& ( $post_type_object = get_post_type_object( $current_object->post_type ) )
|
108 |
+
&& duplicate_post_is_current_user_allowed_to_copy()
|
109 |
+
&& ( $post_type_object->show_ui || 'attachment' == $current_object->post_type )
|
110 |
+
&& (duplicate_post_is_post_type_enabled($current_object->post_type) ) )
|
111 |
{
|
112 |
$wp_admin_bar->add_menu( array(
|
113 |
'id' => 'new_draft',
|
118 |
}
|
119 |
|
120 |
function duplicate_post_add_css() {
|
121 |
+
$current_object = get_queried_object();
|
122 |
+
if ( empty($current_object) )
|
123 |
+
return;
|
124 |
+
if ( ! empty( $current_object->post_type )
|
125 |
+
&& ( $post_type_object = get_post_type_object( $current_object->post_type ) )
|
126 |
+
&& duplicate_post_is_current_user_allowed_to_copy()
|
127 |
+
&& ( $post_type_object->show_ui || 'attachment' == $current_object->post_type )
|
128 |
+
&& (duplicate_post_is_post_type_enabled($current_object->post_type) ) )
|
129 |
+
{
|
130 |
+
wp_enqueue_style ( 'duplicate-post', plugins_url('/duplicate-post.css', __FILE__));
|
131 |
}
|
132 |
}
|
133 |
|
141 |
*/
|
142 |
function duplicate_post_tax_obj_cmp($a, $b) {
|
143 |
return ($a->public < $b->public);
|
144 |
+
}
|
|
|
|
duplicate-post-options.php
CHANGED
@@ -90,7 +90,7 @@ function duplicate_post_options() {
|
|
90 |
jQuery('section').hide();
|
91 |
jQuery('section').eq(jQuery(this).index()).show();
|
92 |
return false;
|
93 |
-
})
|
94 |
|
95 |
function toggle_private_taxonomies(){
|
96 |
jQuery('.taxonomy_private').toggle();
|
90 |
jQuery('section').hide();
|
91 |
jQuery('section').eq(jQuery(this).index()).show();
|
92 |
return false;
|
93 |
+
});
|
94 |
|
95 |
function toggle_private_taxonomies(){
|
96 |
jQuery('.taxonomy_private').toggle();
|
duplicate-post.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Duplicate Post
|
4 |
Plugin URI: http://lopo.it/duplicate-post-plugin/
|
5 |
Description: Clone posts and pages.
|
6 |
-
Version: 3.0.
|
7 |
Author: Enrico Battocchi
|
8 |
Author URI: http://lopo.it
|
9 |
Text Domain: duplicate-post
|
@@ -31,7 +31,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
31 |
}
|
32 |
|
33 |
// Version of the plugin
|
34 |
-
define('DUPLICATE_POST_CURRENT_VERSION', '3.0.
|
35 |
|
36 |
|
37 |
/**
|
@@ -54,6 +54,4 @@ require_once (dirname(__FILE__).'/duplicate-post-common.php');
|
|
54 |
|
55 |
if (is_admin()){
|
56 |
require_once (dirname(__FILE__).'/duplicate-post-admin.php');
|
57 |
-
}
|
58 |
-
|
59 |
-
?>
|
3 |
Plugin Name: Duplicate Post
|
4 |
Plugin URI: http://lopo.it/duplicate-post-plugin/
|
5 |
Description: Clone posts and pages.
|
6 |
+
Version: 3.0.3
|
7 |
Author: Enrico Battocchi
|
8 |
Author URI: http://lopo.it
|
9 |
Text Domain: duplicate-post
|
31 |
}
|
32 |
|
33 |
// Version of the plugin
|
34 |
+
define('DUPLICATE_POST_CURRENT_VERSION', '3.0.3' );
|
35 |
|
36 |
|
37 |
/**
|
54 |
|
55 |
if (is_admin()){
|
56 |
require_once (dirname(__FILE__).'/duplicate-post-admin.php');
|
57 |
+
}
|
|
|
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: lopo
|
|
3 |
Donate link: http://lopo.it/duplicate-post-plugin/
|
4 |
Tags: duplicate post, copy, clone
|
5 |
Requires at least: 3.4
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -90,6 +90,9 @@ There is an open ticket in WordPress Trac, as other plugin developers too are in
|
|
90 |
|
91 |
== Upgrade Notice ==
|
92 |
|
|
|
|
|
|
|
93 |
= 3.0.2 =
|
94 |
Small bugfixes: check the changelog for more info
|
95 |
|
@@ -137,6 +140,12 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you
|
|
137 |
|
138 |
== Changelog ==
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
= 3.0.2 =
|
141 |
* Can now be enabled for every custom post type with visible UI (not just public ones)
|
142 |
* Admin bar CSS only enqueued when needed
|
3 |
Donate link: http://lopo.it/duplicate-post-plugin/
|
4 |
Tags: duplicate post, copy, clone
|
5 |
Requires at least: 3.4
|
6 |
+
Tested up to: 4.7
|
7 |
+
Stable tag: 3.0.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
90 |
|
91 |
== Upgrade Notice ==
|
92 |
|
93 |
+
= 3.0.3 =
|
94 |
+
Notices + small fixes and improvements
|
95 |
+
|
96 |
= 3.0.2 =
|
97 |
Small bugfixes: check the changelog for more info
|
98 |
|
140 |
|
141 |
== Changelog ==
|
142 |
|
143 |
+
= 3.0.3 =
|
144 |
+
* Notices in admin after copying
|
145 |
+
* Fixes warning in custom post type archives
|
146 |
+
* Uses site options for version and notice
|
147 |
+
* Minor fixes
|
148 |
+
|
149 |
= 3.0.2 =
|
150 |
* Can now be enabled for every custom post type with visible UI (not just public ones)
|
151 |
* Admin bar CSS only enqueued when needed
|