Duplicate Page and Post - Version 2.5.8

Version Description

Download this release

Release Info

Developer arjunthakur
Plugin Icon 128x128 Duplicate Page and Post
Version 2.5.8
Comparing to
See all releases

Code changes from version 2.0 to 2.5.8

duplicate-wp-page-post-setting.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
  <div class="wrap dpp_page_settings">
3
  <h1><?php _e('Plugin Settings', 'dpp_wpp_page')?></h1>
4
- <?php $dpp_options = array();
 
5
  $opt = get_option('dpp_wpp_page_options');
6
  $instruct = isset($_GET['instruct']) ? $_GET['instruct'] : '';
7
  if(isset($_POST['submit_dpp_wpp_page']) && wp_verify_nonce( $_POST['dpp_nonce_field'], 'dpp_page_action' )):
@@ -17,32 +18,80 @@ if(isset($_POST['submit_dpp_wpp_page']) && wp_verify_nonce( $_POST['dpp_nonce_fi
17
  if($dpp_settings_save){ dpp_wpp_page::dp_redirect('options-general.php?page=dpp_page_settings&instruct=1'); }
18
  else{ dpp_wpp_page::dp_redirect('options-general.php?page=dpp_page_settings&instruct=2'); }endif;
19
  if(!empty($instruct) && $instruct == 1):
20
- _e( '<div class="updated settings-error dpp_pluginnotice is-dismissible" id="setting-error-settings_updated">
21
- <p><strong>Changes saved.</strong></p><button class="notice-ignore" type="button"><span class="screen-reader-text">Ignore this notice.</span></button></div>', 'dpp_wpp_page');
 
 
 
 
22
  elseif(!empty($instruct) && $instruct == 2):
23
- _e( '<div class="error settings-error dpp_pluginnotice is-dismissible" id="setting-error-settings_updated">
24
- <p><strong>Changes not saved.</strong></p><button class="notice-ignore" type="button"><span class="screen-reader-text">Ignore this notice.</span></button></div>', 'dpp_wpp_page');
 
 
 
 
25
  endif;
26
- $dpp_post_status = array('draft');
27
  ?>
28
- <div id="dpp-stuff">
29
- <div id="dpp-post-body" class="metabox-holder columns-2">
30
- <div id="dpp-post-body-content" style="position: relative;">
31
  <form style="padding: 10px; border: 1px solid #333;" action="" method="post" name="dpp_wpp_page_form">
32
  <?php wp_nonce_field( 'dpp_page_action', 'dpp_nonce_field' ); ?>
33
  <table class="form-table">
34
  <tbody>
35
- <tr><th scope="row"><label for="dpp_post_suffix"><?php _e('Duplicate Post Suffix', 'dpp_wpp_page')?></label></th>
36
- <h3 style="color: red;"><?php _e('Add a suffix for duplicate or clone post as Copy, Clone etc. It will show after title.', 'dpp_wpp_page')?></h3>
37
- <td><input type="text" class="regular-text" value="<?php echo !empty($opt['dpp_post_suffix']) ? $opt['dpp_post_suffix'] : ''?>" id="dpp_post_suffix" name="dpp_post_suffix"></td>
 
 
 
 
 
 
38
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  </tbody>
40
  </table>
41
  <p class="submit"><input type="submit" value="Save Settings" class="button button-primary" id="submit" name="submit_dpp_wpp_page"></p>
42
- </form>
43
- </div>
44
- </div>
45
- </div>
46
- </div>
47
  </div>
48
  </div>
1
  <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
  <div class="wrap dpp_page_settings">
3
  <h1><?php _e('Plugin Settings', 'dpp_wpp_page')?></h1>
4
+ <?php
5
+ $dpp_options = array();
6
  $opt = get_option('dpp_wpp_page_options');
7
  $instruct = isset($_GET['instruct']) ? $_GET['instruct'] : '';
8
  if(isset($_POST['submit_dpp_wpp_page']) && wp_verify_nonce( $_POST['dpp_nonce_field'], 'dpp_page_action' )):
18
  if($dpp_settings_save){ dpp_wpp_page::dp_redirect('options-general.php?page=dpp_page_settings&instruct=1'); }
19
  else{ dpp_wpp_page::dp_redirect('options-general.php?page=dpp_page_settings&instruct=2'); }endif;
20
  if(!empty($instruct) && $instruct == 1):
21
+ _e( '<div id="message" class="updated notice notice-success is-dismissible">
22
+ <p>Changes Saved!</p>
23
+ <button type="button" class="notice-dismiss">
24
+ <span class="screen-reader-text">Ignore this notice.</span>
25
+ </button>
26
+ </div>', 'dpp_wpp_page');
27
  elseif(!empty($instruct) && $instruct == 2):
28
+ _e( '<div id="message" class="error notice notice-error is-dismissible">
29
+ <p>Changes not saved!</p>
30
+ <button type="button" class="notice-dismiss">
31
+ <span class="screen-reader-text">Ignore this notice.</span>
32
+ </button>
33
+ </div>', 'dpp_wpp_page');
34
  endif;
35
+ //$dpp_post_status = array('draft');
36
  ?>
37
+ <div id="dpp-stuff"><div id="dpp-post-body" class="metabox-holder columns-2"><div id="dpp-post-body-content" style="position: relative;">
 
 
38
  <form style="padding: 10px; border: 1px solid #333;" action="" method="post" name="dpp_wpp_page_form">
39
  <?php wp_nonce_field( 'dpp_page_action', 'dpp_nonce_field' ); ?>
40
  <table class="form-table">
41
  <tbody>
42
+ <tr>
43
+ <th scope="row"><label for="dpp_posteditor"><?php _e('Select Editor<br><em>Default: Classic Editor</em>', 'dpp_wpp_page'); ?></label></th>
44
+ <td>
45
+ <select id="dpp_posteditor" name="dpp_posteditor">
46
+ <option value="classic" <?php echo (isset($opt['dpp_posteditor']) && $opt['dpp_posteditor'] == 'classic') ? "selected = 'selected'" : ''; ?>><?php _e('Classic Editor', 'dpp_wpp_page'); ?></option>
47
+ <option value="gutenberg" <?php echo (isset($opt['dpp_posteditor']) && $opt['dpp_posteditor'] == 'gutenberg') ? "selected = 'selected'" : ''; ?>><?php _e('Gutenberg Editor', 'dpp_wpp_page'); ?></option>
48
+ </select>
49
+ <p><?php _e('Please select which editor you are using.<br> If you are using Gutenberg, select gutenberg editor otherwise it will not show Duplicate button on edit screen.', 'dpp_wpp_page'); ?></p>
50
+ </td>
51
  </tr>
52
+ <tr>
53
+ <th scope="row"><label for="dpp_post_status"><?php _e('Post Status<br><em>Default: Draft</em>', 'dpp_wpp_page'); ?></label></th>
54
+ <td>
55
+ <select id="dpp_post_status" name="dpp_post_status">
56
+ <option value="draft" <?php echo($opt['dpp_post_status'] == 'draft') ? "selected = 'selected'" : ''; ?>><?php _e('Draft', 'dpp_wpp_page'); ?></option>
57
+ <option value="publish" <?php echo($opt['dpp_post_status'] == 'publish') ? "selected = 'selected'" : ''; ?>><?php _e('Publish', 'dpp_wpp_page'); ?></option>
58
+ <option value="private" <?php echo($opt['dpp_post_status'] == 'private') ? "selected = 'selected'" : ''; ?>><?php _e('Private', 'dpp_wpp_page'); ?></option>
59
+ <option value="pending" <?php echo($opt['dpp_post_status'] == 'pending') ? "selected = 'selected'" : ''; ?>><?php _e('Pending', 'dpp_wpp_page'); ?></option>
60
+ </select>
61
+ <p><?php _e('Please select any post status you want to assign for duplicate post.', 'dpp_wpp_page'); ?></p>
62
+ </td>
63
+ </tr>
64
+ <tr>
65
+ <th scope="row"><label for="dpp_post_redirect"><?php _e('Redirect<br><em>Default: To current list.</em><br>(After click on <strong>Duplicate</strong>)', 'dpp_wpp_page'); ?></label></th>
66
+ <td>
67
+ <select id="dpp_post_redirect" name="dpp_post_redirect">
68
+ <option value="to_list" <?php echo($opt['dpp_post_redirect'] == 'to_list') ? "selected = 'selected'" : ''; ?>><?php _e('All Post List', 'dpp_wpp_page'); ?></option>
69
+ <option value="to_page" <?php echo($opt['dpp_post_redirect'] == 'to_page') ? "selected = 'selected'" : ''; ?>><?php _e('Direct Edit', 'dpp_wpp_page'); ?></option>
70
+ </select>
71
+ <p><?php _e('Please select any post redirection, redirect you to selected after click on duplicate.', 'dpp_wpp_page'); ?></p>
72
+ </td>
73
+ </tr>
74
+ <tr>
75
+ <th scope="row"><label for="dpp_post_suffix"><?php _e('Duplicate Post Suffix<br><em>Default: Empty</em>', 'dpp_wpp_page')?></label></th>
76
+
77
+ <td>
78
+ <input type="text" class="regular-text" value="<?php echo !empty($opt['dpp_post_suffix']) ? $opt['dpp_post_suffix'] : ''?>" id="dpp_post_suffix" name="dpp_post_suffix">
79
+ <p><?php _e('Add a suffix for duplicate page and post. It will show after title.', 'dpp_wpp_page')?></p>
80
+ </td>
81
+ </tr>
82
+ <tr>
83
+ <th scope="row"><label for="dpp_post_link_title"><?php _e('Duplicate Link Text<br><em>Default: Duplicate</em>', 'dpp_wpp_page')?></label></th>
84
+ <td>
85
+ <input type="text" class="regular-text" value="<?php echo !empty($opt['dpp_post_link_title']) ? $opt['dpp_post_link_title'] : ''?>" id="dpp_post_link_title" name="dpp_post_link_title">
86
+ <p><?php _e('It will show above text on duplicate page/post link button instead of default (Duplicate)', 'dpp_wpp_page')?></p>
87
+ </td>
88
+ </tr>
89
  </tbody>
90
  </table>
91
  <p class="submit"><input type="submit" value="Save Settings" class="button button-primary" id="submit" name="submit_dpp_wpp_page"></p>
92
+ </form></div></div>
93
+ <div>
94
+ <h3><a href="https://wordpress.org/support/plugin/duplicate-wp-page-post/reviews/?filter=5#new-post">Please review us</a> if you like the plugin.</h3>
95
+ </div>
 
96
  </div>
97
  </div>
duplicate-wp-page-post.php CHANGED
@@ -1,12 +1,11 @@
1
-
2
  <?php
3
  /*
4
  Plugin Name: Duplicate Page and Post
5
  Plugin URI: https://wordpress.org/plugins/duplicate-wp-page-post/
6
- Description: This plugin quickly creates a clone of page or post
7
  Author: Arjun Thakur
8
- Author URI: http://www.hisysinfotech.com/
9
- Version: 2.1
10
  License: GPLv2 or later
11
  Text Domain: dpp_wpp_page
12
  */
@@ -19,27 +18,36 @@ if(!class_exists('dcc_dpp_wpp_page')):
19
  /*AutoLoad Hooks*/
20
  public function __construct()
21
  {
 
22
  register_activation_hook(__FILE__, array(&$this, 'dpp_wpp_page_install'));
23
  add_action('admin_menu', array(&$this, 'dpp_page_options_page'));
24
  add_filter( 'plugin_action_links', array(&$this, 'dpp_page_plugin_action_links'), 10, 2 );
25
  add_action( 'admin_action_dt_dpp_post_as_draft', array(&$this,'dt_dpp_post_as_draft') );
26
  add_filter( 'post_row_actions', array(&$this,'dt_dpp_post_link'), 10, 2);
27
  add_filter( 'page_row_actions', array(&$this,'dt_dpp_post_link'), 10, 2);
28
- add_action( 'post_submitbox_misc_actions', array(&$this,'dpp_wpp_page_custom_button'));
29
- add_action( 'wp_before_admin_bar_render', array(&$this, 'dpp_wpp_page_admin_bar_link'));
30
- }
 
 
 
 
 
31
 
 
32
  /*Activation plugin Hook*/
33
  public function dpp_wpp_page_install()
34
  {
35
- $defaultsettings = array('dpp_post_status' => 'draft',
36
- 'dpp_post_redirect' => 'to_list',
37
- 'dpp_post_suffix' => '' );
38
- $opt = get_option('dpp_wpp_page_options');
39
- if(!$opt['dpp_post_status'])
40
- {
41
- update_option('dpp_wpp_page_options', $defaultsettings);
42
- }
 
 
43
  }
44
 
45
  /* Plugin Action Links(Dashboard) */
@@ -61,26 +69,34 @@ if(!class_exists('dcc_dpp_wpp_page')):
61
 
62
  /*Important function*/
63
  public function dt_dpp_post_as_draft()
64
- {
 
 
 
 
 
 
65
  global $wpdb;
66
 
67
  /*sanitize_GET POST REQUEST*/
68
- $post_copy = sanitize_text_field( $_POST["post"] );
69
- $get_copy = sanitize_text_field( $_GET['post'] );
70
- $request_copy = sanitize_text_field( $_REQUEST['action'] );
71
 
72
  $opt = get_option('dpp_wpp_page_options');
73
  $suffix = !empty($opt['dpp_post_suffix']) ? ' -- '.$opt['dpp_post_suffix'] : '';
 
74
  $post_status = !empty($opt['dpp_post_status']) ? $opt['dpp_post_status'] : 'draft';
75
  $redirectit = !empty($opt['dpp_post_redirect']) ? $opt['dpp_post_redirect'] : 'to_list';
76
 
77
- if (! ( isset( $get_copy ) || isset( $post_copy ) || ( isset($request_copy) && 'dt_dpp_post_as_draft' == $request_copy ) ) ) {
 
78
  wp_die('No post!');
79
  }
80
  $returnpage = '';
81
 
82
  /* Get post id */
83
- $post_id = (isset($get_copy) ? $get_copy : $post_copy );
84
 
85
  $post = get_post( $post_id );
86
 
@@ -93,9 +109,9 @@ if(!class_exists('dcc_dpp_wpp_page')):
93
  $args = array('comment_status' => $post->comment_status,
94
  'ping_status' => $post->ping_status,
95
  'post_author' => $new_post_author,
96
- 'post_content' => $post->post_content,
97
  'post_excerpt' => $post->post_excerpt,
98
- 'post_name' => $post->post_name,
99
  'post_parent' => $post->post_parent,
100
  'post_password' => $post->post_password,
101
  'post_status' => $post_status,
@@ -137,14 +153,20 @@ if(!class_exists('dcc_dpp_wpp_page')):
137
  } else {
138
  wp_die('Error! Post creation failed: ' . $post_id);
139
  }
 
 
 
140
  }
 
141
 
142
  /*Add link to action*/
143
  public function dt_dpp_post_link( $actions, $post ) {
 
 
144
  $opt = get_option('dpp_wpp_page_options');
145
  $post_status = !empty($opt['dpp_post_status']) ? $opt['dpp_post_status'] : 'draft';
146
  if (current_user_can('edit_posts')) {
147
- $actions['dpp'] = '<a href="admin.php?action=dt_dpp_post_as_draft&amp;post=' . $post->ID . '" title="Clone this as '.$post_status.'" rel="permalink">Duplicate</a>';
148
  }
149
  return $actions;
150
  }
@@ -152,15 +174,43 @@ if(!class_exists('dcc_dpp_wpp_page')):
152
  /*Add link to edit Post*/
153
  public function dpp_wpp_page_custom_button(){
154
  $opt = get_option('dpp_wpp_page_options');
155
- $post_status = !empty($opt['dpp_post_status']) ? $opt['dpp_post_status'] : 'draft';
156
  global $post;
 
 
157
  $html = '<div id="major-publishing-actions">';
158
  $html .= '<div id="export-action">';
159
- $html .= '<a href="admin.php?action=dt_dpp_post_as_draft&amp;post=' . $post->ID . '" title="Clone this as '.$post_status.'" rel="permalink">Duplicate</a>';
160
  $html .= '</div>';
161
  $html .= '</div>';
162
  echo $html;
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  /*Click here to clone Admin Bar*/
166
  public function dpp_wpp_page_admin_bar_link()
@@ -174,11 +224,12 @@ if(!class_exists('dcc_dpp_wpp_page')):
174
  return;
175
  if ( ! empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) )&& ( $post_type_object->show_ui || $current_object->post_type == 'attachment') )
176
  {
177
- $wp_admin_bar->add_menu( array('parent' => 'edit',
 
178
  'id' => 'dpp_this',
179
  'title' => __("Clone this as ".$post_status."", 'dpp_wpp_page'),
180
- 'href' => admin_url().'admin.php?action=dt_dpp_post_as_draft&amp;post=' . $post->ID
181
- ) );
182
  }
183
  }
184
 
@@ -188,6 +239,18 @@ if(!class_exists('dcc_dpp_wpp_page')):
188
  echo '<script>window.location.href="'.$url.'"</script>';
189
  }
190
  }
191
- new dpp_wpp_page;
 
 
 
 
 
 
 
 
 
 
192
  endif;
 
 
193
  ?>
 
1
  <?php
2
  /*
3
  Plugin Name: Duplicate Page and Post
4
  Plugin URI: https://wordpress.org/plugins/duplicate-wp-page-post/
5
+ Description: This plugin quickly creates a clone of page or post and supports Gutenberg.
6
  Author: Arjun Thakur
7
+ Author URI: https://profiles.wordpress.org/arjunthakur#content-plugins
8
+ Version: 2.5.8
9
  License: GPLv2 or later
10
  Text Domain: dpp_wpp_page
11
  */
18
  /*AutoLoad Hooks*/
19
  public function __construct()
20
  {
21
+ $opt = get_option('dpp_wpp_page_options');
22
  register_activation_hook(__FILE__, array(&$this, 'dpp_wpp_page_install'));
23
  add_action('admin_menu', array(&$this, 'dpp_page_options_page'));
24
  add_filter( 'plugin_action_links', array(&$this, 'dpp_page_plugin_action_links'), 10, 2 );
25
  add_action( 'admin_action_dt_dpp_post_as_draft', array(&$this,'dt_dpp_post_as_draft') );
26
  add_filter( 'post_row_actions', array(&$this,'dt_dpp_post_link'), 10, 2);
27
  add_filter( 'page_row_actions', array(&$this,'dt_dpp_post_link'), 10, 2);
28
+ if (isset($opt['dpp_posteditor']) && $opt['dpp_posteditor'] == 'gutenberg') {
29
+ add_action('admin_head', array(&$this, 'dpp_wpp_button_guten'));
30
+ } else {
31
+ add_action( 'post_submitbox_misc_actions', array(&$this,'dpp_wpp_page_custom_button'));
32
+ }
33
+ add_action( 'wp_before_admin_bar_render', array(&$this, 'dpp_wpp_page_admin_bar_link'));
34
+ }
35
+
36
 
37
+
38
  /*Activation plugin Hook*/
39
  public function dpp_wpp_page_install()
40
  {
41
+ $defaultsettings = array('dpp_post_status' => 'draft',
42
+ 'dpp_post_redirect' => 'to_list',
43
+ 'dpp_post_suffix' => '',
44
+ 'dpp_posteditor' => 'classic',
45
+ 'dpp_post_link_title' => '', );
46
+ $opt = get_option('dpp_wpp_page_options');
47
+ if(!$opt['dpp_post_status'])
48
+ {
49
+ update_option('dpp_wpp_page_options', $defaultsettings);
50
+ }
51
  }
52
 
53
  /* Plugin Action Links(Dashboard) */
69
 
70
  /*Important function*/
71
  public function dt_dpp_post_as_draft()
72
+ {
73
+
74
+ $nonce = $_REQUEST['nonce'];
75
+ $post_id = (isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post']));
76
+
77
+
78
+ if(wp_verify_nonce( $nonce, 'dt-duplicate-page-'.$post_id) && current_user_can('edit_posts')) {
79
  global $wpdb;
80
 
81
  /*sanitize_GET POST REQUEST*/
82
+ //$post_copy = sanitize_text_field( $_POST["post"] );
83
+ //$get_copy = sanitize_text_field( $_GET['post'] );
84
+ //$request_copy = sanitize_text_field( $_REQUEST['action'] );
85
 
86
  $opt = get_option('dpp_wpp_page_options');
87
  $suffix = !empty($opt['dpp_post_suffix']) ? ' -- '.$opt['dpp_post_suffix'] : '';
88
+
89
  $post_status = !empty($opt['dpp_post_status']) ? $opt['dpp_post_status'] : 'draft';
90
  $redirectit = !empty($opt['dpp_post_redirect']) ? $opt['dpp_post_redirect'] : 'to_list';
91
 
92
+ //if (! ( isset( $get_copy ) || isset( $post_copy ) || ( isset($request_copy) && 'dt_dpp_post_as_draft' == $request_copy ) ) ) {
93
+ if (!(isset($_GET['post']) || isset($_POST['post']) || (isset($_REQUEST['action']) && 'dt_dpp_post_as_draft' == $_REQUEST['action']))) {
94
  wp_die('No post!');
95
  }
96
  $returnpage = '';
97
 
98
  /* Get post id */
99
+ //$post_id = (isset($get_copy) ? $get_copy : $post_copy );
100
 
101
  $post = get_post( $post_id );
102
 
109
  $args = array('comment_status' => $post->comment_status,
110
  'ping_status' => $post->ping_status,
111
  'post_author' => $new_post_author,
112
+ 'post_content' => (isset($opt['dpp_posteditor']) && $opt['dpp_posteditor'] == 'gutenberg') ? wp_slash($post->post_content) : $post->post_content,
113
  'post_excerpt' => $post->post_excerpt,
114
+ //'post_name' => $post->post_name,
115
  'post_parent' => $post->post_parent,
116
  'post_password' => $post->post_password,
117
  'post_status' => $post_status,
153
  } else {
154
  wp_die('Error! Post creation failed: ' . $post_id);
155
  }
156
+ } else {
157
+ wp_die('Security check issue, Please try again.');
158
+ }
159
  }
160
+
161
 
162
  /*Add link to action*/
163
  public function dt_dpp_post_link( $actions, $post ) {
164
+ $opt = get_option('dpp_wpp_page_options');
165
+ $link_title = !empty($opt['dpp_post_link_title']) ? $opt['dpp_post_link_title'] : 'Duplicate';
166
  $opt = get_option('dpp_wpp_page_options');
167
  $post_status = !empty($opt['dpp_post_status']) ? $opt['dpp_post_status'] : 'draft';
168
  if (current_user_can('edit_posts')) {
169
+ $actions['dpp'] = '<a href="admin.php?action=dt_dpp_post_as_draft&amp;post='.$post->ID.'&amp;nonce='.wp_create_nonce( 'dt-duplicate-page-'.$post->ID ).'" title="Clone this as '.$post_status.'" rel="permalink">'.$link_title.'</a>';
170
  }
171
  return $actions;
172
  }
174
  /*Add link to edit Post*/
175
  public function dpp_wpp_page_custom_button(){
176
  $opt = get_option('dpp_wpp_page_options');
177
+ $link_title = !empty($opt['dpp_post_link_title']) ? $opt['dpp_post_link_title'] : 'Duplicate';
178
  global $post;
179
+ $opt = get_option('dpp_wpp_page_options');
180
+ $post_status = !empty($opt['dpp_post_status']) ? $opt['dpp_post_status'] : 'draft';
181
  $html = '<div id="major-publishing-actions">';
182
  $html .= '<div id="export-action">';
183
+ $html .= '<a href="admin.php?action=dt_dpp_post_as_draft&amp;post='.$post->ID.'&amp;nonce='.wp_create_nonce( 'dt-duplicate-page-'.$post->ID ).'" title="Duplicate this as '.$post_status.'" rel="permalink">'.$link_title.'</a>';
184
  $html .= '</div>';
185
  $html .= '</div>';
186
  echo $html;
187
  }
188
+ /*
189
+ * Add the duplicate link to edit screen - gutenberg
190
+ */
191
+ public function dpp_wpp_button_guten()
192
+ {
193
+ global $post;
194
+ if ($post) {
195
+ $opt = get_option('dpp_wpp_page_options');
196
+ $post_status = !empty($opt['dpp_post_status']) ? $opt['dpp_post_status'] : 'draft';
197
+ if (isset($opt['dpp_posteditor']) && $opt['dpp_posteditor'] == 'gutenberg') {
198
+ ?>
199
+ <style> .link_gutenberg {text-align: center; margin-top: 15px;} .link_gutenberg a {text-decoration: none; display: block; height: 40px; line-height: 28px; padding: 3px 12px 2px; background: #0073AA; border-radius: 3px; border-width: 1px; border-style: solid; color: #ffffff; font-size: 16px; } .link_gutenberg a:hover { background: #23282D; border-color: #23282D; }</style>
200
+ <script>jQuery(window).load(function(e){
201
+ var dpp_postid = "<?php echo $post->ID; ?>";
202
+ var dtnonce = "<?php echo wp_create_nonce( 'dt-duplicate-page-'.$post->ID );?>";
203
+ var dpp_posttitle = "Duplicate this as <?php echo $post_status; ?>";
204
+ var dpp_duplicatelink = '<div class="link_gutenberg">';
205
+ dpp_duplicatelink += '<a href="admin.php?action=dt_dpp_post_as_draft&amp;post='+dpp_postid'&amp;nonce='+dtnonce+'" title="'+dpp_posttitle+'">Duplicate</a>';
206
+ dpp_duplicatelink += '</div>';
207
+ jQuery('.edit-post-post-status').append(dpp_duplicatelink);
208
+ });</script>
209
+ <?php
210
+ }
211
+ }
212
+ }
213
+
214
 
215
  /*Click here to clone Admin Bar*/
216
  public function dpp_wpp_page_admin_bar_link()
224
  return;
225
  if ( ! empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) )&& ( $post_type_object->show_ui || $current_object->post_type == 'attachment') )
226
  {
227
+ $wp_admin_bar->add_menu( array(
228
+ 'parent' => 'edit',
229
  'id' => 'dpp_this',
230
  'title' => __("Clone this as ".$post_status."", 'dpp_wpp_page'),
231
+ 'href' => admin_url().'admin.php?action=dt_dpp_post_as_draft&amp;post='.$post->ID.'&amp;nonce='.wp_create_nonce( 'dt-duplicate-page-'.$post->ID )
232
+ ));
233
  }
234
  }
235
 
239
  echo '<script>window.location.href="'.$url.'"</script>';
240
  }
241
  }
