Version Description
(2021-01-12) =
Bugfixes:
- Fixes a bug that caused a fatal error when used with some plugins.
Download this release
Release Info
Developer | lopo |
Plugin | Duplicate Post |
Version | 4.0.1 |
Comparing to | |
See all releases |
Code changes from version 4.0 to 4.0.1
- duplicate-post-admin.php +1 -1
- duplicate-post.php +2 -2
- js/dist/{duplicate-post-edit-400.js → duplicate-post-edit-401.js} +0 -0
- js/dist/{duplicate-post-options-400.js → duplicate-post-options-401.js} +0 -0
- js/dist/{duplicate-post-quick-edit-400.js → duplicate-post-quick-edit-401.js} +0 -0
- js/dist/{duplicate-post-strings-400.js → duplicate-post-strings-401.js} +0 -0
- readme.txt +7 -1
- src/class-post-republisher.php +6 -3
- src/handlers/class-bulk-handler.php +21 -17
- src/ui/class-classic-editor.php +9 -4
- src/ui/class-post-list.php +6 -2
- src/ui/class-post-states.php +1 -0
- src/ui/class-row-actions.php +8 -6
duplicate-post-admin.php
CHANGED
@@ -161,7 +161,7 @@ function duplicate_post_plugin_upgrade() {
|
|
161 |
update_option( 'duplicate_post_blacklist', implode( ',', $meta_blacklist ) );
|
162 |
|
163 |
delete_option( 'duplicate_post_show_notice' );
|
164 |
-
if ( version_compare( $installed_version, '
|
165 |
update_site_option( 'duplicate_post_show_notice', 1 );
|
166 |
}
|
167 |
|
161 |
update_option( 'duplicate_post_blacklist', implode( ',', $meta_blacklist ) );
|
162 |
|
163 |
delete_option( 'duplicate_post_show_notice' );
|
164 |
+
if ( version_compare( $installed_version, '4.0.0' ) < 0 ) {
|
165 |
update_site_option( 'duplicate_post_show_notice', 1 );
|
166 |
}
|
167 |
|
duplicate-post.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Yoast Duplicate Post
|
4 |
* Plugin URI: https://yoast.com/wordpress/plugins/duplicate-post/
|
5 |
* Description: Clone posts and pages.
|
6 |
-
* Version: 4.0
|
7 |
* Author: Enrico Battocchi & Team Yoast
|
8 |
* Author URI: https://yoast.com
|
9 |
* Text Domain: duplicate-post
|
@@ -42,7 +42,7 @@ if ( ! defined( 'DUPLICATE_POST_PATH' ) ) {
|
|
42 |
define( 'DUPLICATE_POST_PATH', plugin_dir_path( __FILE__ ) );
|
43 |
}
|
44 |
|
45 |
-
define( 'DUPLICATE_POST_CURRENT_VERSION', '4.0' );
|
46 |
|
47 |
$duplicate_post_autoload_file = __DIR__ . '/vendor/autoload.php';
|
48 |
|
3 |
* Plugin Name: Yoast Duplicate Post
|
4 |
* Plugin URI: https://yoast.com/wordpress/plugins/duplicate-post/
|
5 |
* Description: Clone posts and pages.
|
6 |
+
* Version: 4.0.1
|
7 |
* Author: Enrico Battocchi & Team Yoast
|
8 |
* Author URI: https://yoast.com
|
9 |
* Text Domain: duplicate-post
|
42 |
define( 'DUPLICATE_POST_PATH', plugin_dir_path( __FILE__ ) );
|
43 |
}
|
44 |
|
45 |
+
define( 'DUPLICATE_POST_CURRENT_VERSION', '4.0.1' );
|
46 |
|
47 |
$duplicate_post_autoload_file = __DIR__ . '/vendor/autoload.php';
|
48 |
|
js/dist/{duplicate-post-edit-400.js → duplicate-post-edit-401.js}
RENAMED
File without changes
|
js/dist/{duplicate-post-options-400.js → duplicate-post-options-401.js}
RENAMED
File without changes
|
js/dist/{duplicate-post-quick-edit-400.js → duplicate-post-quick-edit-401.js}
RENAMED
File without changes
|
js/dist/{duplicate-post-strings-400.js → duplicate-post-strings-401.js}
RENAMED
File without changes
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://yoast.com/wordpress/plugins/duplicate-post/
|
|
4 |
Tags: duplicate post, copy, clone
|
5 |
Requires at least: 5.5
|
6 |
Tested up to: 5.6
|
7 |
-
Stable tag: 4.0
|
8 |
Requires PHP: 5.6.20
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -151,6 +151,12 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you
|
|
151 |
|
152 |
== Changelog ==
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
= 4.0 (2021-01-12) =
|
155 |
|
156 |
Enhancements:
|
4 |
Tags: duplicate post, copy, clone
|
5 |
Requires at least: 5.5
|
6 |
Tested up to: 5.6
|
7 |
+
Stable tag: 4.0.1
|
8 |
Requires PHP: 5.6.20
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
151 |
|
152 |
== Changelog ==
|
153 |
|
154 |
+
= 4.0.1 (2021-01-12) =
|
155 |
+
|
156 |
+
Bugfixes:
|
157 |
+
|
158 |
+
* Fixes a bug that caused a fatal error when used with some plugins.
|
159 |
+
|
160 |
= 4.0 (2021-01-12) =
|
161 |
|
162 |
Enhancements:
|
src/class-post-republisher.php
CHANGED
@@ -8,6 +8,8 @@
|
|
8 |
|
9 |
namespace Yoast\WP\Duplicate_Post;
|
10 |
|
|
|
|
|
11 |
/**
|
12 |
* Represents the Post Republisher class.
|
13 |
*/
|
@@ -126,7 +128,8 @@ class Post_Republisher {
|
|
126 |
*/
|
127 |
public function republish_request( $post ) {
|
128 |
if (
|
129 |
-
! $
|
|
|
130 |
|| ! $this->permissions_helper->is_copy_allowed_to_be_republished( $post )
|
131 |
) {
|
132 |
return;
|
@@ -183,8 +186,8 @@ class Post_Republisher {
|
|
183 |
*
|
184 |
* @return void
|
185 |
*/
|
186 |
-
public function republish_scheduled_post(
|
187 |
-
if ( ! $this->permissions_helper->is_rewrite_and_republish_copy( $copy ) ) {
|
188 |
return;
|
189 |
}
|
190 |
|
8 |
|
9 |
namespace Yoast\WP\Duplicate_Post;
|
10 |
|
11 |
+
use WP_Post;
|
12 |
+
|
13 |
/**
|
14 |
* Represents the Post Republisher class.
|
15 |
*/
|
128 |
*/
|
129 |
public function republish_request( $post ) {
|
130 |
if (
|
131 |
+
! $post instanceof WP_Post
|
132 |
+
|| ! $this->permissions_helper->is_rewrite_and_republish_copy( $post )
|
133 |
|| ! $this->permissions_helper->is_copy_allowed_to_be_republished( $post )
|
134 |
) {
|
135 |
return;
|
186 |
*
|
187 |
* @return void
|
188 |
*/
|
189 |
+
public function republish_scheduled_post( $copy ) {
|
190 |
+
if ( ! $copy instanceof WP_Post || ! $this->permissions_helper->is_rewrite_and_republish_copy( $copy ) ) {
|
191 |
return;
|
192 |
}
|
193 |
|
src/handlers/class-bulk-handler.php
CHANGED
@@ -73,7 +73,7 @@ class Bulk_Handler {
|
|
73 |
*
|
74 |
* @return string The URL to redirect to.
|
75 |
*/
|
76 |
-
public function bulk_action_handler( $redirect_to, $doaction,
|
77 |
$redirect_to = $this->clone_bulk_action_handler( $redirect_to, $doaction, $post_ids );
|
78 |
return $this->rewrite_bulk_action_handler( $redirect_to, $doaction, $post_ids );
|
79 |
}
|
@@ -87,18 +87,20 @@ class Bulk_Handler {
|
|
87 |
*
|
88 |
* @return string The URL to redirect to.
|
89 |
*/
|
90 |
-
public function rewrite_bulk_action_handler( $redirect_to, $doaction,
|
91 |
if ( $doaction !== 'duplicate_post_bulk_rewrite_republish' ) {
|
92 |
return $redirect_to;
|
93 |
}
|
94 |
|
95 |
$counter = 0;
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
|
101 |
-
$
|
|
|
|
|
102 |
}
|
103 |
}
|
104 |
}
|
@@ -120,15 +122,17 @@ class Bulk_Handler {
|
|
120 |
}
|
121 |
|
122 |
$counter = 0;
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
if (
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
$
|
|
|
|
|
132 |
}
|
133 |
}
|
134 |
}
|
73 |
*
|
74 |
* @return string The URL to redirect to.
|
75 |
*/
|
76 |
+
public function bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
|
77 |
$redirect_to = $this->clone_bulk_action_handler( $redirect_to, $doaction, $post_ids );
|
78 |
return $this->rewrite_bulk_action_handler( $redirect_to, $doaction, $post_ids );
|
79 |
}
|
87 |
*
|
88 |
* @return string The URL to redirect to.
|
89 |
*/
|
90 |
+
public function rewrite_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
|
91 |
if ( $doaction !== 'duplicate_post_bulk_rewrite_republish' ) {
|
92 |
return $redirect_to;
|
93 |
}
|
94 |
|
95 |
$counter = 0;
|
96 |
+
if ( \is_array( $post_ids ) ) {
|
97 |
+
foreach ( $post_ids as $post_id ) {
|
98 |
+
$post = \get_post( $post_id );
|
99 |
+
if ( ! empty( $post ) && $this->permissions_helper->should_rewrite_and_republish_be_allowed( $post ) ) {
|
100 |
+
$new_post_id = $this->post_duplicator->create_duplicate_for_rewrite_and_republish( $post );
|
101 |
+
if ( ! \is_wp_error( $new_post_id ) ) {
|
102 |
+
$counter ++;
|
103 |
+
}
|
104 |
}
|
105 |
}
|
106 |
}
|
122 |
}
|
123 |
|
124 |
$counter = 0;
|
125 |
+
if ( \is_array( $post_ids ) ) {
|
126 |
+
foreach ( $post_ids as $post_id ) {
|
127 |
+
$post = \get_post( $post_id );
|
128 |
+
if ( ! empty( $post ) && ! $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
|
129 |
+
if ( \intval( \get_option( 'duplicate_post_copychildren' ) !== 1 )
|
130 |
+
|| ! \is_post_type_hierarchical( $post->post_type )
|
131 |
+
|| ( \is_post_type_hierarchical( $post->post_type ) && ! Utils::has_ancestors_marked( $post, $post_ids ) )
|
132 |
+
) {
|
133 |
+
if ( ! \is_wp_error( \duplicate_post_create_duplicate( $post ) ) ) {
|
134 |
+
$counter ++;
|
135 |
+
}
|
136 |
}
|
137 |
}
|
138 |
}
|
src/ui/class-classic-editor.php
CHANGED
@@ -7,6 +7,7 @@
|
|
7 |
|
8 |
namespace Yoast\WP\Duplicate_Post\UI;
|
9 |
|
|
|
10 |
use Yoast\WP\Duplicate_Post\Permissions_Helper;
|
11 |
use Yoast\WP\Duplicate_Post\Utils;
|
12 |
|
@@ -157,7 +158,7 @@ class Classic_Editor {
|
|
157 |
}
|
158 |
|
159 |
if (
|
160 |
-
|
161 |
&& $this->permissions_helper->should_rewrite_and_republish_be_allowed( $post )
|
162 |
&& $this->permissions_helper->should_links_be_displayed( $post )
|
163 |
) {
|
@@ -185,7 +186,7 @@ class Classic_Editor {
|
|
185 |
}
|
186 |
}
|
187 |
|
188 |
-
if (
|
189 |
?>
|
190 |
<div id="check-changes-action">
|
191 |
<?php \esc_html_e( 'Do you want to compare your changes with the original version before merging? Please save any changes first.', 'duplicate-post' ); ?>
|
@@ -295,7 +296,7 @@ class Classic_Editor {
|
|
295 |
return false;
|
296 |
}
|
297 |
|
298 |
-
if (
|
299 |
return false;
|
300 |
}
|
301 |
|
@@ -311,7 +312,7 @@ class Classic_Editor {
|
|
311 |
* @return void
|
312 |
*/
|
313 |
public function remove_slug_meta_box( $post_type, $post ) {
|
314 |
-
if ( $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
|
315 |
\remove_meta_box( 'slugdiv', $post_type, 'normal' );
|
316 |
}
|
317 |
}
|
@@ -328,6 +329,10 @@ class Classic_Editor {
|
|
328 |
* @return string The filtered HTML of the sample permalink slug editor.
|
329 |
*/
|
330 |
public function remove_sample_permalink_slug_editor( $return, $post_id, $new_title, $new_slug, $post ) {
|
|
|
|
|
|
|
|
|
331 |
if ( $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
|
332 |
return '';
|
333 |
}
|
7 |
|
8 |
namespace Yoast\WP\Duplicate_Post\UI;
|
9 |
|
10 |
+
use WP_Post;
|
11 |
use Yoast\WP\Duplicate_Post\Permissions_Helper;
|
12 |
use Yoast\WP\Duplicate_Post\Utils;
|
13 |
|
158 |
}
|
159 |
|
160 |
if (
|
161 |
+
$post instanceof WP_Post
|
162 |
&& $this->permissions_helper->should_rewrite_and_republish_be_allowed( $post )
|
163 |
&& $this->permissions_helper->should_links_be_displayed( $post )
|
164 |
) {
|
186 |
}
|
187 |
}
|
188 |
|
189 |
+
if ( $post instanceof WP_Post && $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
|
190 |
?>
|
191 |
<div id="check-changes-action">
|
192 |
<?php \esc_html_e( 'Do you want to compare your changes with the original version before merging? Please save any changes first.', 'duplicate-post' ); ?>
|
296 |
return false;
|
297 |
}
|
298 |
|
299 |
+
if ( ! $post instanceof WP_Post ) {
|
300 |
return false;
|
301 |
}
|
302 |
|
312 |
* @return void
|
313 |
*/
|
314 |
public function remove_slug_meta_box( $post_type, $post ) {
|
315 |
+
if ( $post instanceof WP_Post && $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
|
316 |
\remove_meta_box( 'slugdiv', $post_type, 'normal' );
|
317 |
}
|
318 |
}
|
329 |
* @return string The filtered HTML of the sample permalink slug editor.
|
330 |
*/
|
331 |
public function remove_sample_permalink_slug_editor( $return, $post_id, $new_title, $new_slug, $post ) {
|
332 |
+
if ( ! $post instanceof WP_Post ) {
|
333 |
+
return $return;
|
334 |
+
}
|
335 |
+
|
336 |
if ( $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
|
337 |
return '';
|
338 |
}
|
src/ui/class-post-list.php
CHANGED
@@ -54,8 +54,8 @@ class Post_List {
|
|
54 |
*
|
55 |
* @return \WP_Query The updated post WordPress query.
|
56 |
*/
|
57 |
-
public function filter_rewrite_and_republish_copies(
|
58 |
-
if ( ! $this->should_filter() ) {
|
59 |
return $query;
|
60 |
}
|
61 |
|
@@ -132,6 +132,10 @@ class Post_List {
|
|
132 |
|
133 |
$current_screen = \get_current_screen();
|
134 |
|
|
|
|
|
|
|
|
|
135 |
return ( $current_screen->base === 'edit' && $this->permissions_helper->is_elementor_active() );
|
136 |
}
|
137 |
}
|
54 |
*
|
55 |
* @return \WP_Query The updated post WordPress query.
|
56 |
*/
|
57 |
+
public function filter_rewrite_and_republish_copies( $query ) {
|
58 |
+
if ( ! $this->should_filter() || ( $query instanceof \WP_Query === false ) ) {
|
59 |
return $query;
|
60 |
}
|
61 |
|
132 |
|
133 |
$current_screen = \get_current_screen();
|
134 |
|
135 |
+
if ( \is_null( $current_screen ) ) {
|
136 |
+
return false;
|
137 |
+
}
|
138 |
+
|
139 |
return ( $current_screen->base === 'edit' && $this->permissions_helper->is_elementor_active() );
|
140 |
}
|
141 |
}
|
src/ui/class-post-states.php
CHANGED
@@ -7,6 +7,7 @@
|
|
7 |
|
8 |
namespace Yoast\WP\Duplicate_Post\UI;
|
9 |
|
|
|
10 |
use Yoast\WP\Duplicate_Post\Permissions_Helper;
|
11 |
use Yoast\WP\Duplicate_Post\Utils;
|
12 |
|
7 |
|
8 |
namespace Yoast\WP\Duplicate_Post\UI;
|
9 |
|
10 |
+
use WP_Post;
|
11 |
use Yoast\WP\Duplicate_Post\Permissions_Helper;
|
12 |
use Yoast\WP\Duplicate_Post\Utils;
|
13 |
|
src/ui/class-row-actions.php
CHANGED
@@ -7,6 +7,7 @@
|
|
7 |
|
8 |
namespace Yoast\WP\Duplicate_Post\UI;
|
9 |
|
|
|
10 |
use Yoast\WP\Duplicate_Post\Permissions_Helper;
|
11 |
use Yoast\WP\Duplicate_Post\Utils;
|
12 |
|
@@ -74,8 +75,8 @@ class Row_Actions {
|
|
74 |
*
|
75 |
* @return array The updated array of actions.
|
76 |
*/
|
77 |
-
public function add_clone_action_link(
|
78 |
-
if ( ! $this->permissions_helper->should_links_be_displayed( $post ) ) {
|
79 |
return $actions;
|
80 |
}
|
81 |
|
@@ -99,8 +100,8 @@ class Row_Actions {
|
|
99 |
*
|
100 |
* @return array The updated array of actions.
|
101 |
*/
|
102 |
-
public function add_new_draft_action_link(
|
103 |
-
if ( ! $this->permissions_helper->should_links_be_displayed( $post ) ) {
|
104 |
return $actions;
|
105 |
}
|
106 |
|
@@ -125,9 +126,10 @@ class Row_Actions {
|
|
125 |
*
|
126 |
* @return array The updated array of actions.
|
127 |
*/
|
128 |
-
public function add_rewrite_and_republish_action_link(
|
129 |
if (
|
130 |
-
! $
|
|
|
131 |
|| ! $this->permissions_helper->should_links_be_displayed( $post )
|
132 |
) {
|
133 |
return $actions;
|
7 |
|
8 |
namespace Yoast\WP\Duplicate_Post\UI;
|
9 |
|
10 |
+
use WP_Post;
|
11 |
use Yoast\WP\Duplicate_Post\Permissions_Helper;
|
12 |
use Yoast\WP\Duplicate_Post\Utils;
|
13 |
|
75 |
*
|
76 |
* @return array The updated array of actions.
|
77 |
*/
|
78 |
+
public function add_clone_action_link( $actions, $post ) {
|
79 |
+
if ( ! $post instanceof WP_Post || ! $this->permissions_helper->should_links_be_displayed( $post ) ) {
|
80 |
return $actions;
|
81 |
}
|
82 |
|
100 |
*
|
101 |
* @return array The updated array of actions.
|
102 |
*/
|
103 |
+
public function add_new_draft_action_link( $actions, $post ) {
|
104 |
+
if ( ! $post instanceof WP_Post || ! $this->permissions_helper->should_links_be_displayed( $post ) ) {
|
105 |
return $actions;
|
106 |
}
|
107 |
|
126 |
*
|
127 |
* @return array The updated array of actions.
|
128 |
*/
|
129 |
+
public function add_rewrite_and_republish_action_link( $actions, $post ) {
|
130 |
if (
|
131 |
+
! $post instanceof WP_Post
|
132 |
+
|| ! $this->permissions_helper->should_rewrite_and_republish_be_allowed( $post )
|
133 |
|| ! $this->permissions_helper->should_links_be_displayed( $post )
|
134 |
) {
|
135 |
return $actions;
|