Duplicate Post - Version 2.1.1

Version Description

Fix for upgrade problem

Download this release

Release Info

Developer lopo
Plugin Icon 128x128 Duplicate Post
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1 to 2.1.1

Files changed (3) hide show
  1. duplicate-post-admin.php +34 -17
  2. duplicate-post.php +2 -2
  3. readme.txt +8 -2
duplicate-post-admin.php CHANGED
@@ -20,20 +20,49 @@ function duplicate_post_get_current_version() {
20
  }
21
 
22
  /**
23
- * Plugin activation
24
  */
25
- add_action('activate_duplicate-post/duplicate-post.php','duplicate_post_plugin_activation');
26
 
27
- function duplicate_post_plugin_activation() {
28
  $installed_version = duplicate_post_get_installed_version();
29
 
30
- if ( $installed_version==duplicate_post_get_current_version() ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  // do nothing
32
- } else {
33
  // delete old, obsolete options
34
  delete_option('duplicate_post_admin_user_level');
35
  delete_option('duplicate_post_create_user_level');
36
  delete_option('duplicate_post_view_user_level');
 
37
 
38
  /*
39
  * Convert old userlevel option to new capability scheme
@@ -76,20 +105,8 @@ function duplicate_post_plugin_activation() {
76
  // Update version number
77
  update_option( 'duplicate_post_version', duplicate_post_get_current_version() );
78
 
79
- // enable notice
80
- update_option('dp_notice', 1);
81
  }
82
 
83
-
84
- function dp_admin_notice(){
85
- echo '<div class="updated">
86
- <p>'.sprintf(__('<strong>Duplicate Post</strong> now has two different ways to work: you can clone immediately or you can copy to a new draft to edit.<br/>Learn more on the <a href="%s">plugin page</a>.', DUPLICATE_POST_I18N_DOMAIN), "http://wordpress.org/extend/plugins/duplicate-post/").'</p>
87
- </div>';
88
- update_option('dp_notice', 0);
89
- }
90
-
91
- if(get_option('dp_notice') != 0) add_action('admin_notices', 'dp_admin_notice');
92
-
93
  add_filter('post_row_actions', 'duplicate_post_make_duplicate_link_row',10,2);
94
  add_filter('page_row_actions', 'duplicate_post_make_duplicate_link_row',10,2);
95
 
20
  }
21
 
22
  /**
23
+ * Plugin upgrade
24
  */
25
+ add_action('admin_init','duplicate_post_plugin_upgrade');
26
 
27
+ function duplicate_post_plugin_upgrade() {
28
  $installed_version = duplicate_post_get_installed_version();
29
 
30
+ if (empty($installed_version)) { // first install
31
+
32
+ // Add capability to admin and editors
33
+
34
+ // Get default roles
35
+ $default_roles = array(
36
+ 3 => 'editor',
37
+ 8 => 'administrator',
38
+ );
39
+
40
+ // Cycle all roles and assign capability if its level >= duplicate_post_copy_user_level
41
+ foreach ($default_roles as $level => $name){
42
+ $role = get_role($name);
43
+ $role->add_cap( 'copy_posts' );
44
+ }
45
+
46
+ add_option(
47
+ 'duplicate_post_copyexcerpt',
48
+ '1',
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
61
  // delete old, obsolete options
62
  delete_option('duplicate_post_admin_user_level');
63
  delete_option('duplicate_post_create_user_level');
64
  delete_option('duplicate_post_view_user_level');
65
+ delete_option('dp_notice');
66
 
67
  /*
68
  * Convert old userlevel option to new capability scheme
105
  // Update version number
106
  update_option( 'duplicate_post_version', duplicate_post_get_current_version() );
107
 
 
 
108
  }
109
 
 
 
 
 
 
 
 
 
 
 
110
  add_filter('post_row_actions', 'duplicate_post_make_duplicate_link_row',10,2);
111
  add_filter('page_row_actions', 'duplicate_post_make_duplicate_link_row',10,2);
112
 
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.1
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.1' );
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.1.1
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.1.1' );
34
 
35
  /**
36
  * Initialise the internationalisation domain
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.0
6
- Tested up to: 3.3
7
- Stable tag: 2.1
8
 
9
  Clone posts and pages.
10
 
@@ -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 =
84
  Copy from admin bar + user levels out, roles and capabilities in.
85
 
@@ -100,6 +103,9 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you
100
 
101
  == Changelog ==
102
 
 
 
 
103
  = 2.1 =
104
  * Even more code cleaning (no more custom queries, using WP API)
105
  * Term order preserved when copying
3
  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.1.1
8
 
9
  Clone posts and pages.
10
 
80
 
81
  == Upgrade Notice ==
82
 
83
+ = 2.1.1 =
84
+ Fix for upgrade problem
85
+
86
  = 2.1 =
87
  Copy from admin bar + user levels out, roles and capabilities in.
88
 
103
 
104
  == Changelog ==
105
 
106
+ = 2.1.1 =
107
+ * Can't rely on activation hook for upgrade, this caused problems with new options
108
+
109
  = 2.1 =
110
  * Even more code cleaning (no more custom queries, using WP API)
111
  * Term order preserved when copying