Duplicate Post - Version 4.4

Version Description

(2022-01-25) =

Enhancements:

  • Converts the upgrade notice into a welcome notice for first-time users.

Bugfixes:

  • Fixes a bug where HTML tags in a Custom HTML block would be removed when republishing a scheduled Rewrite & Republish copy.
  • Fixes a bug where the button style would be broken in the Classic Editor.
  • Fixes a bug where a fatal error would be triggered in the Widgets page in combination with some themes or plugins.

Other: * Sets the WordPress tested up to version to 5.9.

Download this release

Release Info

Developer lopo
Plugin Icon 128x128 Duplicate Post
Version 4.4
Comparing to
See all releases

Code changes from version 4.3 to 4.4

admin-functions.php CHANGED
@@ -98,6 +98,10 @@ function duplicate_post_plugin_upgrade() {
98
  $role->add_cap( 'copy_posts' );
99
  }
100
  }
 
 
 
 
101
  }
102
 
103
  $show_links_in_defaults = [
@@ -163,11 +167,6 @@ function duplicate_post_plugin_upgrade() {
163
  }
164
  update_option( 'duplicate_post_blacklist', implode( ',', $meta_blacklist ) );
165
 
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
-
171
  if ( version_compare( $installed_version, '4.0.0' ) < 0 ) {
172
  // Migrate the 'Show links in' options to the new array-based structure.
173
  duplicate_post_migrate_show_links_in_options( $show_links_in_defaults );
@@ -203,7 +202,7 @@ function duplicate_post_migrate_show_links_in_options( $defaults ) {
203
  }
204
 
205
  /**
206
- * Shows the update notice.
207
  *
208
  * @global string $wp_version The WordPress version string.
209
  */
@@ -220,43 +219,21 @@ function duplicate_post_show_update_notice() {
220
  return;
221
  }
222
 
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 );
253
 
254
  $img_path = plugins_url( '/duplicate_post_yoast_icon-125x125.png', __FILE__ );
255
 
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>';
 
 
 
260
 
261
  echo "<script>
262
  function duplicate_post_dismiss_notice(){
98
  $role->add_cap( 'copy_posts' );
99
  }
100
  }
101
+ add_option( 'duplicate_post_show_notice', 1 );
102
+ }
103
+ else {
104
+ update_option( 'duplicate_post_show_notice', 0 );
105
  }
106
 
107
  $show_links_in_defaults = [
167
  }
168
  update_option( 'duplicate_post_blacklist', implode( ',', $meta_blacklist ) );
169
 
 
 
 
 
 
170
  if ( version_compare( $installed_version, '4.0.0' ) < 0 ) {
171
  // Migrate the 'Show links in' options to the new array-based structure.
172
  duplicate_post_migrate_show_links_in_options( $show_links_in_defaults );
202
  }
203
 
204
  /**
205
+ * Shows the welcome notice.
206
  *
207
  * @global string $wp_version The WordPress version string.
208
  */
219
  return;
220
  }
221
 
