Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/blogs-gentoo:master commit in: plugins/, plugins/akismet/_inc/, plugins/akismet/views/, plugins/akismet/
Date: Mon, 06 Jan 2020 19:38:13
Message-Id: 1578339479.bf29da39d9e10efa8ac88d79d1eabf7ce147f0ca.blueness@gentoo
1 commit: bf29da39d9e10efa8ac88d79d1eabf7ce147f0ca
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 6 19:37:59 2020 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 6 19:37:59 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/blogs-gentoo.git/commit/?id=bf29da39
7
8 Update akismet 4.1.3
9
10 Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
11
12 plugins/akismet.4.1.3.zip | Bin 0 -> 73019 bytes
13 plugins/akismet/_inc/akismet.css | 38 ++++++++++++
14 plugins/akismet/_inc/akismet.js | 64 ++++++++++++++++---
15 plugins/akismet/akismet.php | 4 +-
16 plugins/akismet/class.akismet-admin.php | 27 +++++++-
17 plugins/akismet/class.akismet.php | 2 +
18 plugins/akismet/readme.txt | 16 +++--
19 plugins/akismet/views/activate.php | 8 +++
20 plugins/akismet/views/connect-jp.php | 72 +++++++++++++++++++++
21 plugins/akismet/views/enter.php | 13 ++++
22 plugins/akismet/views/notice.php | 8 ++-
23 plugins/akismet/views/predefined.php | 11 ++++
24 plugins/akismet/views/setup.php | 5 ++
25 plugins/akismet/views/start.php | 107 ++++++--------------------------
26 plugins/akismet/views/title.php | 3 +
27 15 files changed, 271 insertions(+), 107 deletions(-)
28
29 diff --git a/plugins/akismet.4.1.3.zip b/plugins/akismet.4.1.3.zip
30 new file mode 100644
31 index 00000000..2c80e73f
32 Binary files /dev/null and b/plugins/akismet.4.1.3.zip differ
33
34 diff --git a/plugins/akismet/_inc/akismet.css b/plugins/akismet/_inc/akismet.css
35 index bc56f061..fea4eb7b 100644
36 --- a/plugins/akismet/_inc/akismet.css
37 +++ b/plugins/akismet/_inc/akismet.css
38 @@ -546,6 +546,44 @@ table.comments td.comment p a:after {
39 margin-top: 1.5rem;
40 }
41
42 +.akismet-box-header {
43 + max-width: 700px;
44 + margin: 0 auto 40px auto;
45 + line-height: 1.5;
46 +}
47 +
48 +.akismet-box-header h2 {
49 + margin: 1.5rem 10% 0;
50 + font-size: 1.375rem;
51 + font-weight: 700;
52 + color: #000;
53 +}
54 +
55 +.akismet-box .centered {
56 + text-align: center;
57 +}
58 +
59 +.akismet-enter-api-key-box {
60 + margin: 1.5rem 0;
61 +}
62 +
63 +.akismet-box .enter-api-key {
64 + display: none;
65 + margin-top: 1.5rem;
66 +}
67 +
68 +.akismet-box .akismet-toggles {
69 + margin: 3rem 0;
70 +}
71 +
72 +.akismet-box .akismet-ak-connect, .akismet-box .toggle-jp-connect {
73 + display: none;
74 +}
75 +
76 +.akismet-box .enter-api-key p {
77 + padding: 0 1.5rem;
78 +}
79 +
80 .akismet-button, .akismet-button:hover, .akismet-button:visited {
81 background: white;
82 border-color: #c8d7e1;
83
84 diff --git a/plugins/akismet/_inc/akismet.js b/plugins/akismet/_inc/akismet.js
85 index 6cb85e6c..3445a094 100644
86 --- a/plugins/akismet/_inc/akismet.js
87 +++ b/plugins/akismet/_inc/akismet.js
88 @@ -169,6 +169,8 @@ jQuery( function ( $ ) {
89 function akismet_check_for_spam(offset, limit) {
90 var check_for_spam_buttons = $( '.checkforspam' );
91
92 + var nonce = check_for_spam_buttons.data( 'nonce' );
93 +
94 // We show the percentage complete down to one decimal point so even queues with 100k
95 // pending comments will show some progress pretty quickly.
96 var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10;
97 @@ -181,9 +183,16 @@ jQuery( function ( $ ) {
98 {
99 'action': 'akismet_recheck_queue',
100 'offset': offset,
101 - 'limit': limit
102 + 'limit': limit,
103 + 'nonce': nonce
104 },
105 function(result) {
106 + if ( 'error' in result ) {
107 + // An error is only returned in the case of a missing nonce, so we don't need the actual error message.
108 + window.location.href = check_for_spam_buttons.data( 'failure-url' );
109 + return;
110 + }
111 +
112 recheck_count += result.counts.processed;
113 spam_count += result.counts.spam;
114
115 @@ -282,27 +291,64 @@ jQuery( function ( $ ) {
116 /**
117 * Sets the comment form privacy notice display to hide when one clicks Core's dismiss button on the related admin notice.
118 */
119 - $( '#akismet-privacy-notice-admin-notice' ).on( 'click', '.notice-dismiss', function(){
120 - $.ajax({
121 - url: './options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide',
122 - });
123 + $( '#akismet-privacy-notice-admin-notice' ).on( 'click', '.notice-dismiss', function () {
124 + $.ajax( {
125 + url: './options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide',
126 + } );
127 });
128
129 - $( ".akismet-could-be-primary" ).each( function () {
130 + $( '.akismet-could-be-primary' ).each( function () {
131 var form = $( this ).closest( 'form' );
132
133 form.data( 'initial-state', form.serialize() );
134
135 form.on( 'change keyup', function () {
136 var self = $( this );
137 - var submit_button = self.find( ".akismet-could-be-primary" );
138 + var submit_button = self.find( '.akismet-could-be-primary' );
139
140 if ( self.serialize() != self.data( 'initial-state' ) ) {
141 - submit_button.addClass( "akismet-is-primary" );
142 + submit_button.addClass( 'akismet-is-primary' );
143 }
144 else {
145 - submit_button.removeClass( "akismet-is-primary" );
146 + submit_button.removeClass( 'akismet-is-primary' );
147 }
148 } );
149 } );
150 +
151 + /**
152 + * Shows the Enter API key form
153 + */
154 + $( '.akismet-enter-api-key-box a' ).on( 'click', function ( e ) {
155 + e.preventDefault();
156 +
157 + var div = $( '.enter-api-key' );
158 + div.show( 500 );
159 + div.find( 'input[name=key]' ).focus();
160 +
161 + $( this ).hide();
162 + } );
163 +
164 + /**
165 + * Hides the Connect with Jetpack form | Shows the Activate Akismet Account form
166 + */
167 + $( 'a.toggle-ak-connect' ).on( 'click', function ( e ) {
168 + e.preventDefault();
169 +
170 + $( '.akismet-ak-connect' ).slideToggle('slow');
171 + $( 'a.toggle-ak-connect' ).hide();
172 + $( '.akismet-jp-connect' ).hide();
173 + $( 'a.toggle-jp-connect' ).show();
174 + } );
175 +
176 + /**
177 + * Shows the Connect with Jetpack form | Hides the Activate Akismet Account form
178 + */
179 + $( 'a.toggle-jp-connect' ).on( 'click', function ( e ) {
180 + e.preventDefault();
181 +
182 + $( '.akismet-jp-connect' ).slideToggle('slow');
183 + $( 'a.toggle-jp-connect' ).hide();
184 + $( '.akismet-ak-connect' ).hide();
185 + $( 'a.toggle-ak-connect' ).show();
186 + } );
187 });
188
189 diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
190 index 49608e5a..538a7dbc 100644
191 --- a/plugins/akismet/akismet.php
192 +++ b/plugins/akismet/akismet.php
193 @@ -6,7 +6,7 @@
194 Plugin Name: Akismet Anti-Spam
195 Plugin URI: https://akismet.com/
196 Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
197 -Version: 4.1.2
198 +Version: 4.1.3
199 Author: Automattic
200 Author URI: https://automattic.com/wordpress-plugins/
201 License: GPLv2 or later
202 @@ -37,7 +37,7 @@ if ( !function_exists( 'add_action' ) ) {
203 exit;
204 }
205
206 -define( 'AKISMET_VERSION', '4.1.2' );
207 +define( 'AKISMET_VERSION', '4.1.3' );
208 define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
209 define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
210 define( 'AKISMET_DELETE_LIMIT', 100000 );
211
212 diff --git a/plugins/akismet/class.akismet-admin.php b/plugins/akismet/class.akismet-admin.php
213 index f0766ebe..b5e2ef8e 100644
214 --- a/plugins/akismet/class.akismet-admin.php
215 +++ b/plugins/akismet/class.akismet-admin.php
216 @@ -80,6 +80,13 @@ class Akismet_Admin {
217 }
218
219 public static function admin_init() {
220 + if ( get_option( 'Activated_Akismet' ) ) {
221 + delete_option( 'Activated_Akismet' );
222 + if ( ! headers_sent() ) {
223 + wp_redirect( add_query_arg( array( 'page' => 'akismet-key-config', 'view' => 'start' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) ) );
224 + }
225 + }
226 +
227 load_plugin_textdomain( 'akismet' );
228 add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' );
229
230 @@ -396,8 +403,10 @@ class Akismet_Admin {
231 href="' . esc_url( $link ) . '"
232 data-active-label="' . esc_attr( __( 'Checking for Spam', 'akismet' ) ) . '"
233 data-progress-label-format="' . esc_attr( __( '(%1$s%)', 'akismet' ) ) . '"
234 - data-success-url="' . esc_attr( remove_query_arg( 'akismet_recheck', add_query_arg( array( 'akismet_recheck_complete' => 1, 'recheck_count' => urlencode( '__recheck_count__' ), 'spam_count' => urlencode( '__spam_count__' ) ) ) ) ) . '"
235 + data-success-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_error' ), add_query_arg( array( 'akismet_recheck_complete' => 1, 'recheck_count' => urlencode( '__recheck_count__' ), 'spam_count' => urlencode( '__spam_count__' ) ) ) ) ) . '"
236 + data-failure-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_complete' ), add_query_arg( array( 'akismet_recheck_error' => 1 ) ) ) ) . '"
237 data-pending-comment-count="' . esc_attr( $comments_count->moderated ) . '"
238 + data-nonce="' . esc_attr( wp_create_nonce( 'akismet_check_for_spam' ) ) . '"
239 >';
240 echo '<span class="akismet-label">' . esc_html__('Check for Spam', 'akismet') . '</span>';
241 echo '<span class="checkforspam-progress"></span>';
242 @@ -414,6 +423,13 @@ class Akismet_Admin {
243 if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) ) {
244 return;
245 }
246 +
247 + if ( ! wp_verify_nonce( $_POST['nonce'], 'akismet_check_for_spam' ) ) {
248 + wp_send_json( array(
249 + 'error' => __( "You don't have permission to do that."),
250 + ));
251 + return;
252 + }
253
254 $result_counts = self::recheck_queue_portion( empty( $_POST['offset'] ) ? 0 : $_POST['offset'], empty( $_POST['limit'] ) ? 100 : $_POST['limit'] );
255
256 @@ -1061,6 +1077,9 @@ class Akismet_Admin {
257
258 echo '<div class="notice notice-success"><p>' . esc_html( $message ) . '</p></div>';
259 }
260 + else if ( isset( $_GET['akismet_recheck_error'] ) ) {
261 + echo '<div class="notice notice-error"><p>' . esc_html( __( 'Akismet could not recheck your comments for spam.', 'akismet' ) ) . '</p></div>';
262 + }
263
264 $akismet_comment_form_privacy_notice_option = get_option( 'akismet_comment_form_privacy_notice' );
265 if ( ! in_array( $akismet_comment_form_privacy_notice_option, array( 'hide', 'display' ) ) ) {
266 @@ -1108,7 +1127,11 @@ class Akismet_Admin {
267 if ( !class_exists('Jetpack') )
268 return false;
269
270 - Jetpack::load_xml_rpc_client();
271 + if ( defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '7.7', '<' ) ) {
272 + // For version of Jetpack prior to 7.7.
273 + Jetpack::load_xml_rpc_client();
274 + }
275 +
276 $xml = new Jetpack_IXR_ClientMulticall( array( 'user_id' => get_current_user_id() ) );
277
278 $xml->addCall( 'wpcom.getUserID' );
279
280 diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
281 index f24fd63d..01753014 100644
282 --- a/plugins/akismet/class.akismet.php
283 +++ b/plugins/akismet/class.akismet.php
284 @@ -1277,6 +1277,8 @@ p {
285 $message = '<strong>'.sprintf(esc_html__( 'Akismet %s requires WordPress %s or higher.' , 'akismet'), AKISMET_VERSION, AKISMET__MINIMUM_WP_VERSION ).'</strong> '.sprintf(__('Please <a href="%1$s">upgrade WordPress</a> to a current version, or <a href="%2$s">downgrade to version 2.4 of the Akismet plugin</a>.', 'akismet'), 'https://codex.wordpress.org/Upgrading_WordPress', 'https://wordpress.org/extend/plugins/akismet/download/');
286
287 Akismet::bail_on_activation( $message );
288 + } else {
289 + add_option( 'Activated_Akismet', true );
290 }
291 }
292
293
294 diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt
295 index 15526e9a..bf0081a9 100644
296 --- a/plugins/akismet/readme.txt
297 +++ b/plugins/akismet/readme.txt
298 @@ -2,8 +2,8 @@
299 Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau
300 Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
301 Requires at least: 4.0
302 -Tested up to: 5.2
303 -Stable tag: 4.1.2
304 +Tested up to: 5.3
305 +Stable tag: 4.1.3
306 License: GPLv2 or later
307
308 Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content.
309 @@ -20,16 +20,24 @@ Major features in Akismet include:
310 * Moderators can see the number of approved comments for each user.
311 * A discard feature that outright blocks the worst spam, saving you disk space and speeding up your site.
312
313 -PS: You'll need an [Akismet.com API key](https://akismet.com/get/) to use it. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites.
314 +PS: You'll be prompted to get an Akismet.com API key to use it, once activated. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites.
315
316 == Installation ==
317
318 -Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.com API key](https://akismet.com/get/).
319 +Upload the Akismet plugin to your blog, activate it, and then enter your Akismet.com API key.
320
321 1, 2, 3: You're done!
322
323 == Changelog ==
324
325 += 4.1.3 =
326 +*Release Date - 31 October 2019*
327 +
328 +* Prevented an attacker from being able to cause a user to unknowingly recheck their Pending comments for spam.
329 +* Improved compatibility with Jetpack 7.7+.
330 +* Updated the plugin activation page to use consistent language and markup.
331 +* Redirecting users to the Akismet connnection/settings screen upon plugin activation, in an effort to make it easier for people to get setup.
332 +
333 = 4.1.2 =
334 *Release Date - 14 May 2019*
335
336
337 diff --git a/plugins/akismet/views/activate.php b/plugins/akismet/views/activate.php
338 new file mode 100644
339 index 00000000..7be1309c
340 --- /dev/null
341 +++ b/plugins/akismet/views/activate.php
342 @@ -0,0 +1,8 @@
343 +<div class="akismet-box">
344 + <?php Akismet::view( 'title' ); ?>
345 + <?php Akismet::view( 'setup' );?>
346 +</div>
347 +<br/>
348 +<div class="akismet-box">
349 + <?php Akismet::view( 'enter' );?>
350 +</div>
351 \ No newline at end of file
352
353 diff --git a/plugins/akismet/views/connect-jp.php b/plugins/akismet/views/connect-jp.php
354 new file mode 100644
355 index 00000000..5b33999a
356 --- /dev/null
357 +++ b/plugins/akismet/views/connect-jp.php
358 @@ -0,0 +1,72 @@
359 +<?php
360 +
361 +//phpcs:disable VariableAnalysis
362 +// There are "undefined" variables here because they're defined in the code that includes this file as a template.
363 +
364 +?>
365 +<div class="akismet-box">
366 + <?php Akismet::view( 'title' ); ?>
367 + <div class="akismet-jp-connect">
368 + <h3><?php esc_html_e( 'Connect with Jetpack', 'akismet' ); ?></h3><?php
369 + if ( in_array( $akismet_user->status, array( 'no-sub', 'missing' ) ) ) {?>
370 + <p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
371 + <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
372 + <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
373 + <input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
374 + <input type="hidden" name="auto-connect" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
375 + <input type="hidden" name="redirect" value="plugin-signup"/>
376 + <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
377 + </form>
378 + <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
379 + <p><?php
380 + /* translators: %s is the WordPress.com username */
381 + echo sprintf( esc_html( __( 'You are connected as %s.', 'akismet' ) ), '<b>' . esc_html( $akismet_user->user_login ) . '</b>' ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
382 + <?php } elseif ( $akismet_user->status == 'cancelled' ) { ?>
383 + <p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
384 + <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
385 + <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
386 + <input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
387 + <input type="hidden" name="user_id" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
388 + <input type="hidden" name="redirect" value="upgrade"/>
389 + <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
390 + </form>
391 + <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
392 + <p><?php
393 + /* translators: %s is the WordPress.com email address */
394 + echo esc_html( sprintf( __( 'Your subscription for %s is cancelled.' , 'akismet' ), $akismet_user->user_email ) ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
395 + <?php } elseif ( $akismet_user->status == 'suspended' ) { ?>
396 + <div class="akismet-right">
397 + <p><a href="https://akismet.com/contact" class="akismet-button akismet-is-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet' ); ?></a></p>
398 + </div>
399 + <p>
400 + <span class="akismet-alert-text"><?php
401 + /* translators: %s is the WordPress.com email address */
402 + echo esc_html( sprintf( __( 'Your subscription for %s is suspended.' , 'akismet' ), $akismet_user->user_email ) ); ?></span>
403 + <?php esc_html_e( 'No worries! Get in touch and we&#8217;ll sort this out.', 'akismet' ); ?>
404 + </p>
405 + <?php } else { // ask do they want to use akismet account found using jetpack wpcom connection ?>
406 + <p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
407 + <form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="akismet-right">
408 + <input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
409 + <input type="hidden" name="action" value="enter-key">
410 + <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
411 + <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
412 + </form>
413 + <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
414 + <p><?php
415 + /* translators: %s is the WordPress.com username */
416 + echo sprintf( esc_html( __( 'You are connected as %s.', 'akismet' ) ), '<b>' . esc_html( $akismet_user->user_login ) . '</b>' ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
417 + <?php } ?>
418 + </div>
419 + <div class="akismet-ak-connect">
420 + <?php Akismet::view( 'setup' );?>
421 + </div>
422 + <div class="centered akismet-toggles">
423 + <a href="#" class="toggle-jp-connect"><?php esc_html_e( 'Connect with Jetpack' ); ?></a>
424 + <a href="#" class="toggle-ak-connect"><?php esc_html_e( 'Set up a different account' ); ?></a>
425 + </div>
426 +</div>
427 +<br/>
428 +<div class="akismet-box">
429 + <?php Akismet::view( 'enter' );?>
430 +</div>
431 \ No newline at end of file
432
433 diff --git a/plugins/akismet/views/enter.php b/plugins/akismet/views/enter.php
434 new file mode 100644
435 index 00000000..0a79ca97
436 --- /dev/null
437 +++ b/plugins/akismet/views/enter.php
438 @@ -0,0 +1,13 @@
439 +<div class="akismet-enter-api-key-box centered">
440 + <a href="#"><?php esc_html_e( 'Manually enter an API key' ); ?></a>
441 + <div class="enter-api-key">
442 + <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
443 + <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
444 + <input type="hidden" name="action" value="enter-key">
445 + <p style="width: 100%; display: flex; flex-wrap: nowrap; box-sizing: border-box;">
446 + <input id="key" name="key" type="text" size="15" value="" placeholder="<?php esc_attr_e( 'Enter your API key' , 'akismet' ); ?>" class="regular-text code" style="flex-grow: 1; margin-right: 1rem;">
447 + <input type="submit" name="submit" id="submit" class="akismet-button" value="<?php esc_attr_e( 'Connect with API key', 'akismet' );?>">
448 + </p>
449 + </form>
450 + </div>
451 +</div>
452 \ No newline at end of file
453
454 diff --git a/plugins/akismet/views/notice.php b/plugins/akismet/views/notice.php
455 index 7f70fc12..fa098b8b 100644
456 --- a/plugins/akismet/views/notice.php
457 +++ b/plugins/akismet/views/notice.php
458 @@ -1,3 +1,9 @@
459 +<?php
460 +
461 +//phpcs:disable VariableAnalysis
462 +// There are "undefined" variables here because they're defined in the code that includes this file as a template.
463 +
464 +?>
465 <?php if ( $type == 'plugin' ) :?>
466 <div class="updated" id="akismet_setup_prompt">
467 <form name="akismet_activate" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
468 @@ -138,4 +144,4 @@
469 <p><?php esc_html_e( 'To help your site with transparency under privacy laws like the GDPR, Akismet can display a notice to your users under your comment forms. This feature is disabled by default, however, you can turn it on below.', 'akismet' ); ?></p>
470 <p><?php printf( __(' Please <a href="%s">enable</a> or <a href="%s">disable</a> this feature. <a href="%s" id="akismet-privacy-notice-control-notice-info-link" target="_blank">More information</a>.', 'akismet' ), admin_url( apply_filters( 'akismet_comment_form_privacy_notice_url_display', 'options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=display' ) ), admin_url( apply_filters( 'akismet_comment_form_privacy_notice_url_hide', 'options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide' ) ), 'https://akismet.com/privacy/' ); ?></p>
471 </div>
472 -<?php endif;?>
473 +<?php endif;?>
474 \ No newline at end of file
475
476 diff --git a/plugins/akismet/views/predefined.php b/plugins/akismet/views/predefined.php
477 new file mode 100644
478 index 00000000..d978aaff
479 --- /dev/null
480 +++ b/plugins/akismet/views/predefined.php
481 @@ -0,0 +1,11 @@
482 +<div class="akismet-box">
483 + <h2><?php esc_html_e( 'Manual Configuration', 'akismet' ); ?></h2>
484 + <p>
485 + <?php
486 +
487 + /* translators: %s is the wp-config.php file */
488 + echo sprintf( esc_html__( 'An Akismet API key has been defined in the %s file for this site.', 'akismet' ), '<code>wp-config.php</code>' );
489 +
490 + ?>
491 + </p>
492 +</div>
493 \ No newline at end of file
494
495 diff --git a/plugins/akismet/views/setup.php b/plugins/akismet/views/setup.php
496 new file mode 100644
497 index 00000000..d21c89a9
498 --- /dev/null
499 +++ b/plugins/akismet/views/setup.php
500 @@ -0,0 +1,5 @@
501 +<h3><?php esc_html_e( 'Set Up Akismet' , 'akismet' );?></h3>
502 +<div class="akismet-right">
503 + <?php Akismet::view( 'get', array( 'text' => __( 'Set up your Akismet account' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?>
504 +</div>
505 +<p><?php esc_html_e( 'Set up your Akismet account to enable spam filtering on this site.', 'akismet' ); ?></p>
506 \ No newline at end of file
507
508 diff --git a/plugins/akismet/views/start.php b/plugins/akismet/views/start.php
509 index 0ec35fdb..aaff5d66 100644
510 --- a/plugins/akismet/views/start.php
511 +++ b/plugins/akismet/views/start.php
512 @@ -1,3 +1,9 @@
513 +<?php
514 +
515 +//phpcs:disable VariableAnalysis
516 +// There are "undefined" variables here because they're defined in the code that includes this file as a template.
517 +
518 +?>
519 <div id="akismet-plugin-container">
520 <div class="akismet-masthead">
521 <div class="akismet-masthead__inside-container">
522 @@ -7,96 +13,19 @@
523 </div>
524 </div>
525 <div class="akismet-lower">
526 - <?php Akismet_Admin::display_status(); ?>
527 -
528 - <div class="akismet-box">
529 - <h2><?php esc_html_e( 'Eliminate spam from your site', 'akismet' ); ?></h2>
530 - <p><?php esc_html_e( 'Select one of the options below to get started.', 'akismet' ); ?></p>
531 - </div>
532 + <?php Akismet_Admin::display_status();?>
533 <div class="akismet-boxes">
534 - <?php if ( ! Akismet::predefined_api_key() ) { ?>
535 - <?php if ( $akismet_user && in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) { ?>
536 - <?php if ( in_array( $akismet_user->status, array( 'no-sub', 'missing' ) ) ) { ?>
537 - <div class="akismet-box">
538 - <h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
539 - <p><?php esc_html_e( 'Use your Jetpack connection to activate Akismet.', 'akismet' ); ?></p>
540 - <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
541 - <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
542 - <input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
543 - <input type="hidden" name="auto-connect" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
544 - <input type="hidden" name="redirect" value="plugin-signup"/>
545 - <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
546 - </form>
547 - <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
548 - <p><?php echo sprintf( esc_html( __( 'You are connected as %s.', 'akismet' ) ), '<b>' . esc_html( $akismet_user->user_login ) . '</b>' ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
549 - </div>
550 - <?php } elseif ( $akismet_user->status == 'cancelled' ) { ?>
551 - <div class="akismet-box">
552 - <h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
553 - <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
554 - <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
555 - <input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
556 - <input type="hidden" name="user_id" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
557 - <input type="hidden" name="redirect" value="upgrade"/>
558 - <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Reactivate Akismet' , 'akismet' ); ?>"/>
559 - </form>
560 - <p><?php echo esc_html( sprintf( __( 'Your subscription for %s is cancelled.' , 'akismet' ), $akismet_user->user_email ) ); ?></p>
561 - </div>
562 - <?php } elseif ( $akismet_user->status == 'suspended' ) { ?>
563 - <div class="centered akismet-box">
564 - <h3><?php esc_html_e( 'Connected via Jetpack' , 'akismet' ); ?></h3>
565 - <p class="akismet-alert-text"><?php echo esc_html( sprintf( __( 'Your subscription for %s is suspended.' , 'akismet' ), $akismet_user->user_email ) ); ?></p>
566 - <p><?php esc_html_e( 'No worries! Get in touch and we&#8217;ll sort this out.', 'akismet' ); ?></p>
567 - <p><a href="https://akismet.com/contact" class="akismet-button akismet-is-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet' ); ?></a></p>
568 - </div>
569 - <?php } else { // ask do they want to use akismet account found using jetpack wpcom connection ?>
570 - <div class="akismet-box">
571 - <h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
572 - <p><?php esc_html_e( 'Use your Jetpack connection to activate Akismet.', 'akismet' ); ?></p>
573 - <form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="akismet-right">
574 - <input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
575 - <input type="hidden" name="action" value="enter-key">
576 - <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
577 - <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
578 - </form>
579 - <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
580 - <p><?php echo sprintf( esc_html( __( 'You are connected as %s.', 'akismet' ) ), '<b>' . esc_html( $akismet_user->user_login ) . '</b>' ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
581 - </div>
582 - <?php } ?>
583 - <div class="akismet-box">
584 - <h3><?php esc_html_e( 'Or sign up with a different email address', 'akismet' ); ?></h3>
585 - <div class="akismet-right">
586 - <?php Akismet::view( 'get', array( 'text' => __( 'Sign up with a different email address' , 'akismet' ), 'classes' => array( 'akismet-button' ) ) ); ?>
587 - </div>
588 - <p><?php esc_html_e( 'Choose this option to use Akismet independently of your Jetpack connection.', 'akismet' ); ?></p>
589 - </div>
590 - <?php } else { ?>
591 - <div class="akismet-box">
592 - <h3><?php esc_html_e( 'Activate Akismet' , 'akismet' );?></h3>
593 - <div class="akismet-right">
594 - <?php Akismet::view( 'get', array( 'text' => __( 'Get your API key' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?>
595 - </div>
596 - <p><?php esc_html_e( 'Log in or sign up now.', 'akismet' ); ?></p>
597 - </div>
598 - <?php } ?>
599 - <div class="akismet-box">
600 - <h3><?php esc_html_e( 'Or enter an API key', 'akismet' ); ?></h3>
601 - <p><?php esc_html_e( 'Already have your key? Enter it here.', 'akismet' ); ?> <a href="https://docs.akismet.com/getting-started/api-key/" target="_blank"><?php esc_html_e( '(What is an API key?)', 'akismet' ); ?></a></p>
602 - <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
603 - <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
604 - <input type="hidden" name="action" value="enter-key">
605 - <p style="width: 100%; display: flex; flex-wrap: nowrap; box-sizing: border-box;">
606 - <input id="key" name="key" type="text" size="15" value="" class="regular-text code" style="flex-grow: 1; margin-right: 1rem;">
607 - <input type="submit" name="submit" id="submit" class="akismet-button" value="<?php esc_attr_e( 'Connect with API key', 'akismet' );?>">
608 - </p>
609 - </form>
610 - </div>
611 - <?php } else { ?>
612 - <div class="akismet-box">
613 - <h2><?php esc_html_e( 'Manual Configuration', 'akismet' ); ?></h2>
614 - <p><?php echo sprintf( esc_html__( 'An Akismet API key has been defined in the %s file for this site.', 'akismet' ), '<code>wp-config.php</code>' ); ?></p>
615 - </div>
616 - <?php } ?>
617 + <?php
618 +
619 + if ( Akismet::predefined_api_key() ) {
620 + Akismet::view( 'predefined' );
621 + } elseif ( $akismet_user && in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) {
622 + Akismet::view( 'connect-jp', compact( 'akismet_user' ) );
623 + } else {
624 + Akismet::view( 'activate' );
625 + }
626 +
627 + ?>
628 </div>
629 </div>
630 </div>
631 \ No newline at end of file
632
633 diff --git a/plugins/akismet/views/title.php b/plugins/akismet/views/title.php
634 new file mode 100644
635 index 00000000..b5abb414
636 --- /dev/null
637 +++ b/plugins/akismet/views/title.php
638 @@ -0,0 +1,3 @@
639 +<div class="centered akismet-box-header">
640 + <h2><?php esc_html_e( 'Eliminate spam from your site', 'akismet' ); ?></h2>
641 +</div>
642 \ No newline at end of file