Duplicate Post - Version 2.5

Version Description

PHP 5.4 (Strict Standards) compatible + Fixed possible XSS and SQL injections + other bugs

Download this release

Release Info

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

Code changes from version 2.4.1 to 2.5

duplicate-post-admin.php CHANGED
@@ -182,7 +182,7 @@ function duplicate_post_save_as_new_post($status = ''){
182
 
183
  } else {
184
  $post_type_obj = get_post_type_object( $post->post_type );
185
- wp_die(esc_attr(__('Copy creation failed, could not find original:', DUPLICATE_POST_I18N_DOMAIN)) . ' ' . $id);
186
  }
187
  }
188
 
@@ -198,7 +198,8 @@ function duplicate_post_get_current_user() {
198
  return $userdata;
199
  } else {
200
  $user_login = $_COOKIE[USER_COOKIE];
201
- $current_user = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_login='$user_login'");
 
202
  return $current_user;
203
  }
204
  }
@@ -315,17 +316,6 @@ function duplicate_post_create_duplicate($post, $status = '', $parent_id = '') {
315
 
316
  $new_post_id = wp_insert_post($new_post);
317
 
318
-
319
- // If you have written a plugin which uses non-WP database tables to save
320
- // information about a post you can hook this action to dupe that data.
321
- if ($post->post_type == 'page' || (function_exists('is_post_type_hierarchical') && is_post_type_hierarchical( $post->post_type )))
322
- do_action( 'dp_duplicate_page', $new_post_id, $post );
323
- else
324
- do_action( 'dp_duplicate_post', $new_post_id, $post );
325
-
326
- delete_post_meta($new_post_id, '_dp_original');
327
- add_post_meta($new_post_id, '_dp_original', $post->ID);
328
-
329
  // If the copy is published or scheduled, we have to set a proper slug.
330
  if ($new_post_status == 'publish' || $new_post_status == 'future'){
331
  $post_name = wp_unique_post_slug($post->post_name, $new_post_id, $new_post_status, $post->post_type, $new_post_parent);
@@ -338,6 +328,16 @@ function duplicate_post_create_duplicate($post, $status = '', $parent_id = '') {
338
  wp_update_post( $new_post );
339
  }
340
 
 
 
 
 
 
 
 
 
 
 
341
  return $new_post_id;
342
  }
343
 
182
 
183
  } else {
184
  $post_type_obj = get_post_type_object( $post->post_type );
185
+ wp_die(esc_attr(__('Copy creation failed, could not find original:', DUPLICATE_POST_I18N_DOMAIN)) . ' ' . htmlspecialchars($id));
186
  }
187
  }
188
 
198
  return $userdata;
199
  } else {
200
  $user_login = $_COOKIE[USER_COOKIE];
201
+ $sql = $wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_login=%s", $user_login);
202
+ $current_user = $wpdb->get_results($sql);
203
  return $current_user;
204
  }
205
  }
316
 
317
  $new_post_id = wp_insert_post($new_post);
318
 
 
 
 
 
 
 
 
 
 
 
 
319
  // If the copy is published or scheduled, we have to set a proper slug.
320
  if ($new_post_status == 'publish' || $new_post_status == 'future'){
321
  $post_name = wp_unique_post_slug($post->post_name, $new_post_id, $new_post_status, $post->post_type, $new_post_parent);
328
  wp_update_post( $new_post );
329
  }
330
 
331
+ // If you have written a plugin which uses non-WP database tables to save
332
+ // information about a post you can hook this action to dupe that data.
333
+ if ($post->post_type == 'page' || (function_exists('is_post_type_hierarchical') && is_post_type_hierarchical( $post->post_type )))
334
+ do_action( 'dp_duplicate_page', $new_post_id, $post );
335
+ else
336
+ do_action( 'dp_duplicate_post', $new_post_id, $post );
337
+
338
+ delete_post_meta($new_post_id, '_dp_original');
339
+ add_post_meta($new_post_id, '_dp_original', $post->ID);
340
+
341
  return $new_post_id;
342
  }
343
 
