Skip to content

Commit 03991d8

Browse files
Merge branch 'release/4.4'
2 parents 5ae315f + b3ba782 commit 03991d8

15 files changed

+150
-101
lines changed

admin-functions.php

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ function duplicate_post_plugin_upgrade() {
9898
$role->add_cap( 'copy_posts' );
9999
}
100100
}
101+
add_option( 'duplicate_post_show_notice', 1 );
102+
}
103+
else {
104+
update_option( 'duplicate_post_show_notice', 0 );
101105
}
102106

103107
$show_links_in_defaults = [
@@ -163,11 +167,6 @@ function duplicate_post_plugin_upgrade() {
163167
}
164168
update_option( 'duplicate_post_blacklist', implode( ',', $meta_blacklist ) );
165169

166-
delete_option( 'duplicate_post_show_notice' );
167-
if ( version_compare( $installed_version, '4.2.0' ) < 0 ) {
168-
update_site_option( 'duplicate_post_show_notice', 1 );
169-
}
170-
171170
if ( version_compare( $installed_version, '4.0.0' ) < 0 ) {
172171
// Migrate the 'Show links in' options to the new array-based structure.
173172
duplicate_post_migrate_show_links_in_options( $show_links_in_defaults );
@@ -203,7 +202,7 @@ function duplicate_post_migrate_show_links_in_options( $defaults ) {
203202
}
204203

205204
/**
206-
* Shows the update notice.
205+
* Shows the welcome notice.
207206
*
208207
* @global string $wp_version The WordPress version string.
209208
*/
@@ -220,43 +219,21 @@ function duplicate_post_show_update_notice() {
220219
return;
221220
}
222221

223-
$class = 'notice is-dismissible';
224-
$message = '<p><strong>' . sprintf(
225-
/* translators: %s: Yoast Duplicate Post version. */
226-
__( "What's new in Yoast Duplicate Post version %s:", 'duplicate-post' ),
227-
DUPLICATE_POST_CURRENT_VERSION
228-
) . '</strong> ';
229-
$message .= __( 'improved compatibility with PHP 8.0 and fixes for some bugs regarding translations and the Rewrite & Republish feature.', 'duplicate-post' )
230-
. ' ';
231-
232-
$message .= '<a href="https://wordpress.org/plugins/duplicate-post/#developers">'
233-
. sprintf(
234-
/* translators: %s: Yoast Duplicate Post version. */
235-
__( 'Read the changelog', 'duplicate-post' ),
236-
DUPLICATE_POST_CURRENT_VERSION
237-
)
238-
. '</a></p>';
239-
240-
$message .= '<p>%%SIGNUP_FORM%%</p>';
241-
242-
$allowed_tags = [
243-
'a' => [
244-
'href' => [],
245-
],
246-
'br' => [],
247-
'p' => [],
248-
'strong' => [],
249-
];
250-
251-
$sanitized_message = wp_kses( $message, $allowed_tags );
252-
$sanitized_message = str_replace( '%%SIGNUP_FORM%%', Newsletter::newsletter_signup_form(), $sanitized_message );
222+
$title = sprintf(
223+
/* translators: %s: Yoast Duplicate Post. */
224+
esc_html__( 'You\'ve successfully installed %s!', 'duplicate-post' ),
225+
'Yoast Duplicate Post'
226+
);
253227

254228
$img_path = plugins_url( '/duplicate_post_yoast_icon-125x125.png', __FILE__ );
255229

256-
echo '<div id="duplicate-post-notice" class="' . esc_attr( $class ) . '" style="display: flex; align-items: flex-start;">
257-
<img src="' . esc_url( $img_path ) . '" alt="" style="margin: 1.5em 0.5em 1.5em 0;"/>
258-
<div style="margin: 0.5em">' . $sanitized_message // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: escaped properly above.
259-
. '</div></div>';
230+
echo '<div id="duplicate-post-notice" class="notice is-dismissible" style="display: flex; align-items: flex-start;">
231+
<img src="' . esc_url( $img_path ) . '" alt="" style="margin: 1em 1em 1em 0; width: 130px; align-self: center;"/>
232+
<div stle="margin: 0.5em">
233+
<h1 style="font-size: 14px; color: #a4286a; font-weight: 600; margin-top: 8px;">' . $title . '</h1>' // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: escaped properly above.
234+
. Newsletter::newsletter_signup_form() // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: escaped in newsletter.php.
235+
. '</div>
236+
</div>';
260237

261238
echo "<script>
262239
function duplicate_post_dismiss_notice(){

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"require": {
2626
"php": ">=5.6",
27-
"composer/installers": "^1.9.0"
27+
"composer/installers": "^1.12.0"
2828
},
2929
"require-dev": {
3030
"yoast/yoastcs": "^2.2.0",
@@ -58,6 +58,10 @@
5858
]
5959
},
6060
"config": {
61-
"classmap-authoritative": true
61+
"classmap-authoritative": true,
62+
"allow-plugins": {
63+
"dealerdirect/phpcodesniffer-composer-installer": true,
64+
"composer/installers": true
65+
}
6266
}
6367
}

duplicate-post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Plugin Name: Yoast Duplicate Post
1010
* Plugin URI: https://yoast.com/wordpress/plugins/duplicate-post/
1111
* Description: The go-to tool for cloning posts and pages, including the powerful Rewrite & Republish feature.
12-
* Version: 4.3
12+
* Version: 4.4-RC3
1313
* Author: Enrico Battocchi & Team Yoast
1414
* Author URI: https://yoast.com
1515
* Text Domain: duplicate-post
@@ -45,7 +45,7 @@
4545
define( 'DUPLICATE_POST_PATH', plugin_dir_path( __FILE__ ) );
4646
}
4747

