WP Post Page Clone - Version 1.1

Version Description

(10th May, 2020) =

  • Security issues fixes addressed by Securi
Download this release

Release Info

Developer gaurangsondagar
Plugin Icon 128x128 WP Post Page Clone
Version 1.1
Comparing to
See all releases

Version 1.1

index.php ADDED
@@ -0,0 +1,2 @@
1
+ <?php
2
+ # Silence is golden.
languages/wp-post-page-clone.pot ADDED
@@ -0,0 +1,30 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Post Page Clone\n"
4
+ "POT-Creation-Date: 2017-02-09\n"
5
+ "PO-Revision-Date: 2017-02-09\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: Gaurang Sondagar <gaurangsondagar@gmail.com>\n"
8
+ "Language: en_EN\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.4\n"
13
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;_n;_x;_ex;_nx;esc_attr_e;"
14
+ "_n_noop:1,2;esc_attr__;esc_attr_x;esc_html__;esc_html_e;esc_html_x\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
18
+ "X-Poedit-SearchPath-0: wp-content/plugins/wp-post-page-clone\n"
19
+
20
+ #: wp-post-page-clone/wp-post-page-clone.php:103
21
+ msgid "Post or Page creation failed, could not find original post:"
22
+ msgstr ""
23
+
24
+ #: wp-post-page-clone/wp-post-page-clone.php:123
25
+ msgid "Clone Post and Page"
26
+ msgstr ""
27
+
28
+ #: wp-post-page-clone/wp-post-page-clone.php:123
29
+ msgid "Click To Clone"
30
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,55 @@
1
+ === WP Post Page Clone ===
2
+ Contributors: gaurangsondagar
3
+ Donate link: http://gaurangsondagar99.wordpress.com/
4
+ Tags: clone post, clone page, duplicate post, duplicate page, clone post and page, duplicate post and page
5
+ Requires at least: 4.0
6
+ Tested up to: 5.4.1
7
+ Stable tag: 1.1
8
+ License: GPLv2
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Clone Post or Page with it's contents and settings in just one click.
12
+
13
+ == Description ==
14
+ WP Post Page Clone is a WordPress plugin that allows you to easily duplicate or clone post/page in just one click.
15
+
16
+ WP Post Page Clone Plugin Features
17
+
18
+ * Clone post with it's contents and settings in just one click.
19
+ * Clone page with it's contents and settings in just one click.
20
+ * Cross Browsers Support ( Firefox, Chrome, Safari, Opera, etc. )
21
+
22
+ == Installation ==
23
+
24
+ * Upload the **wp-post-page-clone.zip** file Via WordPress Admin > Plugins > Add New,
25
+ * Alternately, upload **wp-post-page-clone** folder to the /wp-content/plugins/ directory via FTP,
26
+ * Activate the **WP Post Page Clone** plugin from Admin > Plugins.
27
+ * Now go to the all posts or all pages from your dashboard
28
+ * Just Hover your cursor on any post or page then you will see a "Click To Clone" link
29
+ * Click on this link to clone your post/page with it's all settings of your previous page.
30
+
31
+ == Frequently Asked Questions ==
32
+
33
+ = How to create a duplicate of post ? =
34
+
35
+ * Activate the plugin from the 'Plugins' menu in Dashboard
36
+ * Now go to all posts on your dashboard
37
+ * Hover your cursor over any post you will see a "Click To Clone" link
38
+ * Click on this link to clone your post with it's all settings of your previous post.
39
+
40
+ = How to create a duplicate of page ? =
41
+
42
+ * Activate the plugin from the 'Plugins' menu in Dashboard
43
+ * Now go to all pages on your dashboard
44
+ * Hover your cursor over any page you will see a "Click To Clone" link
45
+ * Click on this link to clone your page with it's all settings of your previous page.
46
+
47
+ == Screenshots ==
48
+
49
+ 1. screenshot-1.png
50
+
51
+ == Changelog ==
52
+
53
+ = 1.1 (10th May, 2020) =
54
+
55
+ * Security issues fixes addressed by Securi
wp-post-page-clone.php ADDED
@@ -0,0 +1,160 @@
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Post Page Clone
4
+ Plugin URI: https://wordpress.org/plugins/wp-post-page-clone
5
+ Description: A plugin to generate duplicate post or page with contents and it's settings.
6
+ Author: Gaurang Sondagar
7
+ Author URI: http://gaurangsondagar99.wordpress.com/
8
+ Version: 1.1
9
+ Text Domain: wp-post-page-clone
10
+ Requires at least: 4.0
11
+ Tested up to: 5.4.1
12
+ Domin Path: Languages
13
+ License: GPLV2
14
+
15
+ /**
16
+ * Exit if accessed directly
17
+ */
18
+ if (!defined('ABSPATH')) {
19
+ exit;
20
+ }
21
+
22
+ /**
23
+ * Define Constant variables
24
+ */
25
+ if (!defined('WP_POST_PAGE_CLONE_URL')) {
26
+ define('WP_POST_PAGE_CLONE_URL', plugins_url() . '/wp-post-page-clone');
27
+ }
28
+
29
+ if (!defined('WP_POST_PAGE_CLONE_PLUGIN_DIRNAME')) {
30
+ define('WP_POST_PAGE_CLONE_PLUGIN_DIRNAME', plugin_basename(dirname(__FILE__)));
31
+ }
32
+
33
+
34
+ if(!function_exists('wp_post_page_clone_translate')) {
35
+ /**
36
+ * Function for language translations
37
+ */
38
+ function wp_post_page_clone_translate() {
39
+
40
+ load_plugin_textdomain('wp-post-page-clone', false, basename(dirname( __FILE__ ) ) . '/languages' );
41
+
42
+ }
43
+
44
+ }
45
+
46
+ add_action( 'plugins_loaded', 'wp_post_page_clone_translate' );
47
+
48
+
49
+ if(!function_exists('wp_post_page_clone')) {
50
+ /**
51
+ * Function for post / page clone and redirect that post
52
+ * @global type $wpdb
53
+ */
54
+ function wp_post_page_clone(){
55
+
56
+ global $wpdb;
57
+
58
+ /*
59
+ * get Nonce value
60
+ */
61
+ $nonce = $_REQUEST['nonce'];
62
+
63
+ if ( !isset( $_GET['post']) || (!isset($_REQUEST['action']) && 'wp_post_page_clone' != $_REQUEST['action'] ) ) {
64
+ wp_die('No post or page to clone has been supplied!, Please try again!');
65
+ }
66
+
67
+ $post_id = (isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post']));
68
+
69
+ if(wp_verify_nonce( $nonce, 'wp-post-page-clone-'.$post_id) && current_user_can('edit_posts')){
70
+
71
+ $post = get_post( $post_id );
72
+ $current_user = wp_get_current_user();
73
+ $post_author = $current_user->ID;
74
+
75
+ if (isset( $post ) && $post != null) {
76
+
77
+ $args = array(
78
+ 'comment_status' => $post->comment_status,
79
+ 'ping_status' => $post->ping_status,
80
+ 'post_author' => $post_author,
81
+ 'post_content' => $post->post_content,
82
+ 'post_excerpt' => $post->post_excerpt,
83
+ 'post_name' => $post->post_name,
84
+ 'post_parent' => $post->post_parent,
85
+ 'post_password' => $post->post_password,
86
+ 'post_status' => 'draft',
87
+ 'post_title' => $post->post_title,
88
+ 'post_type' => $post->post_type,
89
+ 'to_ping' => $post->to_ping,
90
+ 'menu_order' => $post->menu_order
91
+ );
92
+
93
+ $clone_post_id = wp_insert_post( $args );
94
+
95
+ $taxonomies = get_object_taxonomies($post->post_type);
96
+ if (!empty($taxonomies) && is_array($taxonomies)){
97
+ foreach ($taxonomies as $taxonomy) {
98
+ $post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
99
+ wp_set_object_terms($clone_post_id, $post_terms, $taxonomy, false);
100
+ }
101
+ }
102
+
103
+ $post_meta_data = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
104
+ if (count($post_meta_data)!=0) {
105
+ $clone_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
106
+ foreach ($post_meta_data as $meta_data) {
107
+ $meta_key = sanitize_text_field($meta_data->meta_key);
108
+ $meta_value = addslashes($meta_data->meta_value);
109
+ $clone_query_select[]= "SELECT $clone_post_id, '$meta_key', '$meta_value'";
110
+ }
111
+ $clone_query.= implode(" UNION ALL ", $clone_query_select);
112
+ $wpdb->query($clone_query);
113
+ }
114
+
115
+ wp_redirect(admin_url('edit.php?post_type='.$post->post_type));
116
+ exit;
117
+
118
+ } else {
119
+
120
+ wp_die(__('Post or Page creation failed, could not find original post:', 'wp-post-page-clone') . $post_id);
121
+
122
+ }
123
+
124
+ } else {
125
+ wp_die('Security issue occure, Please try again!.');
126
+ }
127
+
128
+ }
129
+
130
+ }
131
+
132
+ add_action( 'admin_action_wp_post_page_clone', 'wp_post_page_clone' );
133
+
134
+
135
+ if(!function_exists('wp_post_page_link')) {
136
+
137
+ /**
138
+ * Add the duplicate link to action list for post_row_actions
139
+ * @param string $actions
140
+ * @param type $post
141
+ * @return string
142
+ */
143
+ function wp_post_page_link( $actions, $post ) {
144
+
145
+ if (current_user_can('edit_posts')) {
146
+ $actions['clone'] = '<a href="admin.php?action=wp_post_page_clone&amp;post=' . $post->ID . '&amp;nonce='.wp_create_nonce( 'wp-post-page-clone-'.$post->ID ).'" title="'.__('Clone Post and Page', 'wp-post-page-clone').'" rel="permalink">'.__('Click To Clone', 'wp-post-page-clone').'</a>';
147
+ }
148
+
149
+ return $actions;
150
+ }
151
+
152
+ }
153
+
154
+ /**
155
+ * Filter for post / page row actions
156
+ */
157
+ add_filter( 'post_row_actions', 'wp_post_page_link', 10, 2 );
158
+ add_filter('page_row_actions', 'wp_post_page_link', 10, 2);
159
+
160
+ ?>