Duplicate Post - Version 1.0

Version Description

  • Better integration with WP 2.7+ interface
  • Added actions for plugins which store post metadata in self-managed tables
  • Added French and Spanish language files
  • Dropped WP 2.6.5 compatibility
Download this release

Release Info

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

Code changes from version 0.6.1 to 1.0

duplicate-post.php CHANGED
@@ -1,29 +1,29 @@
1
  <?php
2
  /*
3
- Plugin Name: Duplicate Post
4
- Plugin URI: http://www.lopo.it/duplicate-post.tar.gz
5
- Description: Create a copy of a post.
6
- Version: 0.6.1
7
- Author: Enrico Battocchi
8
- Author URI: http://www.lopo.it
9
- Text Domain: duplicate-post
10
- */
11
 
12
- /* Copyright 2008 Enrico Battocchi (email : enrico.battocchi@gmail.com)
13
 
14
- This program is free software; you can redistribute it and/or modify
15
- it under the terms of the GNU General Public License as published by
16
- the Free Software Foundation; either version 3 of the License, or
17
- (at your option) any later version.
18
 
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
 
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
29
  // Added by WarmStal
@@ -34,499 +34,515 @@ return;
34
  * This function calls the creation of a new copy of the selected post (as a draft)
35
  * then redirects to the edit post screen
36
  */
37
-
38
  function duplicate_post_save_as_new_post(){
39
  if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'duplicate_post_save_as_new_post' == $_REQUEST['action'] ) ) ) {
40
- wp_die(_e('No post to duplicate has been supplied!', DUPLICATE_POST_I18N_DOMAIN));
41
  }
42
-
43
  // Get the original post
44
- $id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']);
45
  $post = duplicate_post_get_post($id);
46
-
47
  // Copy the post and insert it
48
  if (isset($post) && $post!=null) {
49
  $new_id = duplicate_post_create_duplicate_from_post($post);
50
-
51
- // Show the post edit
52
- echo '<meta content="0; URL=post.php?action=edit&post=' . $new_id . '" http-equiv="Refresh" />';
 
 
 
 
53
  exit;
54
  } else {
55
- wp_die(_e('Post creation failed, could not find original post:', DUPLICATE_POST_I18N_DOMAIN) . ' ' . $id);
56
- }
57
  }
58
 
59
-
60
  /*
61
  * Same as above, for pages
62
  */
63
-
64
  function duplicate_post_save_as_new_page(){
65
  if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'duplicate_post_save_as_new_post' == $_REQUEST['action'] ) ) ) {
66
- wp_die(_e('No page to duplicate has been supplied!', DUPLICATE_POST_I18N_DOMAIN));
67
  }
68
-
69
  // Get the original page
70
- $id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']);
71
  $post = duplicate_post_get_page($id);
72
-
73
  // Copy the page and insert it
74
  if (isset($post) && $post!=null) {
75
  $new_id = duplicate_post_create_duplicate_from_page($post);
76
-
77
- // Show the page edit
78
- echo '<meta content="0; URL=page.php?action=edit&post=' . $new_id . '" http-equiv="Refresh" />';
 
 
 
 
79
  exit;
80
  } else {
81
- wp_die(_e('Post creation failed, could not find original post:', DUPLICATE_POST_I18N_DOMAIN) . ' ' . $id);
82
- }
83
  }
84
 
 
 
 
 
 
 
85
 
86
- // Version of the plugin
87
- define('DUPLICATE_POST_CURRENT_VERSION', '0.6' );
88
- define('DUPLICATE_POST_COLUMN', 'control_duplicate_post');
89
- define('DUPLICATE_POST_VIEW_USER_LEVEL_OPTION', 'duplicate_post_view_user_level');
90
- define('DUPLICATE_POST_CREATE_USER_LEVEL_OPTION', 'duplicate_post_create_user_level');
91
- define('DUPLICATE_POST_ADMIN_USER_LEVEL_OPTION', 'duplicate_post_admin_user_level');
92
-
93
- // i18n plugin domain
94
  define('DUPLICATE_POST_I18N_DOMAIN', 'duplicate-post');
95
 
96
- /**
97
- * Initialise the internationalisation domain
98
- */
99
- //if (!function_exists('duplicate_post_init_i18n')) {
100
- // function duplicate_post_init_i18n() {
101
- load_plugin_textdomain(DUPLICATE_POST_I18N_DOMAIN,
102
- 'wp-content/plugins/duplicate-post/languages','duplicate-post/languages');
103
- // }
104
- // duplicate_post_init_i18n();
105
- //}
106
-
107
- /**
108
- * Plugin activation
109
- */
110
  add_action('activate_duplicate-post/duplicate-post.php','duplicate_post_plugin_activation');
111
 
 
 
112
 
113
- function duplicate_post_plugin_activation() {
114
- $installed_version = duplicate_post_get_installed_version();
115
-
116
- if ( $installed_version==duplicate_post_get_current_version() ) {
117
- // do nothing
118
- } else if ( $installed_version=='' ) {
119
- // Add all options, nothing already installed
120
- add_option(
121
- DUPLICATE_POST_VIEW_USER_LEVEL_OPTION,
122
- '2',
123
- 'Default user level to copy posts' );
124
- add_option(
125
- DUPLICATE_POST_CREATE_USER_LEVEL_OPTION,
126
- '5',
127
- 'Default user level to create the templates' );
128
- add_option(
129
- DUPLICATE_POST_ADMIN_USER_LEVEL_OPTION,
130
- '8',
131
- 'Default user level to change the plugin options' );
132
- }
133
-
134
- // Update version number
135
- update_option( 'duplicate_post_version', duplicate_post_get_current_version() );
136
  }
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
- /**
140
- * Add a column in the post listing
141
- */
142
- add_filter('manage_posts_columns', 'duplicate_post_add_duplicate_post_column');
143
- // Added by WarmStal
144
- add_filter('manage_pages_columns', 'duplicate_post_add_duplicate_post_column');
145
- add_action('manage_posts_custom_column', 'duplicate_post_make_duplicate_link', 10, 2);
146
- // Added by WarmStal
147
- add_action('manage_pages_custom_column', 'duplicate_page_make_duplicate_link', 10, 2);
148
 
149
- add_action('admin_action_duplicate_post_save_as_new_post', 'duplicate_post_save_as_new_post');
150
- add_action('admin_action_duplicate_post_save_as_new_page', 'duplicate_post_save_as_new_page');
151
-
152
- function duplicate_post_add_duplicate_post_column($columns) {
153
- if (duplicate_post_is_current_user_allowed_to_create()) {
154
- $columns[DUPLICATE_POST_COLUMN] = '';
155
- }
156
- return $columns;
157
- }
158
-
159
- function duplicate_post_make_duplicate_link($column_name, $id) {
160
- if (duplicate_post_is_current_user_allowed_to_create()) {
161
- if ($column_name == DUPLICATE_POST_COLUMN) {
162
- echo "<a href='admin.php?action=duplicate_post_save_as_new_post&amp;post=" . $id
163
- . "' title='" . __("Make a duplicate from this post", DUPLICATE_POST_I18N_DOMAIN)
164
- . "' class='edit'>" . __("Duplicate", DUPLICATE_POST_I18N_DOMAIN) . "</a>";
165
- }
166
- }
167
  }
168
 
 
 
 
169
  // Added by WarmStal
170
  function duplicate_page_make_duplicate_link($column_name, $id) {
171
  if (duplicate_post_is_current_user_allowed_to_create()) {
172
  if ($column_name == DUPLICATE_POST_COLUMN) {
173
  echo "<a href='admin.php?action=duplicate_post_save_as_new_page&amp;post=" . $id
174
- . "' title='" . __("Make a duplicate from this page", DUPLICATE_POST_I18N_DOMAIN)
175
- . "' class='edit'>" . __("Duplicate", DUPLICATE_POST_I18N_DOMAIN) . "</a>";
176
  }
177
  }
178
  }
179
 
 
 
 
 
 
180
 
181
-
182
- /**
183
- * Add a button in the post edit form to create a clone
184
- */
185
- add_action( 'edit_form_advanced', 'duplicate_post_add_duplicate_post_button' );
186
-
187
-
188
-
189
- function duplicate_post_add_duplicate_post_button() {
190
- if ( isset( $_GET['post'] ) && duplicate_post_is_current_user_allowed_to_create()) {
191
- $notifyUrl = "admin.php?action=duplicate_post_save_as_new_post&post=" . $_GET['post'];
192
- ?>
193
- <p class="submit">
194
- <span style="font-weight: bold; color: red;">
195
- <a href="<?php echo $notifyUrl; ?>"><?php _e('Click here to create a copy of this post.', DUPLICATE_POST_I18N_DOMAIN); ?></a>
196
- </span>
197
- </p>
198
- <?php
199
- }
200
- }
201
 