222
+ $title = sprintf(
223
+ /* translators: %s: Yoast Duplicate Post. */
224
+ esc_html__( 'You\'ve successfully installed %s!', 'duplicate-post' ),
225
+ 'Yoast Duplicate Post'
226
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
 
228
  $img_path = plugins_url( '/duplicate_post_yoast_icon-125x125.png', __FILE__ );
229
 
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>';
237
 
238
  echo "<script>
239
  function duplicate_post_dismiss_notice(){
duplicate-post.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin Name: Yoast Duplicate Post
10
  * Plugin URI: https://yoast.com/wordpress/plugins/duplicate-post/
11
  * Description: The go-to tool for cloning posts and pages, including the powerful Rewrite & Republish feature.
12
- * Version: 4.3
13
  * Author: Enrico Battocchi & Team Yoast
14
  * Author URI: https://yoast.com
15
  * Text Domain: duplicate-post
@@ -45,7 +45,7 @@ if ( ! defined( 'DUPLICATE_POST_PATH' ) ) {
45
  define( 'DUPLICATE_POST_PATH', plugin_dir_path( __FILE__ ) );
46
  }
47
 
48
- define( 'DUPLICATE_POST_CURRENT_VERSION', '4.3' );
49
 
50
  $duplicate_post_autoload_file = DUPLICATE_POST_PATH . 'vendor/autoload.php';
51
 
9
  * Plugin Name: Yoast Duplicate Post
10
  * Plugin URI: https://yoast.com/wordpress/plugins/duplicate-post/
11
  * Description: The go-to tool for cloning posts and pages, including the powerful Rewrite & Republish feature.
12
+ * Version: 4.4
13
  * Author: Enrico Battocchi & Team Yoast
14
  * Author URI: https://yoast.com
15
  * Text Domain: duplicate-post
45
  define( 'DUPLICATE_POST_PATH', plugin_dir_path( __FILE__ ) );
46
  }
47
 
48
+ define( 'DUPLICATE_POST_CURRENT_VERSION', '4.4' );
49
 
50
  $duplicate_post_autoload_file = DUPLICATE_POST_PATH . 'vendor/autoload.php';
51
 
js/dist/{duplicate-post-edit-430.js → duplicate-post-edit-440.js} RENAMED
@@ -1 +1 @@
1
- !function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.wp.i18n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.redirectOnSaveCompletion=void 0;var i=r(0),n=function(e){var t=(0,i.select)("core/editor").getCurrentPostAttribute("status"),r=(0,i.select)("core/editor").getEditedPostAttribute("status");"dp-rewrite-republish"===t&&"publish"===r&&(0,i.dispatch)("core/editor").editPost({status:t}),window.location.assign(e)};t.redirectOnSaveCompletion=function(e,t){var r=(0,i.select)("core/editor").isSavingPost(),o=(0,i.select)("core/editor").isAutosavingPost(),s=(0,i.select)("core/edit-post").hasMetaBoxes(),a=(0,i.select)("core/edit-post").isSavingMetaBoxes();return s&&!a&&t.wasSavingMetaboxes&&n(e),s||r||!t.wasSavingPost||t.wasAutoSavingPost||n(e),{isSavingPost:r,isSavingMetaBoxes:a,isAutosavingPost:o}}},function(e,t,r){"use strict";var i=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],i=!0,n=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);i=!0);}catch(e){n=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(n)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},n=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),o=r(6),s=r(7),a=r(1),u=r(2),l=r(3),c=r(0),d=r(4);var p=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.renderNotices(),this.removeSlugSidebarPanel()}return n(e,[{key:"handleRedirect",value:function(){var e=this;if(parseInt(duplicatePost.rewriting,10)){var t=!1,r=!1,i=!1;(0,c.subscribe)((function(){if(e.isSafeRedirectURL(duplicatePost.originalEditURL)&&e.isCopyAllowedToBeRepublished()){var n=(0,d.redirectOnSaveCompletion)(duplicatePost.originalEditURL,{wasSavingPost:t,wasSavingMetaboxes:r,wasAutoSavingPost:i});t=n.isSavingPost,r=n.isSavingMetaBoxes,i=n.isAutosavingPost}}))}}},{key:"isSafeRedirectURL",value:function(e){var t=document.createElement("a");return t.href=e,!!(/^https?:$/.test(t.protocol)&&/\/wp-admin\/post\.php$/.test(t.pathname)&&/\?action=edit&post=[0-9]+&dprepublished=1&dpcopy=[0-9]+&dpnonce=[a-z0-9]+/i.test(t.search))}},{key:"isCopyAllowedToBeRepublished",value:function(){var e=(0,c.select)("core/editor").getCurrentPostAttribute("status");return"dp-rewrite-republish"===e||"private"===e}},{key:"renderNotices",value:function(){if(duplicatePostNotices&&duplicatePostNotices instanceof Object){var e=!0,t=!1,r=void 0;try{for(var n,o=Object.entries(duplicatePostNotices)[Symbol.iterator]();!(e=(n=o.next()).done);e=!0){var s=n.value,a=i(s,2),u=(a[0],a[1]),l=JSON.parse(u);l.status&&l.text&&(0,c.dispatch)("core/notices").createNotice(l.status,l.text,{isDismissible:l.isDismissible||!0})}}catch(e){t=!0,r=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw r}}}}},{key:"removeSlugSidebarPanel",value:function(){parseInt(duplicatePost.rewriting,10)&&(0,c.dispatch)("core/edit-post").removeEditorPanel("post-link")}},{key:"render",value:function(){var e=(0,c.select)("core/editor").getEditedPostAttribute("status");return"1"===duplicatePost.showLinksIn.submitbox&&wp.element.createElement(a.Fragment,null,""!==duplicatePost.newDraftLink&&"1"===duplicatePost.showLinks.new_draft&&wp.element.createElement(s.PluginPostStatusInfo,null,wp.element.createElement(u.Button,{isTertiary:!0,className:"dp-editor-post-copy-to-draft",href:duplicatePost.newDraftLink},(0,l.__)("Copy to a new draft","duplicate-post"))),"publish"===e&&""!==duplicatePost.rewriteAndRepublishLink&&"1"===duplicatePost.showLinks.rewrite_republish&&wp.element.createElement(s.PluginPostStatusInfo,null,wp.element.createElement(u.Button,{isTertiary:!0,className:"dp-editor-post-rewrite-republish",href:duplicatePost.rewriteAndRepublishLink},(0,l.__)("Rewrite & Republish","duplicate-post"))))}}]),e}());p.handleRedirect(),(0,o.registerPlugin)("duplicate-post",{render:p.render})},function(e,t){e.exports=window.wp.plugins},function(e,t){e.exports=window.wp.editPost}]);
1
+ !function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.wp.i18n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.redirectOnSaveCompletion=void 0;var i=r(0),n=function(e){var t=(0,i.select)("core/editor").getCurrentPostAttribute("status"),r=(0,i.select)("core/editor").getEditedPostAttribute("status");"dp-rewrite-republish"===t&&"publish"===r&&(0,i.dispatch)("core/editor").editPost({status:t}),window.location.assign(e)};t.redirectOnSaveCompletion=function(e,t){var r=(0,i.select)("core/editor").isSavingPost(),o=(0,i.select)("core/editor").isAutosavingPost(),s=(0,i.select)("core/edit-post").hasMetaBoxes(),a=(0,i.select)("core/edit-post").isSavingMetaBoxes();return s&&!a&&t.wasSavingMetaboxes&&n(e),s||r||!t.wasSavingPost||t.wasAutoSavingPost||n(e),{isSavingPost:r,isSavingMetaBoxes:a,isAutosavingPost:o}}},function(e,t,r){"use strict";var i=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],i=!0,n=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);i=!0);}catch(e){n=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(n)throw o}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},n=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),o=r(6),s=r(7),a=r(1),u=r(2),l=r(3),c=r(0),d=r(4);var p=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.renderNotices(),this.removeSlugSidebarPanel()}return n(e,[{key:"handleRedirect",value:function(){var e=this;if(parseInt(duplicatePost.rewriting,10)){var t=!1,r=!1,i=!1;(0,c.subscribe)((function(){if(e.isSafeRedirectURL(duplicatePost.originalEditURL)&&e.isCopyAllowedToBeRepublished()){var n=(0,d.redirectOnSaveCompletion)(duplicatePost.originalEditURL,{wasSavingPost:t,wasSavingMetaboxes:r,wasAutoSavingPost:i});t=n.isSavingPost,r=n.isSavingMetaBoxes,i=n.isAutosavingPost}}))}}},{key:"isSafeRedirectURL",value:function(e){var t=document.createElement("a");return t.href=e,!!(/^https?:$/.test(t.protocol)&&/\/wp-admin\/post\.php$/.test(t.pathname)&&/\?action=edit&post=[0-9]+&dprepublished=1&dpcopy=[0-9]+&dpnonce=[a-z0-9]+/i.test(t.search))}},{key:"isCopyAllowedToBeRepublished",value:function(){var e=(0,c.select)("core/editor").getCurrentPostAttribute("status");return"dp-rewrite-republish"===e||"private"===e}},{key:"renderNotices",value:function(){if(duplicatePostNotices&&duplicatePostNotices instanceof Object){var e=!0,t=!1,r=void 0;try{for(var n,o=Object.entries(duplicatePostNotices)[Symbol.iterator]();!(e=(n=o.next()).done);e=!0){var s=n.value,a=i(s,2),u=(a[0],a[1]),l=JSON.parse(u);l.status&&l.text&&(0,c.dispatch)("core/notices").createNotice(l.status,l.text,{isDismissible:l.isDismissible||!0})}}catch(e){t=!0,r=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw r}}}}},{key:"removeSlugSidebarPanel",value:function(){parseInt(duplicatePost.rewriting,10)&&(0,c.dispatch)("core/edit-post").removeEditorPanel("post-link")}},{key:"render",value:function(){if(!(0,c.select)("core/editor")||!wp.editPost||!wp.editPost.PluginPostStatusInfo)return null;var e=(0,c.select)("core/editor").getEditedPostAttribute("status");return"1"===duplicatePost.showLinksIn.submitbox&&wp.element.createElement(a.Fragment,null,""!==duplicatePost.newDraftLink&&"1"===duplicatePost.showLinks.new_draft&&wp.element.createElement(s.PluginPostStatusInfo,null,wp.element.createElement(u.Button,{isTertiary:!0,className:"dp-editor-post-copy-to-draft",href:duplicatePost.newDraftLink},(0,l.__)("Copy to a new draft","duplicate-post"))),"publish"===e&&""!==duplicatePost.rewriteAndRepublishLink&&"1"===duplicatePost.showLinks.rewrite_republish&&wp.element.createElement(s.PluginPostStatusInfo,null,wp.element.createElement(u.Button,{isTertiary:!0,className:"dp-editor-post-rewrite-republish",href:duplicatePost.rewriteAndRepublishLink},(0,l.__)("Rewrite & Republish","duplicate-post"))))}}]),e}());p.handleRedirect(),(0,o.registerPlugin)("duplicate-post",{render:p.render})},function(e,t){e.exports=window.wp.plugins},function(e,t){e.exports=window.wp.editPost}]);
js/dist/{duplicate-post-elementor-430.js → duplicate-post-elementor-440.js} RENAMED
File without changes
js/dist/{duplicate-post-options-430.js → duplicate-post-options-440.js} RENAMED
File without changes
js/dist/{duplicate-post-quick-edit-430.js → duplicate-post-quick-edit-440.js} RENAMED
File without changes
js/dist/{duplicate-post-strings-430.js → duplicate-post-strings-440.js} RENAMED
File without changes
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: yoast, lopo
3
  Donate link: https://yoast.com/wordpress/plugins/duplicate-post/