242
+ new dpp_wpp_page;
243
+
244
+ /*plugin settings page link*/
245
+ add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'dpp_settings_link');
246
+ function dpp_settings_link( $links ) {
247
+ $links[] = '<a href="' .
248
+ admin_url( 'options-general.php?page=dpp_page_settings' ) .
249
+ '">' . __('Settings') . '</a>';
250
+ return $links;
251
+ }
252
+
253
  endif;
254
+
255
+
256
  ?>
readme.txt CHANGED
@@ -1,36 +1,40 @@
1
  === Duplicate Page and Post ===
2
- Contributors: arjunthakur
3
- Donate link: http://www.hisysinfotech.com/
4
- Tags: duplicate post, duplicate page, duplicate custom posts, wordpress page duplicator, wordpress post duplicator, page duplicate, page and post clone, page clone, post clone, wp post clone.
5
  Requires at least: 3.5
6
- Tested up to: 4.8.1
7
- Stable tag: 2.0
 
 
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Duplicate posts, pages and custom posts or page and post clone.
12
 
13
  == Description ==
14
 
15
- Duplicate page and post plugin provides functionality to creates a clone of page or posts,
16
- You can duplicate pages, posts and custom post by click and it will be saved as draft.
17
- Duplicate page and post doesn't have a lot of features that other plugins have, but it
18
- also is lightning fast by comparison.
19
 
