Post Duplicator - Version 2.26

Version Description

  • Removed duplicate functionality from post trash pages
  • Database sanitization updates
  • Asset loading path updates
Download this release

Release Info

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

Code changes from version 2.25 to 2.26

includes/ajax.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /* --------------------------------------------------------- */
4
- /* !Duplicate the post - 2.22 */
5
  /* --------------------------------------------------------- */
6
 
7
  function mtphr_duplicate_post( $original_id, $args=array(), $do_action=true ) {
@@ -16,9 +16,9 @@ function mtphr_duplicate_post( $original_id, $args=array(), $do_action=true ) {
16
  $settings = wp_parse_args( $args, $global_settings );
17
 
18
  // Modify some of the elements
19
- $appended = ( $settings['title'] != '' ) ? ' '.$settings['title'] : '';
20
- $duplicate['post_title'] = $duplicate['post_title'].' '.$appended;
21
- $duplicate['post_name'] = sanitize_title($duplicate['post_name'].'-'.$settings['slug']);
22
 
23
  // Set the status
24
  if( $settings['status'] != 'same' ) {
@@ -74,11 +74,17 @@ function mtphr_duplicate_post( $original_id, $args=array(), $do_action=true ) {
74
  foreach ( $custom_fields as $key => $value ) {
75
  if( is_array($value) && count($value) > 0 ) {
76
  foreach( $value as $i=>$v ) {
77
- $result = $wpdb->insert( $wpdb->prefix.'postmeta', array(
78
- 'post_id' => $duplicate_id,
79
- 'meta_key' => $key,
80
- 'meta_value' => $v
81
- ));
 
 
 
 
 
 
82
  }
83
  }
84
  }
1
  <?php
2
 
3
  /* --------------------------------------------------------- */
4
+ /* !Duplicate the post - 2.26 */
5
  /* --------------------------------------------------------- */
6
 
7
  function mtphr_duplicate_post( $original_id, $args=array(), $do_action=true ) {
16
  $settings = wp_parse_args( $args, $global_settings );
17
 
18
  // Modify some of the elements
19
+ $appended = isset( $settings['title'] ) ? $settings['title'] : esc_html__( 'Copy', 'post-duplicator' );
20
+ $duplicate['post_title'] = $duplicate['post_title'] . ' ' . $appended;
21
+ $duplicate['post_name'] = sanitize_title( $duplicate['post_name'] . '-' . $settings['slug'] );
22
 
23
  // Set the status
24
  if( $settings['status'] != 'same' ) {
74
  foreach ( $custom_fields as $key => $value ) {
75
  if( is_array($value) && count($value) > 0 ) {
76
  foreach( $value as $i=>$v ) {
77
+ $data = array(
78
+ 'post_id' => $duplicate_id,
79
+ 'meta_key' => $key,
80
+ 'meta_value' => $v,
81
+ );
82
+ $formats = array(
83
+ '%d',
84
+ '%s',
85
+ '%s',
86
+ );
87
+ $result = $wpdb->insert( $wpdb->prefix.'postmeta', $data, $formats );
88
  }
89
  }
90
  }
includes/edit.php CHANGED
@@ -3,9 +3,15 @@
3
  /**
4
  * Add a duplicate post link.
5
  *
6
- * @since 2.25
7
  */
8
  function mtphr_post_duplicator_action_row_link( $post ) {
 
 
 
 
 
 
9
 
10
  $settings = get_mtphr_post_duplicator_settings();
11
  if ( 'current_user' === $settings['post_duplication'] ) {
3
  /**
4
  * Add a duplicate post link.
5
  *
6
+ * @since 2.26
7
  */
8
  function mtphr_post_duplicator_action_row_link( $post ) {
9
+
10
+ // Do not show on trash page
11
+ $post_status = isset( $_GET['post_status'] ) ? $_GET['post_status'] : false;
12
+ if ( 'trash' == $post_status ) {
13
+ return false;
14
+ }
15
 
16
  $settings = get_mtphr_post_duplicator_settings();
17
  if ( 'current_user' === $settings['post_duplication'] ) {
includes/scripts.php CHANGED
@@ -3,12 +3,12 @@
3
  /**
4
  * Load the metaboxer scripts
5
  *
6
- * @since 2.25
7
  */
8
  function mtphr_post_duplicator_metaboxer_scripts( $hook ) {
9
  if( $hook == 'tools_page_mtphr_post_duplicator_settings_menu' ) {
10
  $version = WP_DEBUG ? time() : MTPHR_POST_DUPLICATOR_VERSION;
11
- wp_enqueue_style( 'mtphr-post-duplicator-metaboxer', plugins_url().'/post-duplicator/metaboxer/metaboxer.css', false, $version );
12
  }
13
  }
14
  add_action( 'admin_enqueue_scripts', 'mtphr_post_duplicator_metaboxer_scripts' );
@@ -16,10 +16,10 @@ add_action( 'admin_enqueue_scripts', 'mtphr_post_duplicator_metaboxer_scripts' )
16
  /**
17
  * Add the necessary jquery.
18
  *
19
- * @since 2.25
20
  */
21
  function m4c_duplicate_post_scripts( $hook_suffix ) {
22
  $version = WP_DEBUG ? time() : MTPHR_POST_DUPLICATOR_VERSION;
23
- wp_enqueue_script( 'mtphr-post-duplicator', plugins_url().'/post-duplicator/assets/js/pd-admin.js', array('jquery'), $version );
24
  }
25
  add_action( 'admin_enqueue_scripts', 'm4c_duplicate_post_scripts' );
3
  /**
4
  * Load the metaboxer scripts
5
  *
6
+ * @since 2.26
7
  */
8
  function mtphr_post_duplicator_metaboxer_scripts( $hook ) {
9
  if( $hook == 'tools_page_mtphr_post_duplicator_settings_menu' ) {
10
  $version = WP_DEBUG ? time() : MTPHR_POST_DUPLICATOR_VERSION;
11
+ wp_enqueue_style( 'mtphr-post-duplicator-metaboxer', MTPHR_POST_DUPLICATOR_URL . 'metaboxer/metaboxer.css', false, $version );
12
  }
13
  }
14
  add_action( 'admin_enqueue_scripts', 'mtphr_post_duplicator_metaboxer_scripts' );
16
  /**
17
  * Add the necessary jquery.
18
  *
19
+ * @since 2.26
20
  */
21
  function m4c_duplicate_post_scripts( $hook_suffix ) {
22
  $version = WP_DEBUG ? time() : MTPHR_POST_DUPLICATOR_VERSION;
23
+ wp_enqueue_script( 'mtphr-post-duplicator', MTPHR_POST_DUPLICATOR_URL . 'assets/js/pd-admin.js', array('jquery'), $version );
24
  }
25
  add_action( 'admin_enqueue_scripts', 'm4c_duplicate_post_scripts' );
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.25
6
  Author: Metaphor Creations
7
  Author URI: http://www.metaphorcreations.com
8
  Text Domain: post-duplicator
@@ -28,11 +28,25 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
 
29
 
30
 
 
 
 
 
31
 
32
- /**Define Widget Constants */
33
- define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.25' );
34
- define ( 'MTPHR_POST_DUPLICATOR_DIR', plugin_dir_path(__FILE__) );
 
35
 
 
 
 
 
 
 
 
 
 
36
 
37
 
38
  add_action( 'plugins_loaded', 'mtphr_post_duplicator_localization' );
2
  /*
3
  Plugin Name: Post Duplicator
4
  Description: Creates functionality to duplicate any and all post types, including taxonomies & custom fields
5
+ Version: 2.26
6
  Author: Metaphor Creations
7
  Author URI: http://www.metaphorcreations.com
8
  Text Domain: post-duplicator
28
 
29
 
30
 
31
+ // Plugin version.
32
+ if ( ! defined( 'MTPHR_POST_DUPLICATOR_VERSION' ) ) {
33
+ define( 'MTPHR_POST_DUPLICATOR_VERSION', '2.26' );
34
+ }
35
 
36
+ // Plugin Folder Path.
37
+ if ( ! defined( 'MTPHR_POST_DUPLICATOR_DIR' ) ) {
38
+ define( 'MTPHR_POST_DUPLICATOR_DIR', plugin_dir_path( __FILE__ ) );
39
+ }
40
 
41
+ // Plugin Folder URL.
42
+ if ( ! defined( 'MTPHR_POST_DUPLICATOR_URL' ) ) {
43
+ define( 'MTPHR_POST_DUPLICATOR_URL', plugin_dir_url( __FILE__ ) );
44
+ }
45
+
46
+ // Plugin Root File.
47
+ if ( ! defined( 'MTPHR_POST_DUPLICATOR_FILE' ) ) {
48
+ define( 'MTPHR_POST_DUPLICATOR_FILE', __FILE__ );
49
+ }
50
 
51
 
52
  add_action( 'plugins_loaded', 'mtphr_post_duplicator_localization' );
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: metaphorcreations
3
  Tags: posts, post, duplicate, duplication
4
  Requires at least: 4.0
5
- Tested up to: 5.8.2
6
- Stable tag: 2.25
7
  License: GPL2
8
 
9
  Creates functionality to duplicate any and all post types, including taxonomies & custom fields.
@@ -41,6 +41,11 @@ Check out the 'Installation' tab.
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
44
  = 2.25 =
45
  * Multiple data sanitization updates
46
 
@@ -141,4 +146,4 @@ Must upgrade in order for the plugin to work. The file paths where initially wro
141
 
142
  == Upgrade Notice ==
143
 
144
- Multiple data sanitization updates
2
  Contributors: metaphorcreations
3
  Tags: posts, post, duplicate, duplication
4
  Requires at least: 4.0
5
+ Tested up to: 5.9
6
+ Stable tag: 2.26
7
  License: GPL2
8
 
9
  Creates functionality to duplicate any and all post types, including taxonomies & custom fields.
41
 
42
  == Changelog ==
43
 
44
+ = 2.26 =
45
+ * Removed duplicate functionality from post trash pages
46
+ * Database sanitization updates
47
+ * Asset loading path updates
48
+
49
  = 2.25 =
50
  * Multiple data sanitization updates
51
 
146
 
147
  == Upgrade Notice ==
148
 
149
+ Sanitization updates and removed trashed post duplication