202
  /**
203
- * Add a button in the page edit form to create a clone
204
- */
205
- add_action( 'edit_page_form', 'duplicate_post_add_duplicate_page_button' );
206
-
207
- function duplicate_post_add_duplicate_page_button() {
208
- if ( isset( $_GET['post'] ) && duplicate_post_is_current_user_allowed_to_create()) {
209
- $notifyUrl = "admin.php?action=duplicate_post_save_as_new_page.php&post=" . $_GET['post'];
210
- ?>
211
- <p class="submit">
212
- <span style="font-weight: bold; color: red;">
213
- <a href="<?php echo $notifyUrl; ?>"><?php _e('Click here to create a copy of this page.', DUPLICATE_POST_I18N_DOMAIN); ?></a>
214
- </span>
215
- </p>
216
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
 
218
  }
219
-
220
- /**
221
- * Wrapper for the option 'duplicate_post_view_user_level'
222
- */
223
- function duplicate_post_get_view_user_level() {
224
- return get_option( DUPLICATE_POST_VIEW_USER_LEVEL_OPTION );
225
- }
226
-
227
- /**
228
- * Wrapper for the option 'duplicate_post_view_user_level'
229
- */
230
- function duplicate_post_set_view_user_level($new_level) {
231
- return update_option( DUPLICATE_POST_VIEW_USER_LEVEL_OPTION, $new_level );
232
- }
233
-
234
- /**
235
- * Wrapper for the option 'duplicate_post_create_user_level'
236
- */
237
- function duplicate_post_get_create_user_level() {
238
- return get_option( DUPLICATE_POST_CREATE_USER_LEVEL_OPTION );
239
- }
240
-
241
- /**
242
- * Wrapper for the option 'duplicate_post_create_user_level'
243
- */
244
- function duplicate_post_set_create_user_level($new_level) {
245
- return update_option( DUPLICATE_POST_CREATE_USER_LEVEL_OPTION, $new_level );
246
- }
247
-
248
- /**
249
- * Wrapper for the option 'duplicate_post_admin_user_level'
250
- */
251
- function duplicate_post_get_admin_user_level() {
252
- return get_option( DUPLICATE_POST_ADMIN_USER_LEVEL_OPTION );
253
- }
254
-
255
- /**
256
- * Wrapper for the option 'duplicate_post_admin_user_level'
257
- */
258
- function duplicate_post_set_admin_user_level($new_level) {
259
- return update_option( DUPLICATE_POST_ADMIN_USER_LEVEL_OPTION, $new_level );
260
- }
261
-
262
- /**
263
- * Wrapper for the option 'duplicate_post_version'
264
- */
265
- function duplicate_post_get_installed_version() {
266
- return get_option( 'duplicate_post_version' );
267
- }
268
-
269
- /**
270
- * Wrapper for the defined constant DUPLICATE_POST_CURRENT_VERSION
271
- */
272
- function duplicate_post_get_current_version() {
273
- return DUPLICATE_POST_CURRENT_VERSION;
274
- }
275
-
276
- /**
277
- * Test if the user is allowed to view the templates & create posts
278
- */
279
- function duplicate_post_is_current_user_allowed_to_view() {
280
- return current_user_can("level_" . duplicate_post_get_view_user_level());
281
- }
282
-
283
- /**
284
- * Test if the user is allowed to create templates
285
- */
286
- function duplicate_post_is_current_user_allowed_to_create() {
287
- return current_user_can("level_" . duplicate_post_get_create_user_level());
288
- }
289
-
290
- /**
291
- * Test if the user is allowed to administrate the plugin
292
- */
293
- function duplicate_post_is_current_user_allowed_to_admin() {
294
- return current_user_can("level_" . duplicate_post_get_admin_user_level());
295
- }
296
-
297
- /**
298
- * Get a level given a role
299
- */
300
- function duplicate_post_get_level_from_role($role) {
301
- switch ($role) {
302
- case 0: // subscribers 0
303
- return 0;
304
- case 1: // contributors 1
305
- return 1;
306
- case 2: // authors 2..4
307
- return 2;
308
- case 3: // editors 5..7
309
- return 5;
310
- case 4: // administrators 8..10
311
- return 8;
312
- default: // error
313
- return 0;
314
- }
315
- }
316
-
317
- /**
318
- * Get a role given a level
319
- */
320
- function duplicate_post_get_role_from_level($level) {
321
- if ($level<=0) {
322
- // subscribers 0
323
- return 0;
324
- } else if ($level==1) {
325
- // contributors 1
326
- return 1;
327
- } else if ($level>=2 && $level<=4) {
328
- // authors 2..4
329
- return 2;
330
- } else if ($level>=5 && $level<=7) {
331
- // editors 5..7
332
- return 3;
333
- } else if ($level>=8) {
334
- // admins 8..10
335
- return 4;
336
- }
337
- return 0;
338
- }
339
-
340
- /**
341
- * Get the currently registered user
342
- */
343
- function duplicate_post_get_current_user() {
344
- if (function_exists('wp_get_current_user')) {
345
- return wp_get_current_user();
346
- } else if (function_exists('get_currentuserinfo')) {
347
- global $userdata;
348
- get_currentuserinfo();
349
- return $userdata;
350
- } else {
351
- $user_login = $_COOKIE[USER_COOKIE];
352
- $current_user = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_login='$user_login'");
353
- return $current_user;
354
- }
355
- }
356
-
357
- /**
358
- * Escape single quotes, specialchar double quotes, and fix line endings.
359
- */
360
- function duplicate_post_js_escape($text) {
361
- if (function_exists('js_escape')) {
362
- return js_escape($text);
363
- } else {
364
- $safe_text = str_replace('&&', '&#038;&', $text);
365
- $safe_text = str_replace('&&', '&#038;&', $safe_text);
366
- $safe_text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&#038;$1', $safe_text);
367
- $safe_text = str_replace('<', '&lt;', $safe_text);
368
- $safe_text = str_replace('>', '&gt;', $safe_text);
369
- $safe_text = str_replace('"', '&quot;', $safe_text);
370
- $safe_text = str_replace('&#039;', "'", $safe_text);
371
- $safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));
372
- return safe_text;
373
- }
374
  }
375
 
376
- /**
377
- * Get a page from the database
378
- */
379
- function duplicate_post_get_page($id) {
380
- global $wpdb;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
382
  if ($post->post_type == "revision"){
383
  $id = $post->post_parent;
384
  $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
385
- }
386
- return $post[0];
387
- }
388
-
389
- /**
390
- * Get a post from the database
391
- */
392
- function duplicate_post_get_post($id) {
393
- global $wpdb;
394
  $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
395
  if ($post->post_type == "revision"){
396
  $id = $post->post_parent;
397
  $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
398
- }
399
- return $post[0];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  }
401
 
402
- /**
403
- * Copy the categories of a post to another post
404
- */
405
- function duplicate_post_copy_post_categories($id, $new_id) {
406
- global $wpdb;
407
- if (isset($wpdb->terms)) {
408
- // WordPress 2.3
409
- $taxonomies = get_object_taxonomies('post'); //array("category", "post_tag");
410
- foreach ($taxonomies as $taxonomy) {
411
- $post_terms = wp_get_object_terms($id, $taxonomy);
412
- for ($i=0; $i<count($post_terms); $i++) {
413
- wp_set_object_terms($new_id, $post_terms[$i]->slug, $taxonomy, true);
414
- }
415
- }
416
- } else {
417
- $post_categories = $wpdb->get_results("SELECT category_id FROM $wpdb->post2cat WHERE post_id=$id");
418
- if (count($post_categories)!=0) {
419
- $sql_query = "INSERT INTO $wpdb->post2cat (post_id, category_id) ";
420
-
421
- for ($i=0; $i<count($post_categories); $i++) {
422
- $post_category = $post_categories[$i]->category_id;
423
-
424
- if ($i<count($post_categories)-1) {
425
- $sql_query .= "SELECT $new_id, $post_category UNION ALL ";
426
- } else {
427
- $sql_query .= "SELECT $new_id, $post_category";
428
- }
429
- }
430
-
431
- $wpdb->query($sql_query);
432
- }
433
- }
434
- }
435
-
436
- /**
437
- * Copy the meta information of a post to another post
438
- */
439
- function duplicate_post_copy_post_meta_info($id, $new_id) {
440
- global $wpdb;
441
- $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$id");
442
-
443
- if (count($post_meta_infos)!=0) {
444
- $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
445
-
446
- for ($i=0; $i<count($post_meta_infos); $i++) {
447
- $meta_info = $post_meta_infos[$i];
448
-
449
  $meta_value = addslashes($meta_info->meta_value);
450
 
451
  if ($i<count($post_meta_infos)-1) {
452
  $sql_query .= "SELECT $new_id, '$meta_info->meta_key', '$meta_value' UNION ALL ";
453
  } else {
454
  $sql_query .= "SELECT $new_id, '$meta_info->meta_key', '$meta_value'";
455
- }
456
- }
457
-
458
- $wpdb->query($sql_query);
459
- }
460
  }
461
 