20
  = Major features of this plugin include =
21
 
22
- 1. Create a clone of particular page.
23
- 2. Create a clone of particular post.
24
- 3. Create a clone of particular custom post(CPT).
 
 
 
 
 
25
 
26
  == Installation ==
27
 
28
  The plugin is simple to install:
29
 
30
- 1. Download duplicate-wp-page-post.zip
31
- 2. Unzip
32
- 3. Upload duplicate-wp-page-post directory to your /wp-content/plugins directory
33
- 4. Go to the plugin menu page and activate the plugin
34
 
35
  == Frequently asked questions ==
36
 
@@ -40,7 +44,7 @@ The plugin is simple to install:
40
  2. Then Create New Post/Page Or you can use old one.
41
  3. Now go to all pages or all posts page on your dashboard.
42
  4. Hover your cursor over any page or any post on dashboard section, you'll see a "Click here to clone" Button.
43
- 5. After you click on "Click here to Clone" link, then duplicate post/page will be created and saved as draft, make the changes you wish and hit publish.
44
 
45
  = What is the benefit of using this plugin? =
46
 
1
  === Duplicate Page and Post ===
2
+ Contributors: arjunthakur, efficientninja
3
+ Tags: duplicate post, duplicate page, clone page, clone post, duplicate custom posts, clone custom post, wordpress page duplicator, wordpress post duplicator, page duplicate, clone page and post, wp post clone.
 
