summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/akismet/class.akismet-admin.php')
-rw-r--r--plugins/akismet/class.akismet-admin.php54
1 files changed, 53 insertions, 1 deletions
diff --git a/plugins/akismet/class.akismet-admin.php b/plugins/akismet/class.akismet-admin.php
index 42e884f9..1e806173 100644
--- a/plugins/akismet/class.akismet-admin.php
+++ b/plugins/akismet/class.akismet-admin.php
@@ -32,6 +32,10 @@ class Akismet_Admin {
if ( isset( $_POST['action'] ) && $_POST['action'] == 'enter-key' ) {
self::enter_api_key();
}
+
+ if ( ! empty( $_GET['akismet_comment_form_privacy_notice'] ) && empty( $_GET['settings-updated']) ) {
+ self::set_form_privacy_notice_option( $_GET['akismet_comment_form_privacy_notice'] );
+ }
}
public static function init_hooks() {
@@ -65,11 +69,23 @@ class Akismet_Admin {
add_filter( 'wxr_export_skip_commentmeta', array( 'Akismet_Admin', 'exclude_commentmeta_from_export' ), 10, 3 );
add_filter( 'all_plugins', array( 'Akismet_Admin', 'modify_plugin_description' ) );
+
+ if ( class_exists( 'Jetpack' ) ) {
+ add_filter( 'akismet_comment_form_privacy_notice_url_display', array( 'Akismet_Admin', 'jetpack_comment_form_privacy_notice_url' ) );
+ add_filter( 'akismet_comment_form_privacy_notice_url_hide', array( 'Akismet_Admin', 'jetpack_comment_form_privacy_notice_url' ) );
+ }
}
public static function admin_init() {
load_plugin_textdomain( 'akismet' );
add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' );
+
+ if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
+ wp_add_privacy_policy_content(
+ __( 'Akismet', 'akismet' ),
+ __( 'We collect information about visitors who comment on Sites that use our Akismet anti-spam service. The information we collect depends on how the User sets up Akismet for the Site, but typically includes the commenter\'s IP address, user agent, referrer, and Site URL (along with other information directly provided by the commenter such as their name, username, email address, and the comment itself).', 'akismet' )
+ );
+ }
}
public static function admin_menu() {
@@ -260,7 +276,13 @@ class Akismet_Admin {
foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) {
update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' );
}
-
+
+ if ( ! empty( $_POST['akismet_comment_form_privacy_notice'] ) ) {
+ self::set_form_privacy_notice_option( $_POST['akismet_comment_form_privacy_notice'] );
+ } else {
+ self::set_form_privacy_notice_option( 'hide' );
+ }
+
if ( Akismet::predefined_api_key() ) {
return false; //shouldn't have option to save key if already defined
}
@@ -825,6 +847,14 @@ class Akismet_Admin {
) );
}
+ public static function display_privacy_notice_control_warning() {
+ if ( !current_user_can( 'manage_options' ) )
+ return;
+ Akismet::view( 'notice', array(
+ 'type' => 'privacy',
+ ) );
+ }
+
public static function display_spam_check_warning() {
Akismet::fix_scheduled_recheck();
@@ -958,6 +988,10 @@ class Akismet_Admin {
$notices[] = array( 'type' => $akismet_user->status );
}
+ if ( false === get_option( 'akismet_comment_form_privacy_notice' ) ) {
+ $notices[] = array( 'type' => 'privacy' );
+ }
+
/*
// To see all variants when testing.
$notices[] = array( 'type' => 'active-notice', 'time_saved' => 'Cleaning up spam takes time. Akismet has saved you 1 minute!' );
@@ -1024,6 +1058,14 @@ class Akismet_Admin {
echo '<div class="notice notice-success"><p>' . esc_html( $message ) . '</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' ) ) ) {
+ $api_key = Akismet::get_api_key();
+ if ( ! empty( $api_key ) ) {
+ self::display_privacy_notice_control_warning();
+ }
+ }
}
public static function display_status() {
@@ -1128,4 +1170,14 @@ class Akismet_Admin {
return $all_plugins;
}
+
+ private static function set_form_privacy_notice_option( $state ) {
+ if ( in_array( $state, array( 'display', 'hide' ) ) ) {
+ update_option( 'akismet_comment_form_privacy_notice', $state );
+ }
+ }
+
+ public static function jetpack_comment_form_privacy_notice_url( $url ) {
+ return str_replace( 'options-general.php', 'admin.php', $url );
+ }
}