duplicate-post-common.php CHANGED
@@ -28,7 +28,7 @@ function duplicate_post_get_clone_post_link( $id = 0, $context = 'display', $dra
28
  if ( !duplicate_post_is_current_user_allowed_to_copy() )
29
  return;
30
 
31
- if ( !$post = &get_post( $id ) )
32
  return;
33
 
34
  if ($draft)
@@ -56,7 +56,7 @@ function duplicate_post_get_clone_post_link( $id = 0, $context = 'display', $dra
56
  * @param int $id Optional. Post ID.
57
  */
58
  function duplicate_post_clone_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
59
- if ( !$post = &get_post( $id ) )
60
  return;
61
 
62
  if ( !$url = duplicate_post_get_clone_post_link( $post->ID ) )
@@ -79,11 +79,11 @@ function duplicate_post_clone_post_link( $link = null, $before = '', $after = ''
79
  * @return mixed Post data
80
  */
81
  function duplicate_post_get_original($id = 0 , $output = OBJECT){
82
- if ( !$post = &get_post( $id ) )
83
  return;
84
  $original_ID = get_post_meta( $post->ID, '_dp_original');
85
  if (empty($original_ID)) return null;
86
- $original_post = &get_post($original_ID[0], $output);
87
  return $original_post;
88
  }
89
  // Admin bar
28
  if ( !duplicate_post_is_current_user_allowed_to_copy() )
29
  return;
30
 
31
+ if ( !$post = get_post( $id ) )
32
  return;
33
 
34
  if ($draft)
56
  * @param int $id Optional. Post ID.
57
  */
58
  function duplicate_post_clone_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
59
+ if ( !$post = get_post( $id ) )
60
  return;
61
 
62
  if ( !$url = duplicate_post_get_clone_post_link( $post->ID ) )
79
  * @return mixed Post data
80
  */
81
  function duplicate_post_get_original($id = 0 , $output = OBJECT){
82
+ if ( !$post = get_post( $id ) )
83
  return;
84
  $original_ID = get_post_meta( $post->ID, '_dp_original');
85
  if (empty($original_ID)) return null;
86
+ $original_post = get_post($original_ID[0], $output);
87
  return $original_post;
88
  }
89
  // Admin bar
duplicate-post-options.php CHANGED
@@ -25,7 +25,7 @@ function duplicate_post_register_settings() { // whitelist options
25
 
26
 
27
  function duplicate_post_menu() {
28
- add_options_page(__("Duplicate Post Options", DUPLICATE_POST_I18N_DOMAIN), __("Duplicate Post", DUPLICATE_POST_I18N_DOMAIN), 'administrator', 'duplicatepost', 'duplicate_post_options');
29
  }
30
 
31
  function duplicate_post_options() {
@@ -65,9 +65,14 @@ function duplicate_post_options() {
65
  <div
66
  style="border: solid 1px #aaaaaa; background-color: #eeeeee; margin: 9px 15px 4px 0; padding: 5px; text-align: center; font-weight: bold; float: left;">
67
  <a href="http://lopo.it/duplicate-post-plugin"><?php _e('Visit plugin site'); ?>
68
- </a> - <a href="http://lopo.it/duplicate-post-plugin"><?php _e('Donate', DUPLICATE_POST_I18N_DOMAIN); ?>
69
  </a> - <a href="http://lopo.it/duplicate-post-plugin"><?php _e('Translate', DUPLICATE_POST_I18N_DOMAIN); ?>
70
- </a>
 
 
 
 
 
 
71
  </div>
72
 
73
  <form method="post" action="options.php">
25
 
26
 
27
  function duplicate_post_menu() {
28
+ add_options_page(__("Duplicate Post Options", DUPLICATE_POST_I18N_DOMAIN), __("Duplicate Post", DUPLICATE_POST_I18N_DOMAIN), 'manage_options', 'duplicatepost', 'duplicate_post_options');
29
  }
30
 
31
  function duplicate_post_options() {
65
  <div
66
  style="border: solid 1px #aaaaaa; background-color: #eeeeee; margin: 9px 15px 4px 0; padding: 5px; text-align: center; font-weight: bold; float: left;">
67
  <a href="http://lopo.it/duplicate-post-plugin"><?php _e('Visit plugin site'); ?>
 
68
  </a> - <a href="http://lopo.it/duplicate-post-plugin"><?php _e('Translate', DUPLICATE_POST_I18N_DOMAIN); ?>
69
+ </a> - <a href="http://lopo.it/duplicate-post-plugin"><?php _e('Donate', DUPLICATE_POST_I18N_DOMAIN); ?> (10¢)
70
+ </a> <form style="display: inline-block; vertical-align: middle;" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input type="hidden" name="cmd" value="_s-xclick">
71
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHVwYJKoZIhvcNAQcEoIIHSDCCB0QCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYADP9YeBpxArWjXNp2GBWuLm4pHQGH+t/CQdt1CWKoETU7y3b8betF4cmZj1GxeiN8REOsrAPuhmZs8v3tHR3Qy5V854GfGNDh0zHgJ4U9NmC3Z2YiGbtEiKxeQE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="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
73
+ <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1"></form>
74
+
75
+
76
  </div>
77
 
78
  <form method="post" action="options.php">
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.4.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.4.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.5
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.5' );
34
 
35
  /**
36
  * Initialise the internationalisation domain
languages/duplicate-post-ca.mo CHANGED
Binary file
languages/duplicate-post-da_DK.mo ADDED
Binary file
languages/duplicate-post-de_DE.mo CHANGED
Binary file
languages/duplicate-post-es.mo CHANGED
Binary file
languages/duplicate-post-fi.mo ADDED
Binary file
languages/duplicate-post-fr_FR.mo CHANGED
Binary file
languages/duplicate-post-he_IL.mo CHANGED
Binary file
languages/duplicate-post-hr.mo ADDED
Binary file
languages/duplicate-post-it_IT.mo CHANGED
Binary file
languages/duplicate-post-ja.mo CHANGED
Binary file
languages/duplicate-post-nl_NL.mo CHANGED
Binary file
languages/duplicate-post-pl_PL.mo CHANGED
Binary file
languages/duplicate-post-pt_BR.mo CHANGED
Binary file
languages/duplicate-post-ro_RO.mo CHANGED
Binary file
languages/duplicate-post-sv_SE.mo CHANGED
Binary file
languages/duplicate-post-tr.mo CHANGED
Binary file
languages/duplicate-post-zh_CN.mo CHANGED
Binary file
readme.txt CHANGED
@@ -3,16 +3,17 @@ 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.2
7
- Stable tag: 2.4.1
8
  License: GPLv2 or later
 
9
 
10
  Clone posts and pages.
11
 
12
  == Description ==
13
 
14
  This plugin allows to clone a post or page, or edit it as a new draft.
15
- If you find this useful, [**please consider donating**](http://wordpress.org/plugins/duplicate-post/) whatever sum you choose, **even just 10 cents**. It's been downloaded thousands of times: just a few cents from every user would help me develop the plugin and improve support.
16
 
17
 
18
  How it works:
@@ -85,6 +86,9 @@ There is an open ticket in WordPress Trac, as other plugin developers too are in
85
 
86
  == Upgrade Notice ==
87
 
 
 
 
88
  = 2.4.1 =
89
  Fixes a couple of bug. Recommended if you have problems with v2.4
90
 
@@ -120,6 +124,13 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you
120
 
121
  == Changelog ==
122
 
 
 
 
 
 
 
 
123
  = 2.4.1 =
124
  * Fixed regression about draft permalinks
125
  * Fixed bug with guid
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.8.1
7
+ Stable tag: 2.5
8
  License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Clone posts and pages.
12
 
13
  == Description ==
14
 
15
  This plugin allows to clone a post or page, or edit it as a new draft.
16
+ If you find this useful, [**please consider donating**](http://lopo.it/duplicate-post-plugin/) whatever sum you choose, **even just 10 cents**. It's been downloaded thousands of times: just a few cents from every user would help me develop the plugin and improve support.
17
 
18
 
19
  How it works:
86
 
87
  == Upgrade Notice ==
88
 
89
+ = 2.5 =
90
+ PHP 5.4 (Strict Standards) compatible + Fixed possible XSS and SQL injections + other bugs
91
+
92
  = 2.4.1 =
93
  Fixes a couple of bug. Recommended if you have problems with v2.4
94
 
124
 
125
  == Changelog ==
126
 
127
+ = 2.5 =
128
+ * PHP 5.4 (Strict Standards) compatible
129
+ * Fixed possible XSS and SQL injections
130
+ * other bugs
131
+ * Updated and added translations
132
+ * Tested up to WP 3.8.1
133
+
134
  = 2.4.1 =
135
  * Fixed regression about draft permalinks
136
  * Fixed bug with guid