Post Duplicator - Version 2.23

Version Description

  • Added setting to limit post duplication to current user
  • Added setting to setup duplicated post author to current user
  • Set the default setting of duplicated post author to current user
Download this release

Release Info

Developer metaphorcreations
Plugin Icon 128x128 Post Duplicator
Version 2.23
Comparing to
See all releases

Code changes from version 2.22 to 2.23

includes/ajax.php CHANGED
@@ -48,6 +48,9 @@ function mtphr_duplicate_post( $original_id, $args=array(), $do_action=true ) {
48
  $duplicate['post_date_gmt'] = date('Y-m-d H:i:s', $timestamp_gmt);
49
  $duplicate['post_modified'] = date('Y-m-d H:i:s', current_time('timestamp',0));
50
  $duplicate['post_modified_gmt'] = date('Y-m-d H:i:s', current_time('timestamp',1));
 
 
 
51
 
52
  // Remove some of the keys
53
  unset( $duplicate['ID'] );
48
  $duplicate['post_date_gmt'] = date('Y-m-d H:i:s', $timestamp_gmt);
49
  $duplicate['post_modified'] = date('Y-m-d H:i:s', current_time('timestamp',0));
50
  $duplicate['post_modified_gmt'] = date('Y-m-d H:i:s', current_time('timestamp',1));
51
+ if ( 'current_user' == $settings['post_author'] ) {
52
+ $duplicate['post_author'] = get_current_user_id();
53
+ }
54
 
55
  // Remove some of the keys
56
  unset( $duplicate['ID'] );
includes/edit.php CHANGED
@@ -8,6 +8,11 @@
8
  function mtphr_post_duplicator_action_row_link( $post ) {
9
 
10
  $settings = get_mtphr_post_duplicator_settings();
 
 
 
 
 
11
 
12
  // Get the post type object
13
  $post_type = get_post_type_object( $post->post_type );
@@ -33,7 +38,9 @@ function mtphr_post_duplicator_action_row_link( $post ) {
33
  // Add the duplicate link to post actions
34
  function mtphr_post_duplicator_action_row( $actions, $post ){
35
  if( function_exists('mtphr_post_duplicator_action_row_link') ) {
36
- $actions['duplicate_post'] = mtphr_post_duplicator_action_row_link( $post );
 
 
37
  }
38
  return $actions;
39
  }
8
  function mtphr_post_duplicator_action_row_link( $post ) {
9
 
10
  $settings = get_mtphr_post_duplicator_settings();
11
+ if ( 'current_user' === $settings['post_duplication'] ) {
12
+ if ( get_current_user_id() != $post->post_author ) {
13
+ return false;
14
+ }
15
+ }
16
 
17
  // Get the post type object
18
  $post_type = get_post_type_object( $post->post_type );
38
  // Add the duplicate link to post actions
39
  function mtphr_post_duplicator_action_row( $actions, $post ){
40
  if( function_exists('mtphr_post_duplicator_action_row_link') ) {
41
+ if ( $link = mtphr_post_duplicator_action_row_link( $post ) ) {
42
+ $actions['duplicate_post'] = $link;
43
+ }
44
  }
45
  return $actions;
46
  }
includes/functions.php CHANGED
@@ -12,6 +12,8 @@ function get_mtphr_post_duplicator_settings() {
12
  $settings = get_option('mtphr_post_duplicator_settings', array());
13
 
14
  $defaults = array(
 
 
15
  'status' => 'same',
16
  'type' => 'same',
17
  'timestamp' => 'current',
@@ -35,6 +37,12 @@ function get_mtphr_post_duplicator_settings() {
35
 
36
  function mtphr_post_duplicator_submitbox( $post ) {
37
  if( $post->post_status == 'publish' ) {
 
 
 
 
 
 
38
  $post_type = get_post_type_object( $post->post_type );
39
  $nonce = wp_create_nonce( 'm4c_ajax_file_nonce' );
40
  ?>
12
  $settings = get_option('mtphr_post_duplicator_settings', array());
13
 
14
  $defaults = array(
15
+ 'post_duplication' => 'all_users',
16
+ 'post_author' => 'current_user',
17
  'status' => 'same',
18
  'type' => 'same',
19
  'timestamp' => 'current',
37
 
38
  function mtphr_post_duplicator_submitbox( $post ) {
39
  if( $post->post_status == 'publish' ) {
40
+ $settings = get_mtphr_post_duplicator_settings();
41
+ if ( 'current_user' === $settings['post_duplication'] ) {
42
+ if ( get_current_user_id() != $post->post_author ) {
43
+ return false;
44
+ }
45
+ }
46
  $post_type = get_post_type_object( $post->post_type );
47
  $nonce = wp_create_nonce( 'm4c_ajax_file_nonce' );
48
  ?>
includes/settings.php CHANGED
@@ -27,6 +27,28 @@ add_action( 'admin_init', 'mtphr_post_duplicator_initialize_settings' );
27
  * @since 2.16
28
  */
29
  function mtphr_post_duplicator_initialize_settings() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  $settings['status'] = array(
32
  'title' => __( 'Post Status', 'post-duplicator' ),
27
  * @since 2.16
28
  */
29
  function mtphr_post_duplicator_initialize_settings() {
30
+
31
+ $settings['post_duplication'] = array(
32
+ 'title' => __( 'Post Duplication', 'post-duplicator' ),
33
+ 'type' => 'radio',
34
+ 'options' => array(
35
+ 'all_users' => __('Allow Duplication of All Users', 'post-duplicator'),
36
+ 'current_user' => __('Limit to Current User', 'post-duplicator')
37
+ ),
38
+ 'display' => 'inline',
39
+ 'default' => 'all_users'
40
+ );
41
+
42
+ $settings['post_author'] = array(
43
+ 'title' => __( 'Post Author', 'post-duplicator' ),
44
+ 'type' => 'radio',
45
+ 'options' => array(
46
+ 'current_user' => __('Current User', 'post-duplicator'),
47
+ 'original_user' => __('Original Post Author', 'post-duplicator'),
48
+ ),
49
+ 'display' => 'inline',
50
+ 'default' => 'current_user'
51
+ );
52
 
53
  $settings['status'] = array(
54
  'title' => __( 'Post Status', 'post-duplicator' ),
m4c-postduplicator.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Post Duplicator
4
  Description: Creates functionality to duplicate any and all post types, including taxonomies & custom fields
5
- Version: 2.22
6
  Author: Metaphor Creations
7
  Author URI: http://www.metaphorcreations.com
8
  Text Domain: post-duplicator
@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
 
31
 
32
  /**Define Widget Constants */
33
- define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.22' );
34
  define ( 'MTPHR_POST_DUPLICATOR_DIR', plugin_dir_path(__FILE__) );
35
 
36
 
2
  /*
3
  Plugin Name: Post Duplicator
4
  Description: Creates functionality to duplicate any and all post types, including taxonomies & custom fields
5
+ Version: 2.23
6
  Author: Metaphor Creations
7
  Author URI: http://www.metaphorcreations.com
8
  Text Domain: post-duplicator
30
 
31
 
32
  /**Define Widget Constants */
33
+ define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.23' );
34
  define ( 'MTPHR_POST_DUPLICATOR_DIR', plugin_dir_path(__FILE__) );
35
 
36
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: metaphorcreations
3
  Tags: posts, post, duplicate, duplication
4
  Requires at least: 4.0
5
- Tested up to: 5.5.1
6
  Stable tag: /trunk/
7
  License: GPL2
8
 
@@ -41,6 +41,11 @@ Check out the 'Installation' tab.
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
44
  = 2.22 =
45
  * Fixed Gutenburg escaping in returns for ACF blocks
46
 
@@ -130,4 +135,4 @@ Must upgrade in order for the plugin to work. The file paths where initially wro
130
 
131
  == Upgrade Notice ==
132
 
133
- Fixed Gutenburg escaping in returns for ACF blocks
2
  Contributors: metaphorcreations
3
  Tags: posts, post, duplicate, duplication
4
  Requires at least: 4.0
5
+ Tested up to: 5.7.2
6
  Stable tag: /trunk/
7
  License: GPL2
8
 
41
 
42
  == Changelog ==
43
 
44
+ = 2.23 =
45
+ * Added setting to limit post duplication to current user
46
+ * Added setting to setup duplicated post author to current user
47
+ * Set the default setting of duplicated post author to current user
48
+
49
  = 2.22 =
50
  * Fixed Gutenburg escaping in returns for ACF blocks
51
 
135
 
136
  == Upgrade Notice ==
137
 
138
+ Set the default setting of duplicated post author to current user and added additional settings