4
  Tags: duplicate post, copy, clone
5
- Requires at least: 5.6
6
- Tested up to: 5.8
7
- Stable tag: 4.3
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,21 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you
151
 
152
  == Changelog ==
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  = 4.3 (2021-12-14) =
155
 
156
  Bugfixes:
2
  Contributors: yoast, lopo
3
  Donate link: https://yoast.com/wordpress/plugins/duplicate-post/
4
  Tags: duplicate post, copy, clone
5
+ Requires at least: 5.8
6
+ Tested up to: 6.0
7
+ Stable tag: 4.4
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.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
+
169
  = 4.3 (2021-12-14) =
170
 
171
  Bugfixes:
src/admin/options.php CHANGED
@@ -259,7 +259,7 @@ class Options {
259
  'duplicate_post_show_notice' => [
260
  'tab' => 'display',
261
  'type' => 'checkbox',
262
- 'label' => \__( 'Show update notice', 'duplicate-post' ),
263
  'value' => 1,
264
  ],
265
  'duplicate_post_show_link' => [
259
  'duplicate_post_show_notice' => [
260
  'tab' => 'display',
261
  'type' => 'checkbox',
262
+ 'label' => \__( 'Show welcome notice', 'duplicate-post' ),
263
  'value' => 1,
264
  ],
265
  'duplicate_post_show_link' => [
src/admin/views/options.php CHANGED
@@ -233,7 +233,7 @@ if ( ! \defined( 'DUPLICATE_POST_CURRENT_VERSION' ) ) {
233
  </td>
234
  </tr>
235
  <tr>
236
- <th scope="row"><?php \esc_html_e( 'Update notice', 'duplicate-post' ); ?></th>
237
  <td>
238
  <?php
239
  // phpcs:ignore WordPress.Security.EscapeOutput -- Already escapes correctly.
233
  </td>
234
  </tr>
235
  <tr>
236
+ <th scope="row"><?php \esc_html_e( 'Welcome notice', 'duplicate-post' ); ?></th>
237
  <td>
238
  <?php
239
  // phpcs:ignore WordPress.Security.EscapeOutput -- Already escapes correctly.
src/post-republisher.php CHANGED
@@ -199,7 +199,9 @@ class Post_Republisher {
199
  return;
200
  }
201
 
 
202
  $this->republish( $copy, $original_post );
 
203
  $this->delete_copy( $copy->ID, $original_post->ID );
204
  }
205
 
@@ -324,7 +326,7 @@ class Post_Republisher {
324
  $_POST['ID'] = $original_post->ID;
325
 
326
  // Republish the original post.
327
- $rewritten_post_id = \wp_update_post( \wp_slash( $post_to_be_rewritten ) );
328
 
329
  if ( $rewritten_post_id === 0 ) {
330
  \wp_die( \esc_html__( 'An error occurred while republishing the post.', 'duplicate-post' ) );
199
  return;
200
  }
201
 
202
+ \kses_remove_filters();
203
  $this->republish( $copy, $original_post );
204
+ \kses_init_filters();
205
  $this->delete_copy( $copy->ID, $original_post->ID );
206
  }
207
 
326
  $_POST['ID'] = $original_post->ID;
327
 
328
  // Republish the original post.
329
+ $rewritten_post_id = \wp_update_post( $post_to_be_rewritten );
330
 
331
  if ( $rewritten_post_id === 0 ) {
332
  \wp_die( \esc_html__( 'An error occurred while republishing the post.', 'duplicate-post' ) );
src/ui/block-editor.php CHANGED
@@ -119,6 +119,10 @@ class Block_Editor {
119
  * @return void
120
  */
121
  public function enqueue_block_editor_scripts() {
 
 
 
 
122
  $post = \get_post();
123
 
124
  if ( ! $post instanceof WP_Post ) {
119
  * @return void
120
  */
121
  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
+
126
  $post = \get_post();
127
 
128
  if ( ! $post instanceof WP_Post ) {
src/ui/classic-editor.php CHANGED
@@ -68,7 +68,12 @@ class Classic_Editor {
68
  \add_filter( 'post_updated_messages', [ $this, 'change_scheduled_notice_classic_editor' ], 10, 1 );
69
 
70
  \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_classic_editor_scripts' ] );
71
- \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_classic_editor_styles' ] );
 
 
 
 
 
72
 
73
  // Remove slug editing from Classic Editor.
74
  \add_action( 'add_meta_boxes', [ $this, 'remove_slug_meta_box' ], 10, 2 );
@@ -102,7 +107,7 @@ class Classic_Editor {
102
  $id = \intval( \wp_unslash( $_GET['post'] ) );
103
  $post = \get_post( $id );
104
 
105
- if ( ! \is_null( $post ) && $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
106
  $this->asset_manager->enqueue_styles();
107
  }
108
  }
68
  \add_filter( 'post_updated_messages', [ $this, 'change_scheduled_notice_classic_editor' ], 10, 1 );
69
 
70
  \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_classic_editor_scripts' ] );
71
+ if ( \intval( Utils::get_option( 'duplicate_post_show_link_in', 'submitbox' ) ) === 1 ) {
72
+ if ( \intval( Utils::get_option( 'duplicate_post_show_link', 'new_draft' ) ) === 1
73
+ || \intval( Utils::get_option( 'duplicate_post_show_link', 'rewrite_republish' ) ) === 1 ) {
74
+ \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_classic_editor_styles' ] );
75
+ }
76
+ }
77
 
78
  // Remove slug editing from Classic Editor.
79
  \add_action( 'add_meta_boxes', [ $this, 'remove_slug_meta_box' ], 10, 2 );
107
  $id = \intval( \wp_unslash( $_GET['post'] ) );
108
  $post = \get_post( $id );
109
 
110
+ if ( ! \is_null( $post ) && $this->permissions_helper->should_links_be_displayed( $post ) ) {
111
  $this->asset_manager->enqueue_styles();
112
  }
113
  }
src/ui/newsletter.php CHANGED
@@ -17,19 +17,29 @@ class Newsletter {
17
  $newsletter_form_response = self::newsletter_handle_form();
18
 
19
 
20
- $copy = sprintf(
21
  /* translators: 1: Yoast */
22
- esc_html__(
23
  'If you want to stay up to date about all the exciting developments around Duplicate Post, subscribe to the %1$s newsletter!',
24
  'duplicate-post'
25
  ),
26
  'Yoast'
27
  );
28
 
29
- $email_label = esc_html__( 'Email Address', 'duplicate-post' );
 
 
 
 
 
 
 
 
 
 
30
 
31
  $response_html = '';
32
- if ( is_array( $newsletter_form_response ) ) {
33
  $response_status = $newsletter_form_response['status'];
34
  $response_message = $newsletter_form_response['message'];
35
 
@@ -39,12 +49,15 @@ class Newsletter {
39
  $html = '
40
  <!-- Begin Newsletter Signup Form -->
41
  <form method="post" id="newsletter-subscribe-form" name="newsletter-subscribe-form" novalidate>
42
- ' . wp_nonce_field( 'newsletter', 'newsletter_nonce' ) . '
43
  <p>' . $copy . '</p>
44
- <div class="newsletter-field-group" style="display: flex; align-items: center;">
45
- <label for="newsletter-email" style="margin-right: 4px;"><strong>' . $email_label . '</strong></label>
46
- <input type="email" value="" name="EMAIL" class="required email" id="newsletter-email" style="margin-right: 4px;">
47
- <input type="submit" value="' . esc_attr__( 'Subscribe', 'duplicate-post' ) . '" name="subscribe" id="newsletter-subscribe" class="button">
 
 
 
48
  </div>
49
  ' . $response_html . '
50
  </form>
@@ -57,31 +70,31 @@ class Newsletter {
57
  /**
58
  * Handles and validates Newsletter form.
59
  *
60
- * @return null|array.
61
  */
62
  private static function newsletter_handle_form() {
63
 
64
  //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Already sanitized.
65
- if ( isset( $_POST['newsletter_nonce'] ) && ! wp_verify_nonce( wp_unslash( $_POST['newsletter_nonce'] ), 'newsletter' ) ) {
66
  return [
67
  'status' => 'error',
68
- 'message' => esc_html__( 'Something went wrong. Please try again later.', 'duplicate-post' ),
69
  ];
70
  }
71
 
72
  $email = null;
73
  if ( isset( $_POST['EMAIL'] ) ) {
74
- $email = sanitize_email( wp_unslash( $_POST['EMAIL'] ) );
75
  }
76
 
77
  if ( $email === null ) {
78
  return null;
79
  }
80
 
81
- if ( ! is_email( $email ) ) {
82
  return [
83
  'status' => 'error',
84
- 'message' => esc_html__( 'Please enter valid e-mail address.', 'duplicate-post' ),
85
  ];
86
  }
87
 
@@ -96,7 +109,7 @@ class Newsletter {
96
  * @return array Feedback response.
97
  */
98
  private static function newsletter_subscribe_to_mailblue( $email ) {
99
- $response = wp_remote_post(
100
  'https://my.yoast.com/api/Mailing-list/subscribe',
101
  [
102
  'method' => 'POST',
@@ -110,18 +123,18 @@ class Newsletter {
110
  ]
111
  );
112
 
113
- $wp_remote_retrieve_response_code = wp_remote_retrieve_response_code( $response );
114
 
115
  if ( $wp_remote_retrieve_response_code <= 200 || $wp_remote_retrieve_response_code >= 300 ) {
116
  return [
117
  'status' => 'error',
118
- 'message' => esc_html__( 'Something went wrong. Please try again later.', 'duplicate-post' ),
119
  ];
120
  }
121
 
122
  return [
123
  'status' => 'success',
124
- 'message' => esc_html__( 'You have successfully subscribed to the newsletter. Please check your inbox.', 'duplicate-post' ),
125
  ];
126
  }
127
  }
17
  $newsletter_form_response = self::newsletter_handle_form();
18
 
19
 
20
+ $copy = \sprintf(
21
  /* translators: 1: Yoast */
22
+ \esc_html__(
23
  'If you want to stay up to date about all the exciting developments around Duplicate Post, subscribe to the %1$s newsletter!',
24
  'duplicate-post'
25
  ),
26
  'Yoast'
27
  );
28
 
29
+ $email_label = \esc_html__( 'Email address', 'duplicate-post' );
30
+
31
+ $copy_privacy_policy = sprintf(
32
+ // translators: %1$s and %2$s are replaced by opening and closing anchor tags.
33
+ \esc_html__(
34
+ 'Yoast respects your privacy. Read %1$sour privacy policy%2$s on how we handle your personal information.',
35
+ 'duplicate-post'
36
+ ),
37
+ '<a href="https://yoa.st/4jf" target="_blank">',
38
+ '</a>'
39
+ );
40
 
41
  $response_html = '';
42
+ if ( \is_array( $newsletter_form_response ) ) {
43
  $response_status = $newsletter_form_response['status'];
44
  $response_message = $newsletter_form_response['message'];
45
 
49
  $html = '
50
  <!-- Begin Newsletter Signup Form -->
51
  <form method="post" id="newsletter-subscribe-form" name="newsletter-subscribe-form" novalidate>
52
+ ' . \wp_nonce_field( 'newsletter', 'newsletter_nonce' ) . '
53
  <p>' . $copy . '</p>
54
+ <div class="newsletter-field-group" style="display: flex; flex-direction: column">
55
+ <label for="newsletter-email" style="margin: 0 0 4px 0;"><strong>' . $email_label . '</strong></label>
56
+ <div>
57
+ <input type="email" value="" name="EMAIL" class="required email" id="newsletter-email" style="margin-right: 4px;">
58
+ <input type="submit" value="' . \esc_attr__( 'Subscribe', 'duplicate-post' ) . '" name="subscribe" id="newsletter-subscribe" class="button">
59
+ </div>
60
+ <p style="font-size: 10px;">' . $copy_privacy_policy . '</p>
61
  </div>
62
  ' . $response_html . '
63
  </form>
70
  /**
71
  * Handles and validates Newsletter form.
72
  *
73
+ * @return array|null
74
  */
75
  private static function newsletter_handle_form() {
76
 
77
  //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Already sanitized.
78
+ if ( isset( $_POST['newsletter_nonce'] ) && ! \wp_verify_nonce( \wp_unslash( $_POST['newsletter_nonce'] ), 'newsletter' ) ) {
79
  return [
80
  'status' => 'error',
81
+ 'message' => \esc_html__( 'Something went wrong. Please try again later.', 'duplicate-post' ),
82
  ];
83
  }
84
 
85
  $email = null;
86
  if ( isset( $_POST['EMAIL'] ) ) {
87
+ $email = \sanitize_email( \wp_unslash( $_POST['EMAIL'] ) );
88
  }
89
 
90
  if ( $email === null ) {
91
  return null;
92
  }
93
 
94
+ if ( ! \is_email( $email ) ) {
95
  return [
96
  'status' => 'error',
97
+ 'message' => \esc_html__( 'Please enter valid e-mail address.', 'duplicate-post' ),
98
  ];
99
  }
100
 
109
  * @return array Feedback response.
110
  */
111
  private static function newsletter_subscribe_to_mailblue( $email ) {
112
+ $response = \wp_remote_post(
113
  'https://my.yoast.com/api/Mailing-list/subscribe',
114
  [
115
  'method' => 'POST',
123
  ]
124
  );
125
 
126
+ $wp_remote_retrieve_response_code = \wp_remote_retrieve_response_code( $response );
127
 
128
  if ( $wp_remote_retrieve_response_code <= 200 || $wp_remote_retrieve_response_code >= 300 ) {
129
  return [
130
  'status' => 'error',
131
+ 'message' => \esc_html__( 'Something went wrong. Please try again later.', 'duplicate-post' ),
132
  ];
133
  }
134
 
135
  return [
136
  'status' => 'success',
137
+ 'message' => \esc_html__( 'You have successfully subscribed to the newsletter. Please check your inbox.', 'duplicate-post' ),
138
  ];
139
  }
140
  }
vendor/composer/ClassLoader.php CHANGED
@@ -149,7 +149,7 @@ class ClassLoader
149
 
150
  /**
151
  * @return string[] Array of classname => path
152
- * @psalm-var array<string, string>
153
  */
154
  public function getClassMap()
155
  {
149
 
150
  /**
151
  * @return string[] Array of classname => path
152
+ * @psalm-return array<string, string>
153
  */
154
  public function getClassMap()
155
  {
vendor/composer/installed.php CHANGED
@@ -5,7 +5,7 @@
5
  'type' => 'wordpress-plugin',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => 'b5db272dca4c6df85d84ef5314324848c5563a45',
9
  'name' => 'yoast/duplicate-post',
10
  'dev' => false,
11
  ),
@@ -37,7 +37,7 @@
37
  'type' => 'wordpress-plugin',
38
  'install_path' => __DIR__ . '/../../',
39
  'aliases' => array(),
40
- 'reference' => 'b5db272dca4c6df85d84ef5314324848c5563a45',
41
  'dev_requirement' => false,
42
  ),
43
  ),
5
  'type' => 'wordpress-plugin',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => '03991d8dd34f07bc7859e30aa0f893f0326d6da6',
9
  'name' => 'yoast/duplicate-post',
10
  'dev' => false,
11
  ),
37
  'type' => 'wordpress-plugin',
38
  'install_path' => __DIR__ . '/../../',
39
  'aliases' => array(),
40
+ 'reference' => '03991d8dd34f07bc7859e30aa0f893f0326d6da6',
41
  'dev_requirement' => false,
42
  ),
43
  ),