Skip to content

Commit 9c893b7

Browse files
Merge pull request #221 from Yoast/DUPP-177-welcome-notice
2 parents 59f02de + 847d945 commit 9c893b7

File tree

2 files changed

+31
-44
lines changed

2 files changed

+31
-44
lines changed

admin-functions.php

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ function duplicate_post_plugin_upgrade() {
137137
]
138138
);
139139
add_option( 'duplicate_post_show_link_in', $show_links_in_defaults );
140+
add_option( 'duplicate_post_show_notice', 1 );
140141

141142
$taxonomies_blacklist = get_option( 'duplicate_post_taxonomies_blacklist' );
142143
if ( $taxonomies_blacklist === '' ) {
@@ -163,11 +164,6 @@ function duplicate_post_plugin_upgrade() {
163164
}
164165
update_option( 'duplicate_post_blacklist', implode( ',', $meta_blacklist ) );
165166

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-
171167
if ( version_compare( $installed_version, '4.0.0' ) < 0 ) {
172168
// Migrate the 'Show links in' options to the new array-based structure.
173169
duplicate_post_migrate_show_links_in_options( $show_links_in_defaults );
@@ -220,43 +216,21 @@ function duplicate_post_show_update_notice() {
220216
return;
221217
}
222218

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 );
219+
$title = sprintf(
220+
/* translators: %s: Yoast Duplicate Post. */
221+
esc_html__( 'You\'ve successfully installed %s!', 'duplicate-post' ),
222+
'Yoast Duplicate Post'
223+
);
253224

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

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>';
227+
echo '<div id="duplicate-post-notice" class="notice is-dismissible" style="display: flex; align-items: flex-start;">
228+
<img src="' . esc_url( $img_path ) . '" alt="" style="margin: 1em 1em 1em 0; width: 130px; align-self: center;"/>
229+
<div stle="margin: 0.5em">
230+
<h1 style="font-size: 14px; color: #a4286a; font-weight: 600; margin-top: 8px;">' . $title . '</h1>' // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: escaped properly above.
231+
. Newsletter::newsletter_signup_form() // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: escaped in newsletter.php.
232+
. '</div>
233+
</div>';
260234

261235
echo "<script>
262236
function duplicate_post_dismiss_notice(){

src/ui/newsletter.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ public static function newsletter_signup_form() {
2626
'Yoast'
2727
);
2828

29-
$email_label = \esc_html__( 'Email Address', 'duplicate-post' );
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">',
38+
'</a>'
39+
);
3040

3141
$response_html = '';
3242
if ( \is_array( $newsletter_form_response ) ) {
@@ -41,10 +51,13 @@ public static function newsletter_signup_form() {
4151
<form method="post" id="newsletter-subscribe-form" name="newsletter-subscribe-form" novalidate>
4252
' . \wp_nonce_field( 'newsletter', 'newsletter_nonce' ) . '
4353
<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">
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>
4861
</div>
4962
' . $response_html . '
5063
</form>

0 commit comments

Comments
 (0)