summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2020-01-06 14:37:59 -0500
committerAnthony G. Basile <blueness@gentoo.org>2020-01-06 14:37:59 -0500
commitbf29da39d9e10efa8ac88d79d1eabf7ce147f0ca (patch)
treec54352ad0f8e7aa828eb4aa999f1b09e2791ac82
parentUpdate public-post-preview 2.9.0 (diff)
downloadblogs-gentoo-bf29da39d9e10efa8ac88d79d1eabf7ce147f0ca.tar.gz
blogs-gentoo-bf29da39d9e10efa8ac88d79d1eabf7ce147f0ca.tar.bz2
blogs-gentoo-bf29da39d9e10efa8ac88d79d1eabf7ce147f0ca.zip
Update akismet 4.1.3
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-rw-r--r--plugins/akismet.4.1.3.zipbin0 -> 73019 bytes
-rw-r--r--plugins/akismet/_inc/akismet.css38
-rw-r--r--plugins/akismet/_inc/akismet.js64
-rw-r--r--plugins/akismet/akismet.php4
-rw-r--r--plugins/akismet/class.akismet-admin.php27
-rw-r--r--plugins/akismet/class.akismet.php2
-rw-r--r--plugins/akismet/readme.txt16
-rw-r--r--plugins/akismet/views/activate.php8
-rw-r--r--plugins/akismet/views/connect-jp.php72
-rw-r--r--plugins/akismet/views/enter.php13
-rw-r--r--plugins/akismet/views/notice.php8
-rw-r--r--plugins/akismet/views/predefined.php11
-rw-r--r--plugins/akismet/views/setup.php5
-rw-r--r--plugins/akismet/views/start.php107
-rw-r--r--plugins/akismet/views/title.php3
15 files changed, 271 insertions, 107 deletions
diff --git a/plugins/akismet.4.1.3.zip b/plugins/akismet.4.1.3.zip
new file mode 100644
index 00000000..2c80e73f
--- /dev/null
+++ b/plugins/akismet.4.1.3.zip
Binary files differ
diff --git a/plugins/akismet/_inc/akismet.css b/plugins/akismet/_inc/akismet.css
index bc56f061..fea4eb7b 100644
--- a/plugins/akismet/_inc/akismet.css
+++ b/plugins/akismet/_inc/akismet.css
@@ -546,6 +546,44 @@ table.comments td.comment p a:after {
margin-top: 1.5rem;
}
+.akismet-box-header {
+ max-width: 700px;
+ margin: 0 auto 40px auto;
+ line-height: 1.5;
+}
+
+.akismet-box-header h2 {
+ margin: 1.5rem 10% 0;
+ font-size: 1.375rem;
+ font-weight: 700;
+ color: #000;
+}
+
+.akismet-box .centered {
+ text-align: center;
+}
+
+.akismet-enter-api-key-box {
+ margin: 1.5rem 0;
+}
+
+.akismet-box .enter-api-key {
+ display: none;
+ margin-top: 1.5rem;
+}
+
+.akismet-box .akismet-toggles {
+ margin: 3rem 0;
+}
+
+.akismet-box .akismet-ak-connect, .akismet-box .toggle-jp-connect {
+ display: none;
+}
+
+.akismet-box .enter-api-key p {
+ padding: 0 1.5rem;
+}
+
.akismet-button, .akismet-button:hover, .akismet-button:visited {
background: white;
border-color: #c8d7e1;
diff --git a/plugins/akismet/_inc/akismet.js b/plugins/akismet/_inc/akismet.js
index 6cb85e6c..3445a094 100644
--- a/plugins/akismet/_inc/akismet.js
+++ b/plugins/akismet/_inc/akismet.js
@@ -169,6 +169,8 @@ jQuery( function ( $ ) {
function akismet_check_for_spam(offset, limit) {
var check_for_spam_buttons = $( '.checkforspam' );
+ var nonce = check_for_spam_buttons.data( 'nonce' );
+
// We show the percentage complete down to one decimal point so even queues with 100k
// pending comments will show some progress pretty quickly.
var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10;
@@ -181,9 +183,16 @@ jQuery( function ( $ ) {
{
'action': 'akismet_recheck_queue',
'offset': offset,
- 'limit': limit
+ 'limit': limit,
+ 'nonce': nonce
},
function(result) {
+ if ( 'error' in result ) {
+ // An error is only returned in the case of a missing nonce, so we don't need the actual error message.
+ window.location.href = check_for_spam_buttons.data( 'failure-url' );
+ return;
+ }
+
recheck_count += result.counts.processed;
spam_count += result.counts.spam;
@@ -282,27 +291,64 @@ jQuery( function ( $ ) {
/**
* Sets the comment form privacy notice display to hide when one clicks Core's dismiss button on the related admin notice.
*/
- $( '#akismet-privacy-notice-admin-notice' ).on( 'click', '.notice-dismiss', function(){
- $.ajax({
- url: './options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide',
- });
+ $( '#akismet-privacy-notice-admin-notice' ).on( 'click', '.notice-dismiss', function () {
+ $.ajax( {
+ url: './options-general.php?page=akismet-key-config&akismet_comment_form_privacy_notice=hide',
+ } );
});
- $( ".akismet-could-be-primary" ).each( function () {
+ $( '.akismet-could-be-primary' ).each( function () {
var form = $( this ).closest( 'form' );
form.data( 'initial-state', form.serialize() );
form.on( 'change keyup', function () {
var self = $( this );
- var submit_button = self.find( ".akismet-could-be-primary" );
+ var submit_button = self.find( '.akismet-could-be-primary' );
if ( self.serialize() != self.data( 'initial-state' ) ) {
- submit_button.addClass( "akismet-is-primary" );
+ submit_button.addClass( 'akismet-is-primary' );
}
else {
- submit_button.removeClass( "akismet-is-primary" );
+ submit_button.removeClass( 'akismet-is-primary' );
}
} );
} );
+
+ /**
+ * Shows the Enter API key form
+ */
+ $( '.akismet-enter-api-key-box a' ).on( 'click', function ( e ) {
+ e.preventDefault();
+
+ var div = $( '.enter-api-key' );
+ div.show( 500 );
+ div.find( 'input[name=key]' ).focus();
+
+ $( this ).hide();
+ } );
+
+ /**
+ * Hides the Connect with Jetpack form | Shows the Activate Akismet Account form
+ */
+ $( 'a.toggle-ak-connect' ).on( 'click', function ( e ) {
+ e.preventDefault();
+
+ $( '.akismet-ak-connect' ).slideToggle('slow');
+ $( 'a.toggle-ak-connect' ).hide();
+ $( '.akismet-jp-connect' ).hide();
+ $( 'a.toggle-jp-connect' ).show();
+ } );
+
+ /**
+ * Shows the Connect with Jetpack form | Hides the Activate Akismet Account form
+ */
+ $( 'a.toggle-jp-connect' ).on( 'click', function ( e ) {
+ e.preventDefault();
+
+ $( '.akismet-jp-connect' ).slideToggle('slow');
+ $( 'a.toggle-jp-connect' ).hide();
+ $( '.akismet-ak-connect' ).hide();
+ $( 'a.toggle-ak-connect' ).show();
+ } );
});
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
index 49608e5a..538a7dbc 100644
--- a/plugins/akismet/akismet.php
+++ b/plugins/akismet/akismet.php
@@ -6,7 +6,7 @@
Plugin Name: Akismet Anti-Spam
Plugin URI: https://akismet.com/
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.
-Version: 4.1.2
+Version: 4.1.3
Author: Automattic
Author URI: https://automattic.com/wordpress-plugins/
License: GPLv2 or later
@@ -37,7 +37,7 @@ if ( !function_exists( 'add_action' ) ) {
exit;
}
-define( 'AKISMET_VERSION', '4.1.2' );
+define( 'AKISMET_VERSION', '4.1.3' );
define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'AKISMET_DELETE_LIMIT', 100000 );
diff --git a/plugins/akismet/class.akismet-admin.php b/plugins/akismet/class.akismet-admin.php
index f0766ebe..b5e2ef8e 100644
--- a/plugins/akismet/class.akismet-admin.php
+++ b/plugins/akismet/class.akismet-admin.php
@@ -80,6 +80,13 @@ class Akismet_Admin {
}
public static function admin_init() {
+ if ( get_option( 'Activated_Akismet' ) ) {
+ delete_option( 'Activated_Akismet' );
+ if ( ! headers_sent() ) {
+ wp_redirect( add_query_arg( array( 'page' => 'akismet-key-config', 'view' => 'start' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) ) );
+ }
+ }
+
load_plugin_textdomain( 'akismet' );
add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' );
@@ -396,8 +403,10 @@ class Akismet_Admin {
href="' . esc_url( $link ) . '"
data-active-label="' . esc_attr( __( 'Checking for Spam', 'akismet' ) ) . '"
data-progress-label-format="' . esc_attr( __( '(%1$s%)', 'akismet' ) ) . '"
- 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__' ) ) ) ) ) . '"
+ 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__' ) ) ) ) ) . '"
+ data-failure-url="' . esc_attr( remove_query_arg( array( 'akismet_recheck', 'akismet_recheck_complete' ), add_query_arg( array( 'akismet_recheck_error' => 1 ) ) ) ) . '"
data-pending-comment-count="' . esc_attr( $comments_count->moderated ) . '"
+ data-nonce="' . esc_attr( wp_create_nonce( 'akismet_check_for_spam' ) ) . '"
>';
echo '<span class="akismet-label">' . esc_html__('Check for Spam', 'akismet') . '</span>';
echo '<span class="checkforspam-progress"></span>';
@@ -414,6 +423,13 @@ class Akismet_Admin {
if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) ) {
return;
}
+
+ if ( ! wp_verify_nonce( $_POST['nonce'], 'akismet_check_for_spam' ) ) {
+ wp_send_json( array(
+ 'error' => __( "You don't have permission to do that."),
+ ));
+ return;
+ }
$result_counts = self::recheck_queue_portion( empty( $_POST['offset'] ) ? 0 : $_POST['offset'], empty( $_POST['limit'] ) ? 100 : $_POST['limit'] );
@@ -1061,6 +1077,9 @@ class Akismet_Admin {
echo '<div class="notice notice-success"><p>' . esc_html( $message ) . '</p></div>';
}
+ else if ( isset( $_GET['akismet_recheck_error'] ) ) {
+ echo '<div class="notice notice-error"><p>' . esc_html( __( 'Akismet could not recheck your comments for spam.', 'akismet' ) ) . '</p></div>';
+ }
$akismet_comment_form_privacy_notice_option = get_option( 'akismet_comment_form_privacy_notice' );
if ( ! in_array( $akismet_comment_form_privacy_notice_option, array( 'hide', 'display' ) ) ) {
@@ -1108,7 +1127,11 @@ class Akismet_Admin {
if ( !class_exists('Jetpack') )
return false;
- Jetpack::load_xml_rpc_client();
+ if ( defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '7.7', '<' ) ) {
+ // For version of Jetpack prior to 7.7.
+ Jetpack::load_xml_rpc_client();
+ }
+
$xml = new Jetpack_IXR_ClientMulticall( array( 'user_id' => get_current_user_id() ) );
$xml->addCall( 'wpcom.getUserID' );
diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
index f24fd63d..01753014 100644
--- a/plugins/akismet/class.akismet.php
+++ b/plugins/akismet/class.akismet.php
@@ -1277,6 +1277,8 @@ p {
$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/');
Akismet::bail_on_activation( $message );
+ } else {
+ add_option( 'Activated_Akismet', true );
}
}
diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt
index 15526e9a..bf0081a9 100644
--- a/plugins/akismet/readme.txt
+++ b/plugins/akismet/readme.txt
@@ -2,8 +2,8 @@
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau
Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
Requires at least: 4.0
-Tested up to: 5.2
-Stable tag: 4.1.2
+Tested up to: 5.3
+Stable tag: 4.1.3
License: GPLv2 or later
Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content.
@@ -20,16 +20,24 @@ Major features in Akismet include:
* Moderators can see the number of approved comments for each user.
* A discard feature that outright blocks the worst spam, saving you disk space and speeding up your site.
-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.
+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.
== Installation ==
-Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.com API key](https://akismet.com/get/).
+Upload the Akismet plugin to your blog, activate it, and then enter your Akismet.com API key.
1, 2, 3: You're done!
== Changelog ==
+= 4.1.3 =
+*Release Date - 31 October 2019*
+
+* Prevented an attacker from being able to cause a user to unknowingly recheck their Pending comments for spam.
+* Improved compatibility with Jetpack 7.7+.
+* Updated the plugin activation page to use consistent language and markup.
+* Redirecting users to the Akismet connnection/settings screen upon plugin activation, in an effort to make it easier for people to get setup.
+
= 4.1.2 =
*Release Date - 14 May 2019*
diff --git a/plugins/akismet/views/activate.php b/plugins/akismet/views/activate.php
new file mode 100644
index 00000000..7be1309c
--- /dev/null
+++ b/plugins/akismet/views/activate.php
@@ -0,0 +1,8 @@
+<div class="akismet-box">
+ <?php Akismet::view( 'title' ); ?>
+ <?php Akismet::view( 'setup' );?>
+</div>
+<br/>
+<div class="akismet-box">
+ <?php Akismet::view( 'enter' );?>
+</div> \ No newline at end of file
diff --git a/plugins/akismet/views/connect-jp.php b/plugins/akismet/views/connect-jp.php
new file mode 100644
index 00000000..5b33999a
--- /dev/null
+++ b/plugins/akismet/views/connect-jp.php
@@ -0,0 +1,72 @@
+<?php
+
+//phpcs:disable VariableAnalysis
+// There are "undefined" variables here because they're defined in the code that includes this file as a template.
+
+?>
+<div class="akismet-box">
+ <?php Akismet::view( 'title' ); ?>
+ <div class="akismet-jp-connect">
+ <h3><?php esc_html_e( 'Connect with Jetpack', 'akismet' ); ?></h3><?php
+ if ( in_array( $akismet_user->status, array( 'no-sub', 'missing' ) ) ) {?>
+ <p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
+ <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
+ <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
+ <input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
+ <input type="hidden" name="auto-connect" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
+ <input type="hidden" name="redirect" value="plugin-signup"/>
+ <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
+ </form>
+ <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
+ <p><?php
+ /* translators: %s is the WordPress.com username */
+ 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>
+ <?php } elseif ( $akismet_user->status == 'cancelled' ) { ?>
+ <p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
+ <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
+ <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
+ <input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
+ <input type="hidden" name="user_id" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
+ <input type="hidden" name="redirect" value="upgrade"/>
+ <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
+ </form>
+ <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
+ <p><?php
+ /* translators: %s is the WordPress.com email address */
+ 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>
+ <?php } elseif ( $akismet_user->status == 'suspended' ) { ?>
+ <div class="akismet-right">
+ <p><a href="https://akismet.com/contact" class="akismet-button akismet-is-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet' ); ?></a></p>
+ </div>
+ <p>
+ <span class="akismet-alert-text"><?php
+ /* translators: %s is the WordPress.com email address */
+ echo esc_html( sprintf( __( 'Your subscription for %s is suspended.' , 'akismet' ), $akismet_user->user_email ) ); ?></span>
+ <?php esc_html_e( 'No worries! Get in touch and we&#8217;ll sort this out.', 'akismet' ); ?>
+ </p>
+ <?php } else { // ask do they want to use akismet account found using jetpack wpcom connection ?>
+ <p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
+ <form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="akismet-right">
+ <input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
+ <input type="hidden" name="action" value="enter-key">
+ <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
+ <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
+ </form>
+ <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
+ <p><?php
+ /* translators: %s is the WordPress.com username */
+ 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>
+ <?php } ?>
+ </div>
+ <div class="akismet-ak-connect">
+ <?php Akismet::view( 'setup' );?>
+ </div>
+ <div class="centered akismet-toggles">
+ <a href="#" class="toggle-jp-connect"><?php esc_html_e( 'Connect with Jetpack' ); ?></a>
+ <a href="#" class="toggle-ak-connect"><?php esc_html_e( 'Set up a different account' ); ?></a>
+ </div>
+</div>
+<br/>
+<div class="akismet-box">
+ <?php Akismet::view( 'enter' );?>
+</div> \ No newline at end of file
diff --git a/plugins/akismet/views/enter.php b/plugins/akismet/views/enter.php
new file mode 100644
index 00000000..0a79ca97
--- /dev/null
+++ b/plugins/akismet/views/enter.php
@@ -0,0 +1,13 @@
+<div class="akismet-enter-api-key-box centered">
+ <a href="#"><?php esc_html_e( 'Manually enter an API key' ); ?></a>
+ <div class="enter-api-key">
+ <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
+ <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
+ <input type="hidden" name="action" value="enter-key">
+ <p style="width: 100%; display: flex; flex-wrap: nowrap; box-sizing: border-box;">
+ <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;">
+ <input type="submit" name="submit" id="submit" class="akismet-button" value="<?php esc_attr_e( 'Connect with API key', 'akismet' );?>">
+ </p>
+ </form>
+ </div>
+</div> \ No newline at end of file
diff --git a/plugins/akismet/views/notice.php b/plugins/akismet/views/notice.php
index 7f70fc12..fa098b8b 100644
--- a/plugins/akismet/views/notice.php
+++ b/plugins/akismet/views/notice.php
@@ -1,3 +1,9 @@
+<?php
+
+//phpcs:disable VariableAnalysis
+// There are "undefined" variables here because they're defined in the code that includes this file as a template.
+
+?>
<?php if ( $type == 'plugin' ) :?>
<div class="updated" id="akismet_setup_prompt">
<form name="akismet_activate" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
@@ -138,4 +144,4 @@
<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>
<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>
</div>
-<?php endif;?>
+<?php endif;?> \ No newline at end of file
diff --git a/plugins/akismet/views/predefined.php b/plugins/akismet/views/predefined.php
new file mode 100644
index 00000000..d978aaff
--- /dev/null
+++ b/plugins/akismet/views/predefined.php
@@ -0,0 +1,11 @@
+<div class="akismet-box">
+ <h2><?php esc_html_e( 'Manual Configuration', 'akismet' ); ?></h2>
+ <p>
+ <?php
+
+ /* translators: %s is the wp-config.php file */
+ 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>
+</div> \ No newline at end of file
diff --git a/plugins/akismet/views/setup.php b/plugins/akismet/views/setup.php
new file mode 100644
index 00000000..d21c89a9
--- /dev/null
+++ b/plugins/akismet/views/setup.php
@@ -0,0 +1,5 @@
+<h3><?php esc_html_e( 'Set Up Akismet' , 'akismet' );?></h3>
+<div class="akismet-right">
+ <?php Akismet::view( 'get', array( 'text' => __( 'Set up your Akismet account' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?>
+</div>
+<p><?php esc_html_e( 'Set up your Akismet account to enable spam filtering on this site.', 'akismet' ); ?></p> \ No newline at end of file
diff --git a/plugins/akismet/views/start.php b/plugins/akismet/views/start.php
index 0ec35fdb..aaff5d66 100644
--- a/plugins/akismet/views/start.php
+++ b/plugins/akismet/views/start.php
@@ -1,3 +1,9 @@
+<?php
+
+//phpcs:disable VariableAnalysis
+// There are "undefined" variables here because they're defined in the code that includes this file as a template.
+
+?>
<div id="akismet-plugin-container">
<div class="akismet-masthead">
<div class="akismet-masthead__inside-container">
@@ -7,96 +13,19 @@
</div>
</div>
<div class="akismet-lower">
- <?php Akismet_Admin::display_status(); ?>
-
- <div class="akismet-box">
- <h2><?php esc_html_e( 'Eliminate spam from your site', 'akismet' ); ?></h2>
- <p><?php esc_html_e( 'Select one of the options below to get started.', 'akismet' ); ?></p>
- </div>
+ <?php Akismet_Admin::display_status();?>
<div class="akismet-boxes">
- <?php if ( ! Akismet::predefined_api_key() ) { ?>
- <?php if ( $akismet_user && in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) { ?>
- <?php if ( in_array( $akismet_user->status, array( 'no-sub', 'missing' ) ) ) { ?>
- <div class="akismet-box">
- <h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
- <p><?php esc_html_e( 'Use your Jetpack connection to activate Akismet.', 'akismet' ); ?></p>
- <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
- <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
- <input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
- <input type="hidden" name="auto-connect" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
- <input type="hidden" name="redirect" value="plugin-signup"/>
- <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
- </form>
- <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
- <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>
- </div>
- <?php } elseif ( $akismet_user->status == 'cancelled' ) { ?>
- <div class="akismet-box">
- <h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
- <form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
- <input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
- <input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
- <input type="hidden" name="user_id" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
- <input type="hidden" name="redirect" value="upgrade"/>
- <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Reactivate Akismet' , 'akismet' ); ?>"/>
- </form>
- <p><?php echo esc_html( sprintf( __( 'Your subscription for %s is cancelled.' , 'akismet' ), $akismet_user->user_email ) ); ?></p>
- </div>
- <?php } elseif ( $akismet_user->status == 'suspended' ) { ?>
- <div class="centered akismet-box">
- <h3><?php esc_html_e( 'Connected via Jetpack' , 'akismet' ); ?></h3>
- <p class="akismet-alert-text"><?php echo esc_html( sprintf( __( 'Your subscription for %s is suspended.' , 'akismet' ), $akismet_user->user_email ) ); ?></p>
- <p><?php esc_html_e( 'No worries! Get in touch and we&#8217;ll sort this out.', 'akismet' ); ?></p>
- <p><a href="https://akismet.com/contact" class="akismet-button akismet-is-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet' ); ?></a></p>
- </div>
- <?php } else { // ask do they want to use akismet account found using jetpack wpcom connection ?>
- <div class="akismet-box">
- <h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
- <p><?php esc_html_e( 'Use your Jetpack connection to activate Akismet.', 'akismet' ); ?></p>
- <form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="akismet-right">
- <input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
- <input type="hidden" name="action" value="enter-key">
- <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
- <input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
- </form>
- <?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
- <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>
- </div>
- <?php } ?>
- <div class="akismet-box">
- <h3><?php esc_html_e( 'Or sign up with a different email address', 'akismet' ); ?></h3>
- <div class="akismet-right">
- <?php Akismet::view( 'get', array( 'text' => __( 'Sign up with a different email address' , 'akismet' ), 'classes' => array( 'akismet-button' ) ) ); ?>
- </div>
- <p><?php esc_html_e( 'Choose this option to use Akismet independently of your Jetpack connection.', 'akismet' ); ?></p>
- </div>
- <?php } else { ?>
- <div class="akismet-box">
- <h3><?php esc_html_e( 'Activate Akismet' , 'akismet' );?></h3>
- <div class="akismet-right">
- <?php Akismet::view( 'get', array( 'text' => __( 'Get your API key' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?>
- </div>
- <p><?php esc_html_e( 'Log in or sign up now.', 'akismet' ); ?></p>
- </div>
- <?php } ?>
- <div class="akismet-box">
- <h3><?php esc_html_e( 'Or enter an API key', 'akismet' ); ?></h3>
- <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>
- <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
- <?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
- <input type="hidden" name="action" value="enter-key">
- <p style="width: 100%; display: flex; flex-wrap: nowrap; box-sizing: border-box;">
- <input id="key" name="key" type="text" size="15" value="" class="regular-text code" style="flex-grow: 1; margin-right: 1rem;">
- <input type="submit" name="submit" id="submit" class="akismet-button" value="<?php esc_attr_e( 'Connect with API key', 'akismet' );?>">
- </p>
- </form>
- </div>
- <?php } else { ?>
- <div class="akismet-box">
- <h2><?php esc_html_e( 'Manual Configuration', 'akismet' ); ?></h2>
- <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>
- </div>
- <?php } ?>
+ <?php
+
+ if ( Akismet::predefined_api_key() ) {
+ Akismet::view( 'predefined' );
+ } elseif ( $akismet_user && in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) {
+ Akismet::view( 'connect-jp', compact( 'akismet_user' ) );
+ } else {
+ Akismet::view( 'activate' );
+ }
+
+ ?>
</div>
</div>
</div> \ No newline at end of file
diff --git a/plugins/akismet/views/title.php b/plugins/akismet/views/title.php
new file mode 100644
index 00000000..b5abb414
--- /dev/null
+++ b/plugins/akismet/views/title.php
@@ -0,0 +1,3 @@
+<div class="centered akismet-box-header">
+ <h2><?php esc_html_e( 'Eliminate spam from your site', 'akismet' ); ?></h2>
+</div> \ No newline at end of file