48-
define( 'DUPLICATE_POST_CURRENT_VERSION', '4.3' );
48+
define( 'DUPLICATE_POST_CURRENT_VERSION', '4.4-RC3' );
4949

5050
$duplicate_post_autoload_file = DUPLICATE_POST_PATH . 'vendor/autoload.php';
5151

js/src/duplicate-post-edit-script.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ class DuplicatePost {
126126
* @returns {JSX.Element} The rendered links.
127127
*/
128128
render() {
129+
// Don't try to render anything if there is no store.
130+
if ( ! select( 'core/editor' ) || ! ( wp.editPost && wp.editPost.PluginPostStatusInfo ) ) {
131+
return null;
132+
}
133+
129134
const currentPostStatus = select( 'core/editor' ).getEditedPostAttribute( 'status' );
130135

131136
return (

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
"@wordpress/plugins": "^2.23.0"
5454
},
5555
"yoast": {
56-
"pluginVersion": "4.3"
56+
"pluginVersion": "4.4"
5757
}
5858
}

readme.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: yoast, lopo
33
Donate link: https://yoast.com/wordpress/plugins/duplicate-post/
44
Tags: duplicate post, copy, clone
55
Requires at least: 5.6
6-
Tested up to: 5.8
6+
Tested up to: 5.9
77
Stable tag: 4.3
88
Requires PHP: 5.6.20
99
License: GPLv2 or later
@@ -151,6 +151,21 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you
151151

152152
== Changelog ==
153153

154+
= 4.4 (2022-01-25) =
155+
156+
Enhancements:
157+
158+
* Converts the upgrade notice into a welcome notice for first-time users.
159+
160+
Bugfixes:
161+
162+
* Fixes a bug where HTML tags in a Custom HTML block would be removed when republishing a scheduled Rewrite & Republish copy.
163+
* Fixes a bug where the button style would be broken in the Classic Editor.
164+
* Fixes a bug where a fatal error would be triggered in the Widgets page in combination with some themes or plugins.
165+
166+
Other:
167+
* Sets the WordPress tested up to version to 5.9.
168+
154169
= 4.3 (2021-12-14) =
155170

156171
Bugfixes:

src/admin/options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public function get_options() {
259259
'duplicate_post_show_notice' => [
260260
'tab' => 'display',
261261
'type' => 'checkbox',
262-
'label' => \__( 'Show update notice', 'duplicate-post' ),
262+
'label' => \__( 'Show welcome notice', 'duplicate-post' ),
263263
'value' => 1,
264264
],
265265
'duplicate_post_show_link' => [

src/admin/views/options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class="nav-tab"
233233
</td>
234234
</tr>
235235
<tr>
236-
<th scope="row"><?php \esc_html_e( 'Update notice', 'duplicate-post' ); ?></th>
236+
<th scope="row"><?php \esc_html_e( 'Welcome notice', 'duplicate-post' ); ?></th>
237237
<td>
238238
<?php
239239
// phpcs:ignore WordPress.Security.EscapeOutput -- Already escapes correctly.

src/post-republisher.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ public function republish_scheduled_post( $copy ) {
199199
return;
200200
}
201201

202+
\kses_remove_filters();
202203
$this->republish( $copy, $original_post );
204+
\kses_init_filters();
203205
$this->delete_copy( $copy->ID, $original_post->ID );
204206
}
205207

@@ -324,7 +326,7 @@ protected function republish_post_elements( $post, $original_post ) {
324326
$_POST['ID'] = $original_post->ID;
325327

326328
// Republish the original post.
327-
$rewritten_post_id = \wp_update_post( \wp_slash( $post_to_be_rewritten ) );
329+
$rewritten_post_id = \wp_update_post( $post_to_be_rewritten );
328330

329331
if ( $rewritten_post_id === 0 ) {
330332
\wp_die( \esc_html__( 'An error occurred while republishing the post.', 'duplicate-post' ) );

src/ui/block-editor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ public function should_previously_used_keyword_assessment_run() {
119119
* @return void
120120
*/
121121
public function enqueue_block_editor_scripts() {
122+
if ( ! $this->permissions_helper->is_edit_post_screen() && ! $this->permissions_helper->is_new_post_screen() ) {
123+
return;
124+
}
125+
122126
$post = \get_post();
123127

124128
if ( ! $post instanceof WP_Post ) {

0 commit comments

Comments
 (0)