462
- /**
463
- * Create a duplicate from a post
464
- */
465
- function duplicate_post_create_duplicate_from_post($post) {
466
- global $wpdb;
467
- $new_post_type = 'post';
468
- $new_post_author = duplicate_post_get_current_user();
469
- $new_post_date = current_time('mysql');
470
- $new_post_date_gmt = get_gmt_from_date($new_post_date);
471
-
472
- $post_content = str_replace("'", "''", $post->post_content);
473
- $post_content_filtered = str_replace("'", "''", $post->post_content_filtered);
474
- $post_excerpt = str_replace("'", "''", $post->post_excerpt);
475
- $post_title = str_replace("'", "''", $post->post_title);
476
- $post_status = str_replace("'", "''", $post->post_status);
477
- $comment_status = str_replace("'", "''", $post->comment_status);
478
- $ping_status = str_replace("'", "''", $post->ping_status);
479
-
480
- // Insert the new template in the post table
481
- $wpdb->query(
482
- "INSERT INTO $wpdb->posts
483
- (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
484
- VALUES
485
- ('$new_post_author->ID', '$new_post_date', '$new_post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', 'draft', '$new_post_type', '$comment_status', '$ping_status', '$post->post_password', '$post->to_ping', '$post->pinged', '$new_post_date', '$new_post_date_gmt', '$post->post_parent', '$post->menu_order', '$post->post_mime_type')");
486
-
487
- $new_post_id = $wpdb->insert_id;
488
-
489
- // Copy the categories
490
- duplicate_post_copy_post_categories($post->ID, $new_post_id);
491
-
492
- // Copy the meta information
493
- duplicate_post_copy_post_meta_info($post->ID, $new_post_id);
494
-
495
- return $new_post_id;
496
  }
497
 
498
- /**
499
- * Create a duplicate from a page
500
- */
501
- function duplicate_post_create_duplicate_from_page($post) {
502
- global $wpdb;
503
- $new_post_type = 'page';
504
- $new_post_date = current_time('mysql');
505
- $new_post_date_gmt = get_gmt_from_date($new_post_date);
506
-
507
- $post_content = str_replace("'", "''", $post->post_content);
508
- $post_content_filtered = str_replace("'", "''", $post->post_content_filtered);
509
- $post_excerpt = str_replace("'", "''", $post->post_excerpt);
510
- $post_title = str_replace("'", "''", $post->post_title);
511
- $post_status = str_replace("'", "''", $post->post_status);
512
- $post_name = str_replace("'", "''", $post->post_name);
513
- $comment_status = str_replace("'", "''", $post->comment_status);
514
- $ping_status = str_replace("'", "''", $post->ping_status);
515
-
516
- // Insert the new template in the post table
517
- $wpdb->query(
518
- "INSERT INTO $wpdb->posts
519
- (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
520
- VALUES
521
- ('$post->post_author', '$new_post_date', '$new_post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', 'draft', '$new_post_type', '$comment_status', '$ping_status', '$post->post_password', '$post_name', '$post->to_ping', '$post->pinged', '$new_post_date', '$new_post_date_gmt', '$post->post_parent', '$post->menu_order', '$post->post_mime_type')");
522
-
523
- $new_page_id = $wpdb->insert_id;
524
-
525
- // Copy the meta information
526
- duplicate_post_copy_post_meta_info($post->ID, $new_page_id);
527
-
528
- return $new_page_id;
529
- }
530
 
 
 
 
 
 
 
 
 
531
 
 
 
 
 
 
532
  ?>
1
  <?php
2
  /*
3
+ Plugin Name: Duplicate Post
4
+ Plugin URI: http://www.lopo.it/duplicate-post-plugin/
5
+ Description: Creates a copy of a post.
6
+ Version: 1.0
7
+ Author: Enrico Battocchi
8
+ Author URI: http://www.lopo.it
9
+ Text Domain: duplicate-post
10
+ */
11
 
12
+ /* Copyright 2009 Enrico Battocchi (email : enrico.battocchi@gmail.com)
13
 
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 3 of the License, or
17
+ (at your option) any later version.
18
 
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
 
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
29
  // Added by WarmStal
34
  * This function calls the creation of a new copy of the selected post (as a draft)
35
  * then redirects to the edit post screen
36
  */
 
37
  function duplicate_post_save_as_new_post(){
38
  if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'duplicate_post_save_as_new_post' == $_REQUEST['action'] ) ) ) {
39
+ wp_die(__('No post to duplicate has been supplied!', DUPLICATE_POST_I18N_DOMAIN));
40
  }
41
+
42
  // Get the original post
43
+ $id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']);
44
  $post = duplicate_post_get_post($id);
45
+
46
  // Copy the post and insert it
47
  if (isset($post) && $post!=null) {
48
  $new_id = duplicate_post_create_duplicate_from_post($post);
49
+
50
+ // If you have written a plugin which uses non-WP database tables to save
51
+ // information about a post you can hook this action to dupe that data.
52
+ do_action( 'dp_duplicate_post', $new_id, $post );
53
+
54
+ // Redirect to the edit screen for the new draft post
55
+ wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_id ) );
56
  exit;
57
  } else {
58
+ wp_die(__('Post creation failed, could not find original post:', DUPLICATE_POST_I18N_DOMAIN) . ' ' . $id);
59
+ }
60
  }
61
 
 
62
  /*
63
  * Same as above, for pages
64
  */
 
65
  function duplicate_post_save_as_new_page(){
66
  if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'duplicate_post_save_as_new_post' == $_REQUEST['action'] ) ) ) {
67
+ wp_die(__('No page to duplicate has been supplied!', DUPLICATE_POST_I18N_DOMAIN));
68
  }
69
+
70
  // Get the original page
71
+ $id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']);
72
  $post = duplicate_post_get_page($id);
73
+
74
  // Copy the page and insert it
75
  if (isset($post) && $post!=null) {
76
  $new_id = duplicate_post_create_duplicate_from_page($post);
77
+
78
+ // If you have written a plugin which uses non-WP database tables to save
79
+ // information about a page you can hook this action to dupe that data.
80
+ do_action( 'dp_duplicate_page', $new_id, $post );
81
+
82
+ // Redirect to the edit screen for the new draft page
83
+ wp_redirect( admin_url( 'page.php?action=edit&post=' . $new_id ) );
84
  exit;
85
  } else {
86
+ wp_die(__('Post creation failed, could not find original post:', DUPLICATE_POST_I18N_DOMAIN) . ' ' . $id);
87
+ }
88
  }
89
 
90
+ // Version of the plugin
91
+ define('DUPLICATE_POST_CURRENT_VERSION', '1.0' );
92
+ define('DUPLICATE_POST_COLUMN', 'control_duplicate_post');
93
+ define('DUPLICATE_POST_VIEW_USER_LEVEL_OPTION', 'duplicate_post_view_user_level');
94
+ define('DUPLICATE_POST_CREATE_USER_LEVEL_OPTION', 'duplicate_post_create_user_level');
95
+ define('DUPLICATE_POST_ADMIN_USER_LEVEL_OPTION', 'duplicate_post_admin_user_level');
96
 
97
+ // i18n plugin domain
 
 
 
 
 
 
 
98
  define('DUPLICATE_POST_I18N_DOMAIN', 'duplicate-post');
99
 
100
+ /**
101
+ * Initialise the internationalisation domain
102
+ */
103
+ load_plugin_textdomain(DUPLICATE_POST_I18N_DOMAIN,
104
+ 'wp-content/plugins/duplicate-post/languages','duplicate-post/languages');
105
+
106
+ /**
107
+ * Plugin activation
108
+ */
 
 
 
 
 
109
  add_action('activate_duplicate-post/duplicate-post.php','duplicate_post_plugin_activation');
110
 
111
+ function duplicate_post_plugin_activation() {
112
+ $installed_version = duplicate_post_get_installed_version();
113
 
114
+ if ( $installed_version==duplicate_post_get_current_version() ) {
115
+ // do nothing
116
+ } else if ( $installed_version=='' ) {
117
+ // Add all options, nothing already installed
118
+ add_option(
119
+ DUPLICATE_POST_VIEW_USER_LEVEL_OPTION,
120
+ '2',
121
+ 'Default user level to copy posts' );
122
+ add_option(
123
+ DUPLICATE_POST_CREATE_USER_LEVEL_OPTION,
124
+ '5',
125
+ 'Default user level to create the templates' );
126
+ add_option(
127
+ DUPLICATE_POST_ADMIN_USER_LEVEL_OPTION,
128
+ '8',
129
+ 'Default user level to change the plugin options' );
130
+ }
131
+ // Update version number
132
+ update_option( 'duplicate_post_version', duplicate_post_get_current_version() );
 
 
 
 
133
  }
134
 
135
+ /**
136
+ * Check if WP version < 2.8: if so, post_row_actions does not exist, so we must add a custom column (the old way)
137
+ */
138
+ global $wp_version;
139
+ if (strncmp($wp_version, "2.7",3) == 0 ){
140
+ add_filter('manage_posts_columns', 'duplicate_post_add_duplicate_post_column');
141
+ // Added by WarmStal
142
+ add_filter('manage_pages_columns', 'duplicate_post_add_duplicate_post_column');
143
+ add_action('manage_posts_custom_column', 'duplicate_post_make_duplicate_link', 10, 2);
144
+ // Added by WarmStal
145
+ add_action('manage_pages_custom_column', 'duplicate_page_make_duplicate_link', 10, 2);
146
+ } else {
147
+ /**
148
+ * Add to the links shown when the mouse gets over a post title in 'Edit Posts' or 'Edit Pages' screen
149
+ */
150
+ add_filter('post_row_actions', 'duplicate_post_make_duplicate_link_row',10,2);
151
+ add_filter('page_row_actions', 'duplicate_page_make_duplicate_link_row',10,2);
152
+ }
153
 
154
+ /**
155
+ * WP version < 2.8: add a custom column
156
+ */
157
+ function duplicate_post_add_duplicate_post_column($columns) {
158
+ if (duplicate_post_is_current_user_allowed_to_create()) {
159
+ $columns[DUPLICATE_POST_COLUMN] = '';
160
+ }
161
+ return $columns;
162
+ }
163
 
164
+ /**
165
+ * WP version < 2.8: add link to custom column for posts
166
+ */
167
+ function duplicate_post_make_duplicate_link($column_name, $id) {
168
+ if (duplicate_post_is_current_user_allowed_to_create()) {
169
+ if ($column_name == DUPLICATE_POST_COLUMN) {
170
+ echo "<a href='admin.php?action=duplicate_post_save_as_new_post&amp;post=" . $id
171
+ . "' title='" . __("Make a duplicate from this post", DUPLICATE_POST_I18N_DOMAIN)
172
+ . "' class='edit'>" . __("Duplicate", DUPLICATE_POST_I18N_DOMAIN) . "</a>";
173
+ }
174
+ }
 
 
 
 
 
 
 
175
  }
