Changeset 2580537
- Timestamp:
- 08/09/2021 08:10:43 PM (5 years ago)
- Location:
- akismet/trunk
- Files:
-
- 1 added
- 7 edited
-
.htaccess (modified) (1 diff)
-
_inc/akismet.css (modified) (1 diff)
-
_inc/img/logo-a-2x.png (added)
-
akismet.php (modified) (2 diffs)
-
class.akismet-admin.php (modified) (4 diffs)
-
class.akismet.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
views/notice.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
akismet/trunk/.htaccess
r1413166 r2580537 24 24 25 25 # Akismet images 26 <FilesMatch "^logo- full-2x\.png$">26 <FilesMatch "^logo-(a|full)-2x\.png$"> 27 27 <IfModule !mod_authz_core.c> 28 28 Allow from all -
akismet/trunk/_inc/akismet.css
r2309873 r2580537 661 661 padding-bottom: 1.5rem; 662 662 } 663 664 div.error.akismet-usage-limit-alert { 665 padding: 25px 45px 25px 15px; 666 display: flex; 667 align-items: center; 668 } 669 670 #akismet-plugin-container .akismet-usage-limit-alert { 671 margin: 0 auto 0.625rem auto; 672 box-sizing: border-box; 673 box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3; 674 border: none; 675 border-left: 4px solid #d63638; 676 } 677 678 .akismet-usage-limit-alert .akismet-usage-limit-logo { 679 width: 38px; 680 min-width: 38px; 681 height: 38px; 682 border-radius: 20px; 683 margin-right: 18px; 684 background: black; 685 position: relative; 686 } 687 688 .akismet-usage-limit-alert .akismet-usage-limit-logo img { 689 position: absolute; 690 width: 22px; 691 left: 8px; 692 top: 10px; 693 } 694 695 .akismet-usage-limit-alert .akismet-usage-limit-text { 696 flex-grow: 1; 697 margin-right: 18px; 698 } 699 700 .akismet-usage-limit-alert h3 { 701 margin: 0; 702 } 703 704 .akismet-usage-limit-alert .akismet-usage-limit-cta { 705 text-align: right; 706 } 707 708 @media (max-width: 550px) { 709 div.error.akismet-usage-limit-alert { 710 display: block; 711 } 712 713 .akismet-usage-limit-alert .akismet-usage-limit-logo, 714 .akismet-usage-limit-alert .akismet-usage-limit-text { 715 margin-bottom: 15px; 716 } 717 718 .akismet-usage-limit-alert .akismet-usage-limit-cta { 719 text-align: left; 720 } 721 } -
akismet/trunk/akismet.php
r2559612 r2580537 7 7 Plugin URI: https://akismet.com/ 8 8 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. 9 Version: 4.1.1 09 Version: 4.1.11a1 10 10 Author: Automattic 11 11 Author URI: https://automattic.com/wordpress-plugins/ … … 38 38 } 39 39 40 define( 'AKISMET_VERSION', '4.1.1 0' );40 define( 'AKISMET_VERSION', '4.1.11a1' ); 41 41 define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' ); 42 42 define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
akismet/trunk/class.akismet-admin.php
r2402753 r2580537 889 889 } 890 890 891 public static function get_usage_limit_alert_data() { 892 return array( 893 'type' => 'usage-limit', 894 'code' => (int) get_option( 'akismet_alert_code' ), 895 'msg' => get_option( 'akismet_alert_msg' ), 896 'api_calls' => get_option( 'akismet_alert_api_calls' ), 897 'usage_limit' => get_option( 'akismet_alert_usage_limit' ), 898 'upgrade_plan' => get_option( 'akismet_alert_upgrade_plan' ), 899 'upgrade_url' => get_option( 'akismet_alert_upgrade_url' ), 900 ); 901 } 902 903 public static function display_usage_limit_alert() { 904 Akismet::view( 'notice', self::get_usage_limit_alert_data() ); 905 } 906 891 907 public static function display_spam_check_warning() { 892 908 Akismet::fix_scheduled_recheck(); … … 1020 1036 if ( !isset( self::$notices['status'] ) && in_array( $akismet_user->status, array( 'cancelled', 'suspended', 'missing', 'no-sub' ) ) ) { 1021 1037 $notices[] = array( 'type' => $akismet_user->status ); 1038 } 1039 1040 $alert_code = get_option( 'akismet_alert_code' ); 1041 if ( preg_match( '/^105\d\d$/', $alert_code ) ) { 1042 $notices[] = self::get_usage_limit_alert_data(); 1022 1043 } 1023 1044 … … 1041 1062 $notices[] = array( 'type' => 'limit-reached', 'level' => 'yellow' ); 1042 1063 $notices[] = array( 'type' => 'limit-reached', 'level' => 'red' ); 1064 $notices[] = array( 'type' => 'usage-limit', 'api_calls' => '15000', 'usage_limit' => '10000', 'upgrade_plan' => 'Enterprise', 'upgrade_url' => 'https://akismet.com/account/' ); 1043 1065 */ 1044 1066 … … 1057 1079 if ( in_array( $hook_suffix, array( 'edit-comments.php' ) ) && (int) get_option( 'akismet_alert_code' ) > 0 ) { 1058 1080 Akismet::verify_key( Akismet::get_api_key() ); //verify that the key is still in alert state 1059 1060 if ( get_option( 'akismet_alert_code' ) > 0 ) 1081 1082 $alert_code = get_option( 'akismet_alert_code' ); 1083 if ( preg_match( '/^105\d\d$/', $alert_code ) ) { 1084 self::display_usage_limit_alert(); 1085 } 1086 elseif ( $alert_code > 0 ) { 1061 1087 self::display_alert(); 1088 } 1062 1089 } 1063 1090 elseif ( ( 'plugins.php' === $hook_suffix || 'edit-comments.php' === $hook_suffix ) && ! Akismet::get_api_key() ) { -
akismet/trunk/class.akismet.php
r2531878 r2580537 5 5 const API_PORT = 80; 6 6 const MAX_DELAY_BEFORE_MODERATION_EMAIL = 86400; // One day in seconds 7 8 const LIMIT_NOTICE_FIRST_MONTH_OVER_LIMIT = 10501; 9 const LIMIT_NOTICE_SECOND_MONTH_OVER_LIMIT = 10502; 10 const LIMIT_NOTICE_THIRD_MONTH_APPROACHING_LIMIT = 10504; 11 const LIMIT_NOTICE_THIRD_MONTH_OVER_LIMIT = 10508; 12 const LIMIT_NOTICE_FOUR_PLUS_MONTHS_OVER_LIMIT = 10516; 7 13 8 14 private static $last_comment = ''; … … 1255 1261 // given a response from an API call like check_key_status(), update the alert code options if an alert is present. 1256 1262 public static function update_alert( $response ) { 1257 $code = $msg = null; 1258 if ( isset( $response[0]['x-akismet-alert-code'] ) ) { 1259 $code = $response[0]['x-akismet-alert-code']; 1260 $msg = $response[0]['x-akismet-alert-msg']; 1261 } 1262 1263 // only call update_option() if the value has changed 1264 if ( $code != get_option( 'akismet_alert_code' ) ) { 1265 if ( ! $code ) { 1266 delete_option( 'akismet_alert_code' ); 1267 delete_option( 'akismet_alert_msg' ); 1268 } 1269 else { 1270 update_option( 'akismet_alert_code', $code ); 1271 update_option( 'akismet_alert_msg', $msg ); 1263 $alert_option_prefix = 'akismet_alert_'; 1264 $alert_header_prefix = 'x-akismet-alert-'; 1265 $alert_header_names = array( 1266 'code', 1267 'msg', 1268 'api-calls', 1269 'usage-limit', 1270 'upgrade-plan', 1271 'upgrade-url', 1272 ); 1273 1274 foreach( $alert_header_names as $alert_header_name ) { 1275 $value = null; 1276 if ( isset( $response[0][$alert_header_prefix . $alert_header_name] ) ) { 1277 $value = $response[0][$alert_header_prefix . $alert_header_name]; 1278 } 1279 1280 $option_name = $alert_option_prefix . str_replace( '-', '_', $alert_header_name ); 1281 if ( $value != get_option( $option_name ) ) { 1282 if ( ! $value ) { 1283 delete_option( $option_name ); 1284 } 1285 else { 1286 update_option( $option_name, $value ); 1287 } 1272 1288 } 1273 1289 } -
akismet/trunk/readme.txt
r2559612 r2580537 30 30 31 31 == Changelog == 32 33 = 4.1.11 = 34 *Release Date - TBD* 35 36 * Added support for Akismet API usage notifications on Akismet settings and edit-comments admin pages. 32 37 33 38 = 4.1.10 = -
akismet/trunk/views/notice.php
r2519525 r2580537 140 140 <?php endif; ?> 141 141 </div> 142 <?php elseif ( $type == 'usage-limit' ) :?> 143 <div class="error akismet-usage-limit-alert"> 144 <div class="akismet-usage-limit-logo"> 145 <img src="<?php echo esc_url( plugins_url( '../_inc/img/logo-a-2x.png', __FILE__ ) ); ?>" alt="Akismet" /> 146 </div> 147 <div class="akismet-usage-limit-text"> 148 <h3> 149 <?php 150 switch ( $code ) { 151 case Akismet::LIMIT_NOTICE_FIRST_MONTH_OVER_LIMIT: 152 case Akismet::LIMIT_NOTICE_SECOND_MONTH_OVER_LIMIT: 153 esc_html_e( 'Your Akismet account usage is over the plan limit', 'akismet' ); 154 break; 155 case Akismet::LIMIT_NOTICE_THIRD_MONTH_APPROACHING_LIMIT: 156 esc_html_e( 'Your Akismet account usage is approaching the plan limit', 'akismet' ); 157 break; 158 case Akismet::LIMIT_NOTICE_THIRD_MONTH_OVER_LIMIT: 159 case Akismet::LIMIT_NOTICE_FOUR_PLUS_MONTHS_OVER_LIMIT: 160 esc_html_e( 'Your account has been restricted', 'akismet' ); 161 break; 162 default: 163 } 164 ?> 165 </h3> 166 <p> 167 <?php 168 switch ( $code ) { 169 case Akismet::LIMIT_NOTICE_FIRST_MONTH_OVER_LIMIT: 170 printf( 171 __( 'Since %s, your account made %s API calls, compared to your plan limit of %s. <a href="%s" target="_blank">Learn more</a> about usage limits.', 'akismet' ), 172 esc_html( gmdate( 'F' ) . ' 1' ), 173 number_format( $api_calls ), 174 number_format( $usage_limit ), 175 'https://docs.akismet.com/akismet-api-usage-limits/' 176 ); 177 break; 178 case Akismet::LIMIT_NOTICE_SECOND_MONTH_OVER_LIMIT: 179 esc_html_e( 'Your Akismet usage has been over the plan limit for two consecutive months. Next month, we will restrict your account after you reach the limit. Please consider upgrading your plan.', 'akismet' ); 180 break; 181 case Akismet::LIMIT_NOTICE_THIRD_MONTH_APPROACHING_LIMIT: 182 esc_html_e( 'Your Akismet usage is nearing the plan limit for the third consecutive month. We will restrict your account after you reach the limit. Upgrade your plan so Akismet can continue blocking spam.', 'akismet' ); 183 break; 184 case Akismet::LIMIT_NOTICE_THIRD_MONTH_OVER_LIMIT: 185 case Akismet::LIMIT_NOTICE_FOUR_PLUS_MONTHS_OVER_LIMIT: 186 esc_html_e( 'Your Akismet usage has been over the plan limit for three consecutive months. We have restricted your account for the rest of the month. Upgrade your plan so Akismet can continue blocking spam.', 'akismet' ); 187 break; 188 default: 189 } 190 ?> 191 </p> 192 </div> 193 <div class="akismet-usage-limit-cta"> 194 <?php printf( __( '<a href="%1$s" class="button" target="_blank">Upgrade to %2$s</a>', 'akismet' ), esc_attr( $upgrade_url ), esc_html( $upgrade_plan ) ); ?> 195 </div> 196 </div> 142 197 <?php endif;?>
Note: See TracChangeset
for help on using the changeset viewer.