Version Description
VERY IMPORTANT UPGRADE to get rid of problems with complex custom fields, afflicting both 2.1.* releases.
Download this release
Release Info
| Developer | lopo |
| Plugin | |
| Version | 2.2 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.1 to 2.2
- duplicate-post-admin.php +27 -39
- duplicate-post-options.php +1 -1
- duplicate-post.php +2 -2
- readme.txt +12 -4
duplicate-post-admin.php
CHANGED
|
@@ -43,18 +43,9 @@ function duplicate_post_plugin_upgrade() {
|
|
| 43 |
$role->add_cap( 'copy_posts' );
|
| 44 |
}
|
| 45 |
|
| 46 |
-
add_option(
|
| 47 |
-
'
|
| 48 |
-
|
| 49 |
-
'Copy the excerpt from the original post/page' );
|
| 50 |
-
add_option(
|
| 51 |
-
'duplicate_post_copystatus',
|
| 52 |
-
'0',
|
| 53 |
-
'Copy the status (draft, published, pending) from the original post/page' );
|
| 54 |
-
add_option(
|
| 55 |
-
'duplicate_post_taxonomies_blacklist',
|
| 56 |
-
array(),
|
| 57 |
-
'List of the taxonomies that mustn\'t be copied' );
|
| 58 |
} else if ( $installed_version==duplicate_post_get_current_version() ) { //re-install
|
| 59 |
// do nothing
|
| 60 |
} else { //upgrade form previous version
|
|
@@ -70,37 +61,30 @@ function duplicate_post_plugin_upgrade() {
|
|
| 70 |
|
| 71 |
// Get old duplicate_post_copy_user_level option
|
| 72 |
$min_user_level = get_option('duplicate_post_copy_user_level');
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
1 => 'contributor',
|
| 77 |
2 => 'author',
|
| 78 |
3 => 'editor',
|
| 79 |
8 => 'administrator',
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
add_option(
|
| 93 |
-
'duplicate_post_copyexcerpt',
|
| 94 |
-
'1',
|
| 95 |
-
'Copy the excerpt from the original post/page' );
|
| 96 |
-
add_option(
|
| 97 |
-
'duplicate_post_copystatus',
|
| 98 |
-
'0',
|
| 99 |
-
'Copy the status (draft, published, pending) from the original post/page' );
|
| 100 |
-
add_option(
|
| 101 |
-
'duplicate_post_taxonomies_blacklist',
|
| 102 |
-
array(),
|
| 103 |
-
'List of the taxonomies that mustn\'t be copied' );
|
| 104 |
}
|
| 105 |
// Update version number
|
| 106 |
update_option( 'duplicate_post_version', duplicate_post_get_current_version() );
|
|
@@ -245,7 +229,9 @@ function duplicate_post_copy_post_meta_info($new_id, $post) {
|
|
| 245 |
foreach ($meta_keys as $meta_key) {
|
| 246 |
$meta_values = get_post_custom_values($meta_key, $post->ID);
|
| 247 |
foreach ($meta_values as $meta_value) {
|
| 248 |
-
|
|
|
|
|
|
|
| 249 |
}
|
| 250 |
}
|
| 251 |
}
|
|
@@ -286,7 +272,6 @@ function duplicate_post_create_duplicate($post, $status = '') {
|
|
| 286 |
|
| 287 |
$new_post_id = wp_insert_post($new_post);
|
| 288 |
|
| 289 |
-
add_post_meta($new_post_id, '_dp_original', $post->ID);
|
| 290 |
|
| 291 |
// If you have written a plugin which uses non-WP database tables to save
|
| 292 |
// information about a post you can hook this action to dupe that data.
|
|
@@ -294,6 +279,9 @@ function duplicate_post_create_duplicate($post, $status = '') {
|
|
| 294 |
do_action( 'dp_duplicate_page', $new_post_id, $post );
|
| 295 |
else
|
| 296 |
do_action( 'dp_duplicate_post', $new_post_id, $post );
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
// If the copy gets immediately published, we have to set a proper slug.
|
| 299 |
if ($new_post_status == 'publish' || $new_post_status == 'future'){
|
| 43 |
$role->add_cap( 'copy_posts' );
|
| 44 |
}
|
| 45 |
|
| 46 |
+
add_option('duplicate_post_copyexcerpt','1');
|
| 47 |
+
add_option('duplicate_post_copystatus','0');
|
| 48 |
+
add_option('duplicate_post_taxonomies_blacklist',array());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
} else if ( $installed_version==duplicate_post_get_current_version() ) { //re-install
|
| 50 |
// do nothing
|
| 51 |
} else { //upgrade form previous version
|
| 61 |
|
| 62 |
// Get old duplicate_post_copy_user_level option
|
| 63 |
$min_user_level = get_option('duplicate_post_copy_user_level');
|
| 64 |
+
|
| 65 |
+
if (!empty($min_user_level)){
|
| 66 |
+
// Get default roles
|
| 67 |
+
$default_roles = array(
|
| 68 |
1 => 'contributor',
|
| 69 |
2 => 'author',
|
| 70 |
3 => 'editor',
|
| 71 |
8 => 'administrator',
|
| 72 |
+
);
|
| 73 |
+
|
| 74 |
+
// Cycle all roles and assign capability if its level >= duplicate_post_copy_user_level
|
| 75 |
+
foreach ($default_roles as $level => $name){
|
| 76 |
+
$role = get_role($name);
|
| 77 |
+
if ($role && $min_user_level <= $level)
|
| 78 |
+
$role->add_cap( 'copy_posts' );
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
// delete old option
|
| 82 |
+
delete_option('duplicate_post_copy_user_level');
|
| 83 |
}
|
| 84 |
|
| 85 |
+
add_option('duplicate_post_copyexcerpt','1');
|
| 86 |
+
add_option('duplicate_post_copystatus','0');
|
| 87 |
+
add_option('duplicate_post_taxonomies_blacklist',array());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
}
|
| 89 |
// Update version number
|
| 90 |
update_option( 'duplicate_post_version', duplicate_post_get_current_version() );
|
| 229 |
foreach ($meta_keys as $meta_key) {
|
| 230 |
$meta_values = get_post_custom_values($meta_key, $post->ID);
|
| 231 |
foreach ($meta_values as $meta_value) {
|
| 232 |
+
$meta_obj = unserialize($meta_value);
|
| 233 |
+
if(!$meta_obj) add_post_meta($new_id, $meta_key, $meta_value);
|
| 234 |
+
else add_post_meta($new_id, $meta_key, $meta_obj);
|
| 235 |
}
|
| 236 |
}
|
| 237 |
}
|
| 272 |
|
| 273 |
$new_post_id = wp_insert_post($new_post);
|
| 274 |
|
|
|
|
| 275 |
|
| 276 |
// If you have written a plugin which uses non-WP database tables to save
|
| 277 |
// information about a post you can hook this action to dupe that data.
|
| 279 |
do_action( 'dp_duplicate_page', $new_post_id, $post );
|
| 280 |
else
|
| 281 |
do_action( 'dp_duplicate_post', $new_post_id, $post );
|
| 282 |
+
|
| 283 |
+
delete_post_meta($new_post_id, '_dp_original');
|
| 284 |
+
add_post_meta($new_post_id, '_dp_original', $post->ID);
|
| 285 |
|
| 286 |
// If the copy gets immediately published, we have to set a proper slug.
|
| 287 |
if ($new_post_status == 'publish' || $new_post_status == 'future'){
|
duplicate-post-options.php
CHANGED
|
@@ -51,7 +51,7 @@ function duplicate_post_options() {
|
|
| 51 |
?>
|
| 52 |
<div class="wrap">
|
| 53 |
<div id="icon-options-general" class="icon32"><br></div>
|
| 54 |
-
<h2
|
| 55 |
<?php _e("Duplicate Post Options", DUPLICATE_POST_I18N_DOMAIN); ?>
|
| 56 |
</h2>
|
| 57 |
|
| 51 |
?>
|
| 52 |
<div class="wrap">
|
| 53 |
<div id="icon-options-general" class="icon32"><br></div>
|
| 54 |
+
<h2>
|
| 55 |
<?php _e("Duplicate Post Options", DUPLICATE_POST_I18N_DOMAIN); ?>
|
| 56 |
</h2>
|
| 57 |
|
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: 2.
|
| 7 |
Author: Enrico Battocchi
|
| 8 |
Author URI: http://lopo.it
|
| 9 |
Text Domain: duplicate-post
|
|
@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
| 30 |
define('DUPLICATE_POST_I18N_DOMAIN', 'duplicate-post');
|
| 31 |
|
| 32 |
// Version of the plugin
|
| 33 |
-
define('DUPLICATE_POST_CURRENT_VERSION', '2.
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Initialise the internationalisation domain
|
| 3 |
Plugin Name: Duplicate Post
|
| 4 |
Plugin URI: http://lopo.it/duplicate-post-plugin/
|
| 5 |
Description: Clone posts and pages.
|
| 6 |
+
Version: 2.2
|
| 7 |
Author: Enrico Battocchi
|
| 8 |
Author URI: http://lopo.it
|
| 9 |
Text Domain: duplicate-post
|
| 30 |
define('DUPLICATE_POST_I18N_DOMAIN', 'duplicate-post');
|
| 31 |
|
| 32 |
// Version of the plugin
|
| 33 |
+
define('DUPLICATE_POST_CURRENT_VERSION', '2.2' );
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Initialise the internationalisation domain
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: http://lopo.it/duplicate-post-plugin/
|
|
| 4 |
Tags: duplicate post, copy, clone
|
| 5 |
Requires at least: 3.0
|
| 6 |
Tested up to: 3.3.1
|
| 7 |
-
Stable tag: 2.
|
| 8 |
|
| 9 |
Clone posts and pages.
|
| 10 |
|
|
@@ -18,7 +18,7 @@ This plugin allows to clone a post or page, or edit it as a new draft.
|
|
| 18 |
|
| 19 |
3. On the post edit screen, you can click on 'Copy to a new draft' above "Cancel"/"Move to trash".
|
| 20 |
|
| 21 |
-
4. While viewing a post as a logged in user, you can click on 'Copy to a new draft' as a dropdown link under "
|
| 22 |
|
| 23 |
2, 3 and 4 will lead to the edit page for the new draft: change what you want, click on 'Publish' and you're done.
|
| 24 |
|
|
@@ -56,11 +56,11 @@ Use WordPress' Add New Plugin feature, searching "Duplicate Post", or download t
|
|
| 56 |
|
| 57 |
= The plugin doesn't work, why? =
|
| 58 |
|
| 59 |
-
First, check your version of WordPress: the plugin is not supposed to work on old versions anymore.
|
| 60 |
|
| 61 |
Then try to deactivate and re-activate it, some user have reported that this fixes the problem.
|
| 62 |
|
| 63 |
-
Pay also
|
| 64 |
|
| 65 |
If not, maybe there is some kind of conflict with other plugins: feel free to write me and we'll try to discover a solution (it will be *really* helpful if you try to deactivate all your other plugins one by one to see which one conflicts with mine... But do it only if you know what you're doing, I will not be responsible of any problem you may experience).
|
| 66 |
|
|
@@ -80,6 +80,9 @@ There is an open ticket in WordPress Trac, as other plugin developers too are in
|
|
| 80 |
|
| 81 |
== Upgrade Notice ==
|
| 82 |
|
|
|
|
|
|
|
|
|
|
| 83 |
= 2.1.1 =
|
| 84 |
Fix for upgrade problem
|
| 85 |
|
|
@@ -103,6 +106,11 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you
|
|
| 103 |
|
| 104 |
== Changelog ==
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
= 2.1.1 =
|
| 107 |
* Can't rely on activation hook for upgrade, this caused problems with new options
|
| 108 |
|
| 4 |
Tags: duplicate post, copy, clone
|
| 5 |
Requires at least: 3.0
|
| 6 |
Tested up to: 3.3.1
|
| 7 |
+
Stable tag: 2.2
|
| 8 |
|
| 9 |
Clone posts and pages.
|
| 10 |
|
| 18 |
|
| 19 |
3. On the post edit screen, you can click on 'Copy to a new draft' above "Cancel"/"Move to trash".
|
| 20 |
|
| 21 |
+
4. While viewing a post as a logged in user, you can click on 'Copy to a new draft' as a dropdown link under "Edit Post" in the admin bar.
|
| 22 |
|
| 23 |
2, 3 and 4 will lead to the edit page for the new draft: change what you want, click on 'Publish' and you're done.
|
| 24 |
|
| 56 |
|
| 57 |
= The plugin doesn't work, why? =
|
| 58 |
|
| 59 |
+
First, check your version of WordPress: the plugin is not supposed to work on old versions anymore. Make sure also to upgrade to the last version of the plugin!
|
| 60 |
|
| 61 |
Then try to deactivate and re-activate it, some user have reported that this fixes the problem.
|
| 62 |
|
| 63 |
+
Pay attention also to the new "Roles allowed to copy" option: it should convert the former "user level" option to the new standard, but unknown problems may arise. Make sure that your role is enabled.
|
| 64 |
|
| 65 |
If not, maybe there is some kind of conflict with other plugins: feel free to write me and we'll try to discover a solution (it will be *really* helpful if you try to deactivate all your other plugins one by one to see which one conflicts with mine... But do it only if you know what you're doing, I will not be responsible of any problem you may experience).
|
| 66 |
|
| 80 |
|
| 81 |
== Upgrade Notice ==
|
| 82 |
|
| 83 |
+
= 2.2 =
|
| 84 |
+
VERY IMPORTANT UPGRADE to get rid of problems with complex custom fields, afflicting both 2.1.* releases.
|
| 85 |
+
|
| 86 |
= 2.1.1 =
|
| 87 |
Fix for upgrade problem
|
| 88 |
|
| 106 |
|
| 107 |
== Changelog ==
|
| 108 |
|
| 109 |
+
= 2.2 =
|
| 110 |
+
* Fix for problems when copying serialized meta fields
|
| 111 |
+
* Fix for multiple _dp_original field
|
| 112 |
+
* Removed deprecated parameter when adding options
|
| 113 |
+
|
| 114 |
= 2.1.1 =
|
| 115 |
* Can't rely on activation hook for upgrade, this caused problems with new options
|
| 116 |
|