4
  Requires at least: 3.5
5
+ Tested up to: 5.4
6
+ Requires PHP: 5.2.4
7
+ Stable tag: 2.5.8
8
+ Version: 2.5.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
+ Duplicate post, Duplicate page and Duplicate custom post or clone page and clone post.
13
 
14
  == Description ==
15
 
16
+ Duplicate page and post plugin provides functionality to create a clone of page or posts. You can duplicate pages, posts and custom post by single click and it will be saved as draft.
17
+ Duplicate page and post doesn't have a lot of features that other plugins have, but it also is lightning fast by comparison.
 
 
18
 
19
  = Major features of this plugin include =
20
 
21
+ * Create a clone of particular page.
22
+ * Create a clone of particular post.
23
+ * Create a clone of particular custom post(CPT).
24
+ * Option to select editor (Classic and Gutenberg)
25
+ * Option to add Post Suffix.
26
+ * Option to add custom text for duplicate link button.
27
+ * Option to select Duplicate Posts Status.
28
+ * Option to Redirect after click on Duplicate.
29
 
30
  == Installation ==
31
 
32
  The plugin is simple to install:
33
 
34
+ * Download duplicate-wp-page-post.zip
35
+ * Unzip
36
+ * Upload duplicate-wp-page-post directory to your /wp-content/plugins directory
37
+ * Go to the plugin menu page and activate the plugin
38
 
39
  == Frequently asked questions ==
40
 
44
  2. Then Create New Post/Page Or you can use old one.
45
  3. Now go to all pages or all posts page on your dashboard.
46
  4. Hover your cursor over any page or any post on dashboard section, you'll see a "Click here to clone" Button.
47
+ 5. After you click on "Duplicate" link, then duplicate post/page will be created and saved as draft, make the changes you wish and hit publish.
48
 
49
  = What is the benefit of using this plugin? =
50