176
 
177
+ /**
178
+ * WP version < 2.8: add link to custom column for pages
179
+ */
180
  // Added by WarmStal
181
  function duplicate_page_make_duplicate_link($column_name, $id) {
182
  if (duplicate_post_is_current_user_allowed_to_create()) {
183
  if ($column_name == DUPLICATE_POST_COLUMN) {
184
  echo "<a href='admin.php?action=duplicate_post_save_as_new_page&amp;post=" . $id
185
+ . "' title='" . __("Make a duplicate from this page", DUPLICATE_POST_I18N_DOMAIN)
186
+ . "' class='edit'>" . __("Duplicate", DUPLICATE_POST_I18N_DOMAIN) . "</a>";
187
  }
188
  }
189
  }
190
 
191
+ /**
192
+ * Connect actions to functions
193
+ */
194
+ add_action('admin_action_duplicate_post_save_as_new_post', 'duplicate_post_save_as_new_post');
195
+ add_action('admin_action_duplicate_post_save_as_new_page', 'duplicate_post_save_as_new_page');
196
 
197
+ /**
198
+ * Add the link to action list for post_row_actions
199
+ */
200
+ function duplicate_post_make_duplicate_link_row($actions, $post) {
201
+ if (duplicate_post_is_current_user_allowed_to_create()) {
202
+ $actions['duplicate'] = '<a href="admin.php?action=duplicate_post_save_as_new_post&amp;post=' . $post->ID . '" title="' . __("Make a duplicate from this post", DUPLICATE_POST_I18N_DOMAIN)
203
+ . '" rel="permalink">' . __("Duplicate", DUPLICATE_POST_I18N_DOMAIN) . '</a>';
204
+ }
205
+ return $actions;
206
+ }
 
 
 
 
 
 
 
 
 
 
207
 
208
  /**
209
+ * Add the link to action list for page_row_actions
210
+ */
211
+ function duplicate_page_make_duplicate_link_row($actions, $page) {
212
+ if (duplicate_post_is_current_user_allowed_to_create()) {
213
+ $actions['duplicate'] = '<a href="admin.php?action=duplicate_post_save_as_new_page&amp;post=' . $page->ID . '" title="' . __("Make a duplicate from this page", DUPLICATE_POST_I18N_DOMAIN)
214
+ . '" rel="permalink">' . __("Duplicate", DUPLICATE_POST_I18N_DOMAIN) . '</a>';
215
+ }
216
+ return $actions;
217
+ }
218
+
219
+ /**
220
+ * Add a button in the post/page edit screen to create a clone
221
+ */
222
+ add_action( 'post_submitbox_start', 'duplicate_post_add_duplicate_post_button' );
223
+
224
+ function duplicate_post_add_duplicate_post_button() {
225
+ if ( isset( $_GET['post'] ) && duplicate_post_is_current_user_allowed_to_create()) {
226
+ $act = "admin.php?action=duplicate_post_save_as_new_post";
227
+ global $post;
228
+ if ($post->post_type == "page") $act = "admin.php?action=duplicate_post_save_as_new_page";
229
+ $notifyUrl = $act."&post=" . $_GET['post'];
230
+ ?>
231
+ <div id="duplicate-action"><a class="submitduplicate duplication"
232
+ href="<?php echo $notifyUrl; ?>"><?php _e('Copy to a new draft', DUPLICATE_POST_I18N_DOMAIN); ?></a>
233
+ </div>
234
+ <?php
235
+ }
236
+ }
237
+
238
+ /**
239
+ * Wrapper for the option 'duplicate_post_view_user_level'
240
+ */
241
+ function duplicate_post_get_view_user_level() {
242
+ return get_option( DUPLICATE_POST_VIEW_USER_LEVEL_OPTION );
243
+ }
244
+
245
+ /**
246
+ * Wrapper for the option 'duplicate_post_view_user_level'
247
+ */
248
+ function duplicate_post_set_view_user_level($new_level) {
249
+ return update_option( DUPLICATE_POST_VIEW_USER_LEVEL_OPTION, $new_level );
250
+ }
251
+
252
+ /**
253
+ * Wrapper for the option 'duplicate_post_create_user_level'
254
+ */
255
+ function duplicate_post_get_create_user_level() {
256
+ return get_option( DUPLICATE_POST_CREATE_USER_LEVEL_OPTION );
257
+ }
258
+
259
+ /**
260
+ * Wrapper for the option 'duplicate_post_create_user_level'
261
+ */
262
+ function duplicate_post_set_create_user_level($new_level) {
263
+ return update_option( DUPLICATE_POST_CREATE_USER_LEVEL_OPTION, $new_level );
264
+ }
265
+
266
+ /**
267
+ * Wrapper for the option 'duplicate_post_admin_user_level'
268
+ */
269
+ function duplicate_post_get_admin_user_level() {
270
+ return get_option( DUPLICATE_POST_ADMIN_USER_LEVEL_OPTION );
271
+ }
272
+
273
+ /**
274
+ * Wrapper for the option 'duplicate_post_admin_user_level'
275
+ */
276
+ function duplicate_post_set_admin_user_level($new_level) {
277
+ return update_option( DUPLICATE_POST_ADMIN_USER_LEVEL_OPTION, $new_level );
278
+ }
279
+
280
+ /**
281
+ * Wrapper for the option 'duplicate_post_version'
282
+ */
283
+ function duplicate_post_get_installed_version() {
284
+ return get_option( 'duplicate_post_version' );
285
+ }
286
+
287
+ /**
288
+ * Wrapper for the defined constant DUPLICATE_POST_CURRENT_VERSION
289
+ */
290
+ function duplicate_post_get_current_version() {
291
+ return DUPLICATE_POST_CURRENT_VERSION;
292
+ }
293
+
294
+ /**
295
+ * Test if the user is allowed to view the templates & create posts
296
+ */
297
+ function duplicate_post_is_current_user_allowed_to_view() {
298
+ return current_user_can("level_" . duplicate_post_get_view_user_level());
299
+ }
300
+
301
+ /**
302
+ * Test if the user is allowed to create templates
303
+ */
304
+ function duplicate_post_is_current_user_allowed_to_create() {
305
+ return current_user_can("level_" . duplicate_post_get_create_user_level());
306
+ }
307
+
308
+ /**
309
+ * Test if the user is allowed to administrate the plugin
310
+ */
311
+ function duplicate_post_is_current_user_allowed_to_admin() {
312
+ return current_user_can("level_" . duplicate_post_get_admin_user_level());
313
+ }
314
+
315
+ /**
316
+ * Get a level given a role
317
+ */
318
+ function duplicate_post_get_level_from_role($role) {
319
+ switch ($role) {
320
+ case 0: // subscribers 0
321
+ return 0;
322
+ case 1: // contributors 1
323
+ return 1;
324
+ case 2: // authors 2..4
325
+ return 2;
326
+ case 3: // editors 5..7
327
+ return 5;
328
+ case 4: // administrators 8..10
329
+ return 8;
330
+ default: // error
331
+ return 0;
332
+ }
333
+ }
334
+
335
+ /**
336
+ * Get a role given a level
337
+ */
338
+ function duplicate_post_get_role_from_level($level) {
339
+ if ($level<=0) {
340
+ // subscribers 0
341
+ return 0;
342
+ } else if ($level==1) {
343
+ // contributors 1
344
+ return 1;
345
+ } else if ($level>=2 && $level<=4) {
346
+ // authors 2..4
347
+ return 2;
348
+ } else if ($level>=5 && $level<=7) {
349
+ // editors 5..7
350
+ return 3;
351
+ } else if ($level>=8) {
352
+ // admins 8..10
353
+ return 4;
354
  }
355
+ return 0;
356
  }
