PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.2.2
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.2.2
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
← All changes | Inc/Modules/PostDuplicator/PostDuplicator.php +21 -36 4.3.0 → 4.0.2.2 View file →
@@ -1,9 +1,9 @@
1 1 <?php
2 2
3 -namespace PXLBSAdminify\Inc\Modules\PostDuplicator;
3 +namespace WPAdminify\Inc\Modules\PostDuplicator;
4 4
5 -use PXLBSAdminify\Inc\Admin\AdminSettings;
5 +use WPAdminify\Inc\Admin\AdminSettings;
6 6 // no direct access allowed
7 7 if (!defined('ABSPATH')) {
8 8 exit;
9 9 }
@@ -28,22 +28,19 @@
28 28 public $options = [];
29 29
30 30 public function __construct()
31 31 {
32 - $this->clone_title = AdminSettings::get_instance()->get('pxlbsadminify_wl_plugin_menu_label');
32 + $this->clone_title = AdminSettings::get_instance()->get('jltwp_adminify_wl_plugin_menu_label');
33 33
34 34 $this->options = (array) AdminSettings::get_instance()->get();
35 35
36 - // Taxonomy duplicator (reads post_duplicator.taxonomies) is a
37 - // Pro-only feature. Pro/Classes/Filters.php registers the
38 - // admin_action and *_row_actions filters when the Pro plugin
39 - // is active.
36 + new TaxonomyDuplicator();
40 37
41 38 // Check Access for User roles
42 - add_action('admin_init', [$this, 'post_duplicator_init']);
39 + add_action('admin_init', [$this, 'adminify_post_duplicator_init']);
43 40 }
44 41
45 - public function post_duplicator_init()
42 + public function adminify_post_duplicator_init()
46 43 {
47 44 $post_types = [];
48 45 if (!empty($this->options['post_duplicator']['post_types'])) {
49 46 $post_types = $this->options['post_duplicator']['post_types'];
@@ -52,19 +49,15 @@
52 49
53 50 if (empty($post_types) || empty(array_intersect($all_post_types, $post_types))) {
54 51 return;
55 52 }
56 -
57 - add_action('admin_action_adminify_duplicate', [$this, 'duplicate_post_as_draft']);
58 - add_filter('post_row_actions', [$this, 'duplicator_row_actions'], 10, 2);
59 - add_filter('page_row_actions', [$this, 'duplicator_row_actions'], 10, 2);
60 53
61 -
62 - // foreach ($post_types as $key => $post_type) {
63 - // if (in_array($post_type, $all_post_types)) {
64 - // add_filter($post_type . '_row_actions', [$this, 'duplicator_row_actions'], 10, 2);
65 - // }
66 - // }
54 + add_action('admin_action_adminify_duplicate', [$this, 'adminify_duplicate_post_as_draft']);
55 + foreach ($post_types as $key => $post_type) {
56 + if (in_array($post_type, $all_post_types)) {
57 + add_filter($post_type . '_row_actions', [$this, 'jltwp_adminify_duplicator_row_actions'], 10, 2);
58 + }
59 + }
67 60 }
68 61
69 62
70 63 /**
@@ -96,26 +89,20 @@
96 89
97 90 /*
98 91 * Add the duplicate link to action list for post_row_actions
99 92 */
100 - public function duplicator_row_actions($actions, $post)
93 + public function jltwp_adminify_duplicator_row_actions($actions, $post)
101 94 {
102 - $post_type = $post->post_type;
103 - $allowed_post_types = $post_types = $this->options['post_duplicator']['post_types'];
104 - if( !in_array($post_type, $allowed_post_types)){
95 + if (!$this->user_can_clone($post)) {
105 96 return $actions;
106 97 }
107 - if (!$this->user_can_clone($post)) {
108 - return $actions;
109 - }
110 -
98 +
111 99 $adminify_duplicate_link = admin_url('admin.php?action=adminify_duplicate&post=' . $post->ID);
112 - $adminify_duplicate_link = wp_nonce_url($adminify_duplicate_link, 'pxlbsadminify_post_duplicator_nonce');
100 + $adminify_duplicate_link = wp_nonce_url($adminify_duplicate_link, 'jltwp_adminify_post_duplicator_nonce');
113 101
114 102 $clone_title = !empty($this->clone_title) ? $this->clone_title : 'Adminify';
115 103 $clone_title = preg_replace('/wp/i', '', $clone_title) . ' Clone';
116 104 $duplicate_title = 'Duplicate this item ' . $post->post_title;
117 - /* translators: 1: Duplicate post URL, 2: Link title attribute, 3: Link text */
118 105 $actions['adminify_duplicate'] = sprintf(__('<a href="%1$s" title="%2$s" rel="permalink">%3$s</a>', 'adminify'), $adminify_duplicate_link, $duplicate_title, $clone_title);
119 106 return $actions;
120 107 }
121 108
@@ -122,9 +109,9 @@
122 109
123 110 /*
124 111 * Function creates post duplicate as a draft and redirects then to the edit post screen
125 112 */
126 - public function duplicate_post_as_draft()
113 + public function adminify_duplicate_post_as_draft()
127 114 {
128 115 global $wpdb;
129 116
130 117 if (!(isset($_GET['post']) || isset($_POST['post']) || (isset($_REQUEST['action']) && 'adminify_duplicate' == $_REQUEST['action']))) {
@@ -134,9 +121,9 @@
134 121 /*
135 122 * Nonce verification
136 123 * Return if nonce is not valid
137 124 */
138 - if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_wpnonce'])), 'pxlbsadminify_post_duplicator_nonce')) {
125 + if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_wpnonce'])), 'jltwp_adminify_post_duplicator_nonce')) {
139 126 return;
140 127 }
141 128
142 129 /*
@@ -146,13 +133,13 @@
146 133 /*
147 134 * and all the original post data then
148 135 */
149 136 $post = get_post($post_id);
150 - if( isset( $_SERVER['HTTP_REFERER']) && str_contains( esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ), 'action=adminify_duplicate' )) {
137 + if( isset( $_SERVER['HTTP_REFERER']) && str_contains( $_SERVER['HTTP_REFERER'], 'action=adminify_duplicate' )) {
151 138 $redirect_url = admin_url('edit.php?post_type=' . $post->post_type);
152 139 wp_safe_redirect($redirect_url);
153 140
154 - // exit;
141 + exit;
155 142 }
156 143
157 144 if (!$this->user_can_clone($post)) {
158 145 return;
@@ -198,10 +185,9 @@
198 185
199 186 /*
200 187 * duplicate all post meta just in two SQL queries
201 188 */
202 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- direct query required for copying all post meta rows; not cached intentionally.
203 - $post_meta_infos = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=%d", $post_id));
189 + $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
204 190 if (count($post_meta_infos) != 0) {
205 191 $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
206 192 foreach ($post_meta_infos as $meta_info) {
207 193 $meta_key = $meta_info->meta_key;
@@ -222,9 +208,8 @@
222 208 $meta_value = $meta_info->meta_value;
223 209 $sql_query_sel[] = $wpdb->prepare('SELECT %d, %s, %s', $new_post_id, $meta_key, $meta_value);
224 210 }
225 211 $sql_query .= implode(' UNION ALL ', $sql_query_sel);
226 - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $sql_query is built from $wpdb->prepare() fragments above; direct query required for bulk meta insert, not cached intentionally.
227 212 $wpdb->query($sql_query);
228 213 }
229 214
230 215 /*