WP Post Page Clone - Version 1.0

Version Description

Download this release

Release Info

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

Version 1.0

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,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, post, posts, page, pages
5
+ Requires at least: 4.0
6
+ Tested up to: 5.3
7
+ Stable tag: 1.0
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 ==
wp-post-page-clone.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0
9
+ Text Domain: wp-post-page-clone
10
+ Requires at least: 4.0
11
+ Tested up to: 5.3
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
+ define('WP_POST_PAGE_CLONE_URL', plugins_url() . '/wp-post-page-clone');
26
+
27
+
28
+ if(!function_exists('wp_post_page_clone_translate')) {
29
+ /**
30
+ * Function for language translations
31
+ */
32
+ function wp_post_page_clone_translate() {
33
+
34
+ load_plugin_textdomain('wp-post-page-clone', false, basename(dirname( __FILE__ ) ) . '/languages' );
35
+
36
+ }
37
+
38
+ }
39
+
40
+ add_action( 'plugins_loaded', 'wp_post_page_clone_translate' );
41
+
42
+
43
+ if(!function_exists('wp_post_page_clone')) {
44
+ /**
45
+ * Function for post / page clone and redirect that post
46
+ * @global type $wpdb
47
+ */
48
+ function wp_post_page_clone(){
49
+
50
+ global $wpdb;
51
+ if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'wp_post_page_clone' == $_REQUEST['action'] ) ) ) {
52
+ wp_die('No post or page to clone has been supplied!');
53
+ }
54
+
55
+ $post_id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']);
56
+ $post = get_post( $post_id );
57
+ $current_user = wp_get_current_user();
58
+ $post_author = $current_user->ID;
59
+
60
+ if (isset( $post ) && $post != null) {
61
+
62
+ $args = array(
63
+ 'comment_status' => $post->comment_status,
64
+ 'ping_status' => $post->ping_status,
65
+ 'post_author' => $post_author,
66
+ 'post_content' => $post->post_content,
67
+ 'post_excerpt' => $post->post_excerpt,
68
+ 'post_name' => $post->post_name,
69
+ 'post_parent' => $post->post_parent,
70
+ 'post_password' => $post->post_password,
71
+ 'post_status' => 'draft',
72
+ 'post_title' => $post->post_title,
73
+ 'post_type' => $post->post_type,
74
+ 'to_ping' => $post->to_ping,
75
+ 'menu_order' => $post->menu_order
76
+ );
77
+
78
+ $clone_post_id = wp_insert_post( $args );
79
+
80
+ $taxonomies = get_object_taxonomies($post->post_type);
81
+ foreach ($taxonomies as $taxonomy) {
82
+ $post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
83
+ wp_set_object_terms($clone_post_id, $post_terms, $taxonomy, false);
84
+ }
85
+
86
+ $post_meta_data = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
87
+ if (count($post_meta_data)!=0) {
88
+ $clone_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
89
+ foreach ($post_meta_data as $meta_data) {
90
+ $meta_key = $meta_data->meta_key;
91
+ $meta_value = addslashes($meta_data->meta_value);
92
+ $clone_query_select[]= "SELECT $clone_post_id, '$meta_key', '$meta_value'";
93
+ }
94
+ $clone_query.= implode(" UNION ALL ", $clone_query_select);
95
+ $wpdb->query($clone_query);
96
+ }
97
+
98
+ wp_redirect( admin_url( 'post.php?action=edit&post=' . $clone_post_id ) );
99
+ exit;
100
+
101
+ } else {
102
+
103
+ wp_die(__('Post or Page creation failed, could not find original post:', 'wp-post-page-clone') . $post_id);
104
+
105
+ }
106
+ }
107
+
108
+ }
109
+
110
+ add_action( 'admin_action_wp_post_page_clone', 'wp_post_page_clone' );
111
+
112
+
113
+ if(!function_exists('wp_post_page_link')) {
114
+
115
+ /**
116
+ * Add the duplicate link to action list for post_row_actions
117
+ * @param string $actions
118
+ * @param type $post
119
+ * @return string
120
+ */
121
+ function wp_post_page_link( $actions, $post ) {
122
+ if (current_user_can('edit_posts')) {
123
+ $actions['clone'] = '<a href="admin.php?action=wp_post_page_clone&amp;post=' . $post->ID . '" title="'.__('Clone Post and Page', 'wp-post-page-clone').'" rel="permalink">'.__('Click To Clone', 'wp-post-page-clone').'</a>';
124
+ }
125
+ return $actions;
126
+ }
127
+
128
+ }
129
+
130
+ /**
131
+ * Filter for post / page row actions
132
+ */
133
+ add_filter( 'post_row_actions', 'wp_post_page_link', 10, 2 );
134
+ add_filter('page_row_actions', 'wp_post_page_link', 10, 2);
135
+
136
+ ?>