357
+
358
+ /**
359
+ * Get the currently registered user
360
+ */
361
+ function duplicate_post_get_current_user() {
362
+ if (function_exists('wp_get_current_user')) {
363
+ return wp_get_current_user();
364
+ } else if (function_exists('get_currentuserinfo')) {
365
+ global $userdata;
366
+ get_currentuserinfo();
367
+ return $userdata;
368
+ } else {
369
+ $user_login = $_COOKIE[USER_COOKIE];
370
+ $current_user = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_login='$user_login'");
371
+ return $current_user;
372
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  }
374
 
375
+ /**
376
+ * Escape single quotes, specialchar double quotes, and fix line endings.
377
+ */
378
+ function duplicate_post_js_escape($text) {
379
+ if (function_exists('js_escape')) {
380
+ return js_escape($text);
381
+ } else {
382
+ $safe_text = str_replace('&&', '&#038;&', $text);
383
+ $safe_text = str_replace('&&', '&#038;&', $safe_text);
384
+ $safe_text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&#038;$1', $safe_text);
385
+ $safe_text = str_replace('<', '&lt;', $safe_text);
386
+ $safe_text = str_replace('>', '&gt;', $safe_text);
387
+ $safe_text = str_replace('"', '&quot;', $safe_text);
388
+ $safe_text = str_replace('&#039;', "'", $safe_text);
389
+ $safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));
390
+ return safe_text;
391
+ }
392
+ }
393
+
394
+ /**
395
+ * Get a page from the database
396
+ */
397
+ function duplicate_post_get_page($id) {
398
+ global $wpdb;
399
  $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
400
  if ($post->post_type == "revision"){
401
  $id = $post->post_parent;
402
  $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
403
+ }
404
+ return $post[0];
405
+ }
406
+
407
+ /**
408
+ * Get a post from the database
409
+ */
410
+ function duplicate_post_get_post($id) {
411
+ global $wpdb;
412
  $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
413
  if ($post->post_type == "revision"){
414
  $id = $post->post_parent;
415
  $post = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$id");
416
+ }
417
+ return $post[0];
418
+ }
419
+
420
+ /**
421
+ * Copy the categories of a post to another post
422
+ */
423
+ function duplicate_post_copy_post_categories($id, $new_id) {
424
+ global $wpdb;
425
+ if (isset($wpdb->terms)) {
426
+ // WordPress 2.3
427
+ $taxonomies = get_object_taxonomies('post'); //array("category", "post_tag");
428
+ foreach ($taxonomies as $taxonomy) {
429
+ $post_terms = wp_get_object_terms($id, $taxonomy);
430
+ for ($i=0; $i<count($post_terms); $i++) {
431
+ wp_set_object_terms($new_id, $post_terms[$i]->slug, $taxonomy, true);
432
+ }
433
+ }
434
+ } else {
435
+ $post_categories = $wpdb->get_results("SELECT category_id FROM $wpdb->post2cat WHERE post_id=$id");
436
+ if (count($post_categories)!=0) {
437
+ $sql_query = "INSERT INTO $wpdb->post2cat (post_id, category_id) ";
438
+
439
+ for ($i=0; $i<count($post_categories); $i++) {
440
+ $post_category = $post_categories[$i]->category_id;
441
+
442
+ if ($i<count($post_categories)-1) {
443
+ $sql_query .= "SELECT $new_id, $post_category UNION ALL ";
444
+ } else {
445
+ $sql_query .= "SELECT $new_id, $post_category";
446
+ }
447
+ }
448
+
449
+ $wpdb->query($sql_query);
450
+ }
451
+ }
452
  }
453
 
454
+ /**
455
+ * Copy the meta information of a post to another post
456
+ */
457
+ function duplicate_post_copy_post_meta_info($id, $new_id) {
458
+ global $wpdb;
459
+ $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$id");
460
+
461
+ if (count($post_meta_infos)!=0) {
462
+ $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
463
+
464
+ for ($i=0; $i<count($post_meta_infos); $i++) {
465
+ $meta_info = $post_meta_infos[$i];
466
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  $meta_value = addslashes($meta_info->meta_value);
468
 
469
  if ($i<count($post_meta_infos)-1) {
470
  $sql_query .= "SELECT $new_id, '$meta_info->meta_key', '$meta_value' UNION ALL ";
471
  } else {
472
  $sql_query .= "SELECT $new_id, '$meta_info->meta_key', '$meta_value'";
473
+ }
474
+ }
475
+
476
+ $wpdb->query($sql_query);
477
+ }
478
  }
479
 
480
+ /**
481
+ * Create a duplicate from a post
482
+ */
483
+ function duplicate_post_create_duplicate_from_post($post) {
484
+ global $wpdb;
485
+ $new_post_type = 'post';
486
+ $new_post_author = duplicate_post_get_current_user();
487
+ $new_post_date = current_time('mysql');
488
+ $new_post_date_gmt = get_gmt_from_date($new_post_date);
489
+
490
+ $post_content = str_replace("'", "''", $post->post_content);
491
+ $post_content_filtered = str_replace("'", "''", $post->post_content_filtered);
492
+ $post_excerpt = str_replace("'", "''", $post->post_excerpt);
493
+ $post_title = str_replace("'", "''", $post->post_title);
494
+ $post_status = str_replace("'", "''", $post->post_status);
495
+ $comment_status = str_replace("'", "''", $post->comment_status);
496
+ $ping_status = str_replace("'", "''", $post->ping_status);
497
+
498
+ // Insert the new template in the post table
499
+ $wpdb->query(
500
+ "INSERT INTO $wpdb->posts
501
+ (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
502
+ VALUES
503
+ ('$new_post_author->ID', '$new_post_date', '$new_post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', 'draft', '$new_post_type', '$comment_status', '$ping_status', '$post->post_password', '$post->to_ping', '$post->pinged', '$new_post_date', '$new_post_date_gmt', '$post->post_parent', '$post->menu_order', '$post->post_mime_type')");
504
+
505
+ $new_post_id = $wpdb->insert_id;
506
+
507
+ // Copy the categories
508
+ duplicate_post_copy_post_categories($post->ID, $new_post_id);
509
+
510
+ // Copy the meta information
511
+ duplicate_post_copy_post_meta_info($post->ID, $new_post_id);
512
+
513
+ return $new_post_id;
514
  }
515
 
516
+ /**
517
+ * Create a duplicate from a page
518
+ */
519
+ function duplicate_post_create_duplicate_from_page($post) {
520
+ global $wpdb;
521
+ $new_post_type = 'page';
522
+ $new_post_date = current_time('mysql');
523
+ $new_post_date_gmt = get_gmt_from_date($new_post_date);
524
+
525
+ $post_content = str_replace("'", "''", $post->post_content);
526
+ $post_content_filtered = str_replace("'", "''", $post->post_content_filtered);
527
+ $post_excerpt = str_replace("'", "''", $post->post_excerpt);
528
+ $post_title = str_replace("'", "''", $post->post_title);
529
+ $post_status = str_replace("'", "''", $post->post_status);
530
+ $post_name = str_replace("'", "''", $post->post_name);
531
+ $comment_status = str_replace("'", "''", $post->comment_status);
532
+ $ping_status = str_replace("'", "''", $post->ping_status);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
533
 
534
+ // Insert the new template in the post table
535
+ $wpdb->query(
536
+ "INSERT INTO $wpdb->posts
537
+ (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
538
+ VALUES
539
+ ('$post->post_author', '$new_post_date', '$new_post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', 'draft', '$new_post_type', '$comment_status', '$ping_status', '$post->post_password', '$post_name', '$post->to_ping', '$post->pinged', '$new_post_date', '$new_post_date_gmt', '$post->post_parent', '$post->menu_order', '$post->post_mime_type')");
540
+
541
+ $new_page_id = $wpdb->insert_id;
542
 
543
+ // Copy the meta information
544
+ duplicate_post_copy_post_meta_info($post->ID, $new_page_id);
545
+
546
+ return $new_page_id;
547
+ }
548
  ?>
languages/duplicate-post-es.mo ADDED
Binary file
languages/duplicate-post-es.po ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Duplicate Post plugin for WordPress
2
+ # Copyright (C) 2009 Enrico Battocchi
3
+ # This file is distributed under the same license as the Duplicate Post package.
4
+ # Enrico Battocchi <enrico.battocchi@gmail.com>, 2009.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: Duplicate Post 1.0\n"
9
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/duplicate-post\n"
10
+ "POT-Creation-Date: 2009-12-02 23:12+0000\n"
11
+ "PO-Revision-Date: 2009-12-10 01:14+0100\n"
12
+ "Last-Translator: Enrico Battocchi <enrico.battocchi@gmail.com>\n"
13
+ "Language-Team: Enrico Battocchi <enrico.battocchi@gmail.com>\n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=utf-8\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+ "X-Poedit-Language: Spanish\n"
18
+
19
+ #: duplicate-post.php:39
20
+ msgid "No post to duplicate has been supplied!"
21
+ msgstr "No se facilitó ninguna entrada a copiar"
22
+
23
+ #: duplicate-post.php:58 duplicate-post.php:86
24
+ msgid "Post creation failed, could not find original post:"
25
+ msgstr "Creación realizada sin éxito, no ha sido posible encontrar la entrada original:"
26
+
27
+ #: duplicate-post.php:67
28
+ msgid "No page to duplicate has been supplied!"
29
+ msgstr "No se facilitó ninguna página a copiar"
30
+
31
+ #: duplicate-post.php:171
32
+ msgid "Make a duplicate from this post"
33
+ msgstr "Crea una copia de esta entrada"
34
+
35
+ #: duplicate-post.php:172 duplicate-post.php:186 duplicate-post.php:203
36
+ #: duplicate-post.php:214
37
+ msgid "Duplicate"
38
+ msgstr "Copiar"
39
+
40
+ #: duplicate-post.php:185
41
+ msgid "Make a duplicate from this page"
42
+ msgstr "Crea una copia de esta página"
43
+
44
+ #: duplicate-post.php:232
45
+ msgid "Copy to a new draft"
46
+ msgstr "Copia en un borrador nuevo"
47
+
48
+ #. Plugin Name of an extension
49
+ msgid "Duplicate Post"
50
+ msgstr "Duplicate Post"
51
+
52
+ #. Plugin URI of an extension
53
+ msgid "http://wordpress.org/extend/plugins/duplicate-post/"
54
+ msgstr "http://wordpress.org/extend/plugins/duplicate-post/"
55
+
56
+ #. Description of an extension
57
+ msgid "Creates a copy of a post."
58
+ msgstr "Para copiar las entradas."
59
+
60
+ #. Author of an extension
61
+ msgid "Enrico Battocchi"
62
+ msgstr "Enrico Battocchi"
63
+
64
+ #. Author URI of an extension
65
+ msgid "http://www.lopo.it"
66
+ msgstr "http://www.lopo.it"
67
+
languages/duplicate-post-fr_FR.mo ADDED
Binary file
languages/duplicate-post-fr_FR.po ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Duplicate Post plugin for WordPress
2
+ # Copyright (C) 2009 Enrico Battocchi
3
+ # This file is distributed under the same license as the Duplicate Post package.
4
+ # Enrico Battocchi <enrico.battocchi@gmail.com>, 2009.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: Duplicate Post 1.0\n"
9
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/duplicate-post\n"
10
+ "POT-Creation-Date: 2009-12-02 23:12+0000\n"
11
+ "PO-Revision-Date: 2009-12-03 15:30+0100\n"
12
+ "Last-Translator: Enrico Battocchi <enrico.battocchi@gmail.com>\n"
13
+ "Language-Team: Enrico Battocchi <enrico.battocchi@gmail.com>\n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=utf-8\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+ "X-Poedit-Language: French\n"
18
+ "X-Poedit-Country: FRANCE\n"
19
+
20
+ #: duplicate-post.php:39
21
+ msgid "No post to duplicate has been supplied!"
22
+ msgstr "Aucun article à copier!"
23
+
24
+ #: duplicate-post.php:58 duplicate-post.php:86
25
+ msgid "Post creation failed, could not find original post:"
26
+ msgstr "La création de l&rsquo;article a échoué, il n&rsquo;était pas possible de trouver l&rsquo;article original"
27
+
28
+ #: duplicate-post.php:67
29
+ msgid "No page to duplicate has been supplied!"
30
+ msgstr "Aucune page à copier!"
31
+
32
+ #: duplicate-post.php:171
33
+ msgid "Make a duplicate from this post"
34
+ msgstr "Copier cet article"
35
+
36
+ #: duplicate-post.php:172 duplicate-post.php:186 duplicate-post.php:203
37
+ #: duplicate-post.php:214
38
+ msgid "Duplicate"
39
+ msgstr "Copier"
40
+
41
+ #: duplicate-post.php:185
42
+ msgid "Make a duplicate from this page"
43
+ msgstr "Copier cette page"
44
+
45
+ #: duplicate-post.php:232
46
+ msgid "Copy to a new draft"
47
+ msgstr "Copier dans un nouveau brouillon"
48
+
49
+ #. Plugin Name of an extension
50
+ msgid "Duplicate Post"
51
+ msgstr "Duplicate Post"
52
+
53
+ #. Plugin URI of an extension
54
+ msgid "http://wordpress.org/extend/plugins/duplicate-post/"
55
+ msgstr "http://wordpress.org/extend/plugins/duplicate-post/"
56
+
57
+ #. Description of an extension
58
+ msgid "Creates a copy of a post."
59
+ msgstr "Pour copier les articles."
60
+
61
+ #. Author of an extension
62
+ msgid "Enrico Battocchi"
63
+ msgstr "Enrico Battocchi"
64
+
65
+ #. Author URI of an extension
66
+ msgid "http://www.lopo.it"
67
+ msgstr "http://www.lopo.it"
68
+
languages/duplicate-post-it.mo DELETED
Binary file
languages/duplicate-post-it.po DELETED
@@ -1,61 +0,0 @@
1
- # Italian Language File for Duplicate Post
2
- # (it.po)
3
- # This file is distributed under the same license as the Duplicate Post package.
4
- #
5
- msgid ""
6
- msgstr ""
7
- "Project-Id-Version: Duplicate Post 0.6\n"
8
- "Report-Msgid-Bugs-To: \n"
9
- "POT-Creation-Date: 2009-07-21 14:49+0100\n"
10
- "PO-Revision-Date: 2009-07-21 14:49+0100\n"
11
- "Last-Translator: Enrico Battocchi <enrico.battocchi@gmail.com>\n"
12
- "Language-Team: \n"
13
- "MIME-Version: 1.0\n"
14
- "Content-Type: text/plain; charset=UTF-8\n"
15
- "Content-Transfer-Encoding: 8bit\n"
16
- "X-Poedit-Language: Italian\n"
17
- "X-Poedit-Country: ITALY\n"
18
- "X-Poedit-SourceCharset: utf-8\n"
19
- "X-Poedit-KeywordsList: _e;__\n"
20
- "X-Poedit-Basepath: ../\n"
21
- "X-Poedit-SearchPath-0: .\n"
22
-
23
- #: save_as_new_page.php:5
24
- #: duplicate-post.php:66
25
- msgid "No page to duplicate has been supplied!"
26
- msgstr "Non è stato indicata alcuna pagina da copiare!"
27
-
28
- #: save_as_new_page.php:23
29
- #: duplicate-post.php:55
30
- #: duplicate-post.php:81
31
- msgid "Post creation failed, could not find original post:"
32
- msgstr "Creazione articolo fallita, non è stato possibile trovare l'articolo originale:"
33
-
34
- #: duplicate-post.php:40
35
- msgid "No post to duplicate has been supplied!"
36
- msgstr "Non è stato indicato alcun articolo da copiare!"
37
-
38
- #: duplicate-post.php:163
39
- msgid "Make a duplicate from this post"
40
- msgstr "Crea una copia di questo articolo"
41
-
42
- #: duplicate-post.php:164
43
- #: duplicate-post.php:175
44
- msgid "Duplicate"
45
- msgstr "Copia"
46
-
47
- #: duplicate-post.php:174
48
- msgid "Make a duplicate from this page"
49
- msgstr "Crea una copia di questa pagina"
50
-
51
- #: duplicate-post.php:195
52
- msgid "Click here to create a copy of this post."
53
- msgstr "Clicca qui per creare una copia di questo articolo"
54
-
55
- #: duplicate-post.php:213
56
- msgid "Click here to create a copy of this page."
57
- msgstr "Clicca qui per creare una copia di questa pagina"
58
-
59
- #~ msgid "Make Copy"
60
- #~ msgstr "Crea una copia"
61
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/duplicate-post-it_IT.mo ADDED
Binary file
languages/duplicate-post-it_IT.po ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Duplicate Post plugin for WordPress
2
+ # Copyright (C) 2009 Enrico Battocchi
3
+ # This file is distributed under the same license as the Duplicate Post package.
4
+ # Enrico Battocchi <enrico.battocchi@gmail.com>, 2009.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: Duplicate Post 1.0\n"
9
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/duplicate-post\n"
10
+ "POT-Creation-Date: 2009-12-02 23:12+0000\n"
11
+ "PO-Revision-Date: 2009-12-03 15:30+0100\n"
12
+ "Last-Translator: Enrico Battocchi <enrico.battocchi@gmail.com>\n"
13
+ "Language-Team: Enrico Battocchi <enrico.battocchi@gmail.com>\n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=utf-8\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+ "X-Poedit-Language: Italian\n"
18
+ "X-Poedit-Country: ITALY\n"
19
+
20
+ #: duplicate-post.php:39
21
+ msgid "No post to duplicate has been supplied!"
22
+ msgstr "Non è stato fornito alcun articolo da copiare!"
23
+
24
+ #: duplicate-post.php:58 duplicate-post.php:86
25
+ msgid "Post creation failed, could not find original post:"
26
+ msgstr "Creazione dell'articolo fallita, non è stato possibile trovare l'articolo originale:"
27
+
28
+ #: duplicate-post.php:67
29
+ msgid "No page to duplicate has been supplied!"
30
+ msgstr "Non è stata fornita alcuna pagina da copiare!"
31
+
32
+ #: duplicate-post.php:171
33
+ msgid "Make a duplicate from this post"
34
+ msgstr "Crea una copia di questo articolo"
35
+
36
+ #: duplicate-post.php:172 duplicate-post.php:186 duplicate-post.php:203
37
+ #: duplicate-post.php:214
38
+ msgid "Duplicate"
39
+ msgstr "Duplica"
40
+
41
+ #: duplicate-post.php:185
42
+ msgid "Make a duplicate from this page"
43
+ msgstr "Crea una copia di questa pagina"
44
+
45
+ #: duplicate-post.php:232
46
+ msgid "Copy to a new draft"
47
+ msgstr "Copia in una nuova bozza"
48
+
49
+ #. Plugin Name of an extension
50
+ msgid "Duplicate Post"
51
+ msgstr "Duplicate Post"
52
+
53
+ #. Plugin URI of an extension
54
+ msgid "http://wordpress.org/extend/plugins/duplicate-post/"
55
+ msgstr "http://wordpress.org/extend/plugins/duplicate-post/"
56
+
57
+ #. Description of an extension
58
+ msgid "Creates a copy of a post."
59
+ msgstr "Crea una copia di un articolo."
60
+
61
+ #. Author of an extension
62
+ msgid "Enrico Battocchi"
63
+ msgstr "Enrico Battocchi"
64
+
65
+ #. Author URI of an extension
66
+ msgid "http://www.lopo.it"
67
+ msgstr "http://www.lopo.it"
68
+
languages/duplicate-post-ja.mo CHANGED
Binary file
languages/duplicate-post-ja.po CHANGED
@@ -4,11 +4,11 @@
4
  #
5
  msgid ""
6
  msgstr ""
7
- "Project-Id-Version: Duplicate Post 0.6\n"
8
- "Report-Msgid-Bugs-To: \n"
9
- "POT-Creation-Date: 2009-07-21 14:49+0100\n"
10
- "PO-Revision-Date: 2009-07-21 14:49+0100\n"
11
- "Last-Translator: Enrico Battocchi <enrico.battocchi@gmail.com>\n"
12
  "Language-Team: WordPress J-Series Project <http://wppluginsj.sourceforge.jp/i18n-ja_jp/>\n"
13
  "MIME-Version: 1.0\n"
14
  "Content-Type: text/plain; charset=UTF-8\n"
@@ -16,48 +16,64 @@ msgstr ""
16
  "X-Poedit-Language: Japanese\n"
17
  "X-Poedit-Country: JAPAN\n"
18
  "X-Poedit-SourceCharset: utf-8\n"
19
- "X-Poedit-KeywordsList: _e;__\n"
20
  "X-Poedit-Basepath: ../\n"
 
21
  "X-Poedit-SearchPath-0: .\n"
22
 
23
- #: save_as_new_page.php:5
24
- #: duplicate-post.php:66
25
- msgid "No page to duplicate has been supplied!"
26
- msgstr "複製元のページが指定されていません !"
27
 
28
- #: save_as_new_page.php:23
29
- #: duplicate-post.php:55
30
- #: duplicate-post.php:81
31
  msgid "Post creation failed, could not find original post:"
32
  msgstr "複製の作成に失敗しました。複製元の投稿が見つかりません:"
33
 
34
- #: duplicate-post.php:40
35
- msgid "No post to duplicate has been supplied!"
36
- msgstr "複製元の投稿が指定されていません !"
37
 
38
- #: duplicate-post.php:163
39
  msgid "Make a duplicate from this post"
40
  msgstr "この投稿を元に複製を作成"
41
 
42
- #: duplicate-post.php:164
43
- #: duplicate-post.php:175
44
  msgid "Duplicate"
45
  msgstr "複製"
46
 
47
- #: duplicate-post.php:174
48
  msgid "Make a duplicate from this page"
49
  msgstr "この投稿を元に複製を作成"
50
 
51
- #: duplicate-post.php:195
52
- msgid "Click here to create a copy of this post."
53
- msgstr "クリックしてこの投稿の複製を作成"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
- #: duplicate-post.php:213
56
- msgid "Click here to create a copy of this page."
57
- msgstr "クリックしてこのページの複製を作成"
58
 
59
  #~ msgid "Make Copy"
60
  #~ msgstr "複製を作成"
 
 
61
  #~ msgid ""
62
  #~ "<strong>ALERT: You are logged out!</strong> Could not save draft. <a href="
63
  #~ "\"%s\" target=\"blank\">Please log in again.</a>"
@@ -2488,8 +2504,6 @@ msgstr "クリックしてこのページの複製を作成"
2488
  #~ msgstr "クイック投稿"
2489
  #~ msgid "Recent Drafts"
2490
  #~ msgstr "最近の下書き"
2491
- #~ msgid "http://wordpress.org/development/"
2492
- #~ msgstr "http://ja.wordpress.org/"
2493
  #~ msgid "http://wordpress.org/development/feed/"
2494
  #~ msgstr "http://ja.wordpress.org/feed/"
2495
  #~ msgid "WordPress Development Blog"
@@ -6470,8 +6484,6 @@ msgstr "クリックしてこのページの複製を作成"
6470
  #~ msgstr "行を下に貼り付け"
6471
  #~ msgid "Cut table row"
6472
  #~ msgstr "行の切り取り"
6473
- #~ msgid "Copy table row"
6474
- #~ msgstr "行のコピー"
6475
  #~ msgid "Delete table"
6476
  #~ msgstr "表を削除"
6477
  #~ msgid "Row"
4
  #
5
  msgid ""
6
  msgstr ""
7
+ "Project-Id-Version: Duplicate Post 0.6.1\n"
8
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/duplicate-post\n"
9
+ "POT-Creation-Date: 2009-12-02 23:12+0000\n"
10
+ "PO-Revision-Date: 2009-12-03 15:34+0100\n"
11
+ "Last-Translator: Naoko McCracken <info@nao-net.com>\n"
12
  "Language-Team: WordPress J-Series Project <http://wppluginsj.sourceforge.jp/i18n-ja_jp/>\n"
13
  "MIME-Version: 1.0\n"
14
  "Content-Type: text/plain; charset=UTF-8\n"
16
  "X-Poedit-Language: Japanese\n"
17
  "X-Poedit-Country: JAPAN\n"
18
  "X-Poedit-SourceCharset: utf-8\n"
19
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_c\n"
20
  "X-Poedit-Basepath: ../\n"
21
+ "Plural-Forms: nplurals=1; plural=0;\n"
22
  "X-Poedit-SearchPath-0: .\n"
23
 
24
+ #: duplicate-post.php:39
25
+ msgid "No post to duplicate has been supplied!"
26
+ msgstr "複製元の投稿が指定されていません !"
 
27
 
28
+ #: duplicate-post.php:58 duplicate-post.php:86
 
 
29
  msgid "Post creation failed, could not find original post:"
30
  msgstr "複製の作成に失敗しました。複製元の投稿が見つかりません:"
31
 
32
+ #: duplicate-post.php:67
33
+ msgid "No page to duplicate has been supplied!"
34
+ msgstr "複製元のページが指定されていません !"
35
 
36
+ #: duplicate-post.php:1171
37
  msgid "Make a duplicate from this post"
38
  msgstr "この投稿を元に複製を作成"
39
 
40
+ #: duplicate-post.php:172 duplicate-post.php:186 duplicate-post.php:203
41
+ #: duplicate-post.php:214
42
  msgid "Duplicate"
43
  msgstr "複製"
44
 
45
+ #: duplicate-post.php:185
46
  msgid "Make a duplicate from this page"
47
  msgstr "この投稿を元に複製を作成"
48
 
49
+ #: duplicate-post.php:232
50
+ msgid "Copy to a new draft"
51
+ msgstr "新規下書きとしてコピー"
52
+
53
+ #. Plugin Name of an extension
54
+ msgid "Duplicate Post"
55
+ msgstr "Duplicate Post"
56
+
57
+ #. Plugin URI of an extension
58
+ msgid "http://wordpress.org/extend/plugins/duplicate-post/"
59
+ msgstr "http://wordpress.org/extend/plugins/duplicate-post/"
60
+
61
+ #. Description of an extension
62
+ msgid "Creates a copy of a post."
63
+ msgstr "投稿の複製を作成します。"
64
+
65
+ #. Author of an extension
66
+ msgid "Enrico Battocchi"
67
+ msgstr "Enrico Battocchi"
68
 
69
+ #. Author URI of an extension
70
+ msgid "http://www.lopo.it"
71
+ msgstr "http://www.lopo.it"
72
 
73
  #~ msgid "Make Copy"
74
  #~ msgstr "複製を作成"
75
+ #~ msgid "Click here to create a copy of this page."
76
+ #~ msgstr "クリックしてこのページの複製を作成"
77
  #~ msgid ""
78
  #~ "<strong>ALERT: You are logged out!</strong> Could not save draft. <a href="
79
  #~ "\"%s\" target=\"blank\">Please log in again.</a>"
2504
  #~ msgstr "クイック投稿"
2505
  #~ msgid "Recent Drafts"
2506
  #~ msgstr "最近の下書き"
 
 
2507
  #~ msgid "http://wordpress.org/development/feed/"
2508
  #~ msgstr "http://ja.wordpress.org/feed/"
2509
  #~ msgid "WordPress Development Blog"
6484
  #~ msgstr "行を下に貼り付け"
6485
  #~ msgid "Cut table row"
6486
  #~ msgstr "行の切り取り"
 
 
6487
  #~ msgid "Delete table"
6488
  #~ msgstr "表を削除"
6489
  #~ msgid "Row"
languages/duplicate-post.pot CHANGED
@@ -1,55 +1,66 @@
 
 
 
 
 
 
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Duplicate Post 0.6\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2009-06-29 12:58-0500\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: \n"
8
- "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-SourceCharset: utf-8\n"
13
- "X-Poedit-KeywordsList: _e;__\n"
14
- "X-Poedit-Basepath: ../\n"
15
- "X-Poedit-SearchPath-0: .\n"
16
 
17
- #: duplicate-post.php:163
18
- msgid "Make a duplicate from this post"
19
  msgstr ""
20
 
21
- #: duplicate-post.php:174
22
- msgid "Make a duplicate from this page"
23
  msgstr ""
24
 
25
- #: duplicate-post.php:164
26
- #: duplicate-post.php:175
 
 
 
 
 
 
 
 
27
  msgid "Duplicate"
28
  msgstr ""
29
 
30
- #: duplicate-post.php:195
31
- msgid "Click here to create a copy of this post."
32
  msgstr ""
33
 
34
- #: duplicate-post.php:134
35
- #: duplicate-post.php:165
36
- msgid "Make Copy"
37
  msgstr ""
38
 
39
- #: duplicate-post.php:213
40
- msgid "Click here to create a copy of this page."
41
  msgstr ""
42
 
43
- #: duplicate-post.php:40
44
- msgid "No post to duplicate has been supplied!"
45
  msgstr ""
46
 
47
- #: duplicate-post.php:55
48
- #: duplicate-post.php:81
49
- msgid "Post creation failed, could not find original post:"
50
  msgstr ""
51
 
52
- #: duplicate-post.php:66
53
- msgid "No page to duplicate has been supplied!"
54
  msgstr ""
55
 
 
 
 
1
+ # Duplicate Post plugin for WordPress
2
+ # Copyright (C) 2009 Enrico Battocchi
3
+ # This file is distributed under the same license as the Duplicate Post package.
4
+ # Enrico Battocchi <enrico.battocchi@gmail.com>, 2009.
5
+ #
6
+ #, fuzzy
7
  msgid ""
8
  msgstr ""
9
+ "Project-Id-Version: Duplicate Post 1.0\n"
10
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/duplicate-post\n"
11
+ "POT-Creation-Date: 2009-12-03 14:26+0000\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
  "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=CHARSET\n"
17
  "Content-Transfer-Encoding: 8bit\n"
 
 
 
 
18
 
19
+ #: duplicate-post.php:39
20
+ msgid "No post to duplicate has been supplied!"
21
  msgstr ""
22
 
23
+ #: duplicate-post.php:58 duplicate-post.php:86
24
+ msgid "Post creation failed, could not find original post:"
25
  msgstr ""
26
 
27
+ #: duplicate-post.php:67
28
+ msgid "No page to duplicate has been supplied!"
29
+ msgstr ""
30
+
31
+ #: duplicate-post.php:171
32
+ msgid "Make a duplicate from this post"
33
+ msgstr ""
34
+
35
+ #: duplicate-post.php:172 duplicate-post.php:186 duplicate-post.php:203
36
+ #: duplicate-post.php:214
37
  msgid "Duplicate"
38
  msgstr ""
39
 
40
+ #: duplicate-post.php:185
41
+ msgid "Make a duplicate from this page"
42
  msgstr ""
43
 
44
+ #: duplicate-post.php:232
45
+ msgid "Copy to a new draft"
 
46
  msgstr ""
47
 
48
+ #. Plugin Name of an extension
49
+ msgid "Duplicate Post"
50
  msgstr ""
51
 
52
+ #. Plugin URI of an extension
53
+ msgid "http://wordpress.org/extend/plugins/duplicate-post/"
54
  msgstr ""
55
 
56
+ #. Description of an extension
57
+ msgid "Creates a copy of a post."
 
58
  msgstr ""
59
 
60
+ #. Author of an extension
61
+ msgid "Enrico Battocchi"
62
  msgstr ""
63
 
64
+ #. Author URI of an extension
65
+ msgid "http://www.lopo.it"
66
+ msgstr ""
readme.txt CHANGED
@@ -1,31 +1,37 @@
1
  === Duplicate Post ===
2
  Contributors: lopo
3
  Donate link: http://www.lopo.it/duplicate-post-plugin/
4
- Tags: duplicate, post
5
- Requires at least: 2.6.5
6
  Tested up to: 2.9
7
- Stable tag: 0.6.1
8
 
9
- Create a copy of a post.
10
 
11
  == Description ==
12
 
13
- Allows to create a draft copy of a current post in two ways:
14
- 1. In 'Manage Posts', you can click on 'Duplicate' link;
15
- 2. While editing a post, you can click on 'Click here to create a copy of this post' at the bottom of the editing page.
16
 
17
- Both ways lead to the edit page of the new draft: change what you want, click on 'Publish' and you're done.
18
 
19
- If you want to clone a page, you can use the first method abov.
 
 
 
 
20
 
21
  Credit must be given to the (great) [Post Template](http://post-templates.vincentprat.info) plugin by Vincent Prat: I made this by hacking his work to get something more focused to a sporadic use, without the need to create and manage templates just to make simple copies of some posts every now and then. If my plugin doesn't fits your needs (and even if it does) check Vincent's.
22
 
23
- Thank you to all the suggestions and bug reports, mainly:
24
- - Franz, for giving me some hints on where to search to fix the bug with WP 2.8.1;
25
- - Ben ter Stal, for WPMU compatibility and some fixes;
26
- - Naoko McCracken, for helping me with i18n (now the plugin ships Japanese and Italian language files - I haven't actually tested them yet because I've been rushing to fix the above bug)
 
 
27
 
28
- An example of use: I started this for a small movie theater website which I'm building. Every friday there's a new movie showing with a new timetable, and thus a new post: but sometimes a movie stays for more than a week, so I need to copy the last post and change only the dates, leaving movie title, director's and actors' names etc. unchanged.
29
  The website is http://www.kino-desse.org and the cinema is located in Livorno, Italy.
30
 
31
  == Installation ==
@@ -33,3 +39,50 @@ The website is http://www.kino-desse.org and the cinema is located in Livorno, I
33
  1. Upload `duplicate-post` directory to the `/wp-content/plugins/` directory
34
  2. Activate the plugin through the 'Plugins' menu in WordPress
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  === Duplicate Post ===
2
  Contributors: lopo
3
  Donate link: http://www.lopo.it/duplicate-post-plugin/
4
+ Tags: duplicate, post, copy
5
+ Requires at least: 2.7
6
  Tested up to: 2.9
7
+ Stable tag: 1.0
8
 
9
+ Creates a copy of a post.
10
 
11
  == Description ==
12
 
13
+ Allows to create a draft copy of a post (or page) in two ways:
14
+ 1. In 'Edit Posts'/'Edit Pages', you can click on 'Duplicate' link;
15
+ 2. While editing a post/page, you can click on 'Copy to a new draft' above "Cancel"/"Move to trash".
16
 
17
+ Both ways lead to the edit page for the new draft: change what you want, click on 'Publish' and you're done.
18
 
19
+ Duplicate post is natively in English, but it is shipped with some other language files. Now there is a [Launchpad translation project](https://translations.launchpad.net/duplicate-post/) available to help translating this plugin: feel free to contribute (you can also send me an e-mail using the form on my website).
20
+
21
+ If you're a plugin developer, I suggest to read the section made just for you under "Other Notes", to ensure compatibility between your plugin(s) and mine!
22
+
23
+ This plugin used to be tested on at least WP 2.6.5. From version 1.0 onwards, it uses some APIs first introduced with WP 2.7 to achieve better integration with the new WordPress interface.
24
 
25
  Credit must be given to the (great) [Post Template](http://post-templates.vincentprat.info) plugin by Vincent Prat: I made this by hacking his work to get something more focused to a sporadic use, without the need to create and manage templates just to make simple copies of some posts every now and then. If my plugin doesn't fits your needs (and even if it does) check Vincent's.
26
 
27
+ Thanks for all the suggestions and bug reports, mainly:
28
+
29
+ * Franz, for giving me some hints on where to search to fix the bug with WP 2.8.1;
30
+ * Ben ter Stal, for WPMU compatibility and some fixes;
31
+ * [Naoko McCracken](http://blog.detlog.org), for helping me with i18n and for the Japanese language files
32
+ * [Simon Wheatley](http://www.simonwheatley.co.uk/), for his suggestions, especially about adding actions for other developers to use.
33
 
34
+ An example of use: I started this for a small movie theater website which I'm building. Every Friday there's a new movie showing with a new timetable, and thus a new post: but sometimes a movie stays for more than a week, so I need to copy the last post and change only the dates, leaving movie title, director's and actors' names etc. unchanged.
35
  The website is http://www.kino-desse.org and the cinema is located in Livorno, Italy.
36
 
37
  == Installation ==
39
  1. Upload `duplicate-post` directory to the `/wp-content/plugins/` directory
40
  2. Activate the plugin through the 'Plugins' menu in WordPress
41
 
42
+ == For plugin developers ==
43
+
44
+ From version 1.0 onwards, thanks to [Simon Wheatley](http://www.simonwheatley.co.uk/)'s suggestion, Duplicate Post adds two actions (*dp_duplicate_post* and *dp_duplicate_page*) which can be used by other developers if their plugins store extra data for posts in non-standard WP tables.
45
+ Since Duplicate Post knows only of standard WP tables, it can't copy other data relevant to the post which is being copied if this information is stored elsewhere. So, if you're a plugin developer which acts this way, and you want to ensure compatibility with Duplicate Post, you can hook your functions to those actions to make sure that they will be called when a post (or page) is cloned.
46
+
47
+ It's very simple. Just write your function that copies post metadata to a new row of your table:
48
+ `function myplugin_copy_post($new_post_id, $old_post_object){
49
+ /* your code */
50
+ }`
51
+
52
+ Then hook the function to the action:
53
+ `add_action( "dp_duplicate_post", "myplugin_copy_post", $priority, 2);`
54
+
55
+ Please refer to the [Plugin API](http://codex.wordpress.org/Plugin_API) for every information about the subject.
56
+
57
+ == Contribute ==
58
+
59
+ If you find this useful and you if you want to contribute, there are three ways:
60
+
61
+ 1. You can [write me](http://www.lopo.it/contatti/) and submit your bug reports, suggestions and requests for features;
62
+ 2. If you want to translate it to your language (there are just a few lines of text), you can [contact me](http://www.lopo.it/contatti/) and I’ll send you the .pot catalogue; your translation could be featured in next releases;
63
+ 3. Using the plugin is free, but if you want you can send me some bucks with PayPal [here](http://www.lopo.it/duplicate-post-plugin/)
64
+
65
+
66
+ == Changelog ==
67
+
68
+ = 1.0 =
69
+ * Better integration with WP 2.7+ interface
70
+ * Added actions for plugins which store post metadata in self-managed tables
71
+ * Added French and Spanish language files
72
+ * Dropped WP 2.6.5 compatibility
73
+
74
+ = 0.6.1 =
75
+ * Tested WP 2.9 compatibility
76
+
77
+ = 0.6 =
78
+ * Fix for WP 2.8.1
79
+ * WPMU compatibility
80
+ * Internationalization (Italian and Japanese language files shipped)
81
+
82
+ = 0.5 =
83
+ * Fix for post-meta
84
+ * WP2.7 compatibility
85
+
86
+ = 0.4 =
87
+ * Support for new WP post revision feature
88
+
todo.txt CHANGED
@@ -1 +1,2 @@
1
-
 
1
+ - Role manager compatibility
2
+ - Configuration page with a list of meta fields which must not be copied (for compatibility with some other plugins)