close

Plugin Directory

Changeset 2586158


Ignore:
Timestamp:
08/20/2021 07:37:01 PM (5 years ago)
Author:
procifer
Message:

Improve code readability of alert codes for API usage notices.

Location:
akismet/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • akismet/trunk/akismet.php

    r2585639 r2586158  
    77Plugin URI: https://akismet.com/
    88Description: 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.11a4
     9Version: 4.1.11a5
    1010Author: Automattic
    1111Author URI: https://automattic.com/wordpress-plugins/
     
    3838}
    3939
    40 define( 'AKISMET_VERSION', '4.1.11a4' );
     40define( 'AKISMET_VERSION', '4.1.11a5' );
    4141define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
    4242define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • akismet/trunk/class.akismet-admin.php

    r2580537 r2586158  
    10391039
    10401040        $alert_code = get_option( 'akismet_alert_code' );
    1041         if ( preg_match( '/^105\d\d$/', $alert_code ) ) {
     1041        if ( isset( Akismet::$LIMIT_NOTICES[ $alert_code ] ) ) {
    10421042            $notices[] = self::get_usage_limit_alert_data();
    10431043        }
     
    10811081       
    10821082            $alert_code = get_option( 'akismet_alert_code' );
    1083             if ( preg_match( '/^105\d\d$/', $alert_code ) ) {
     1083            if ( isset( Akismet::$LIMIT_NOTICES[ $alert_code ] ) ) {
    10841084                self::display_usage_limit_alert();
    10851085            }
  • akismet/trunk/class.akismet.php

    r2585043 r2586158  
    66    const MAX_DELAY_BEFORE_MODERATION_EMAIL = 86400; // One day in seconds
    77
    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;
     8    public static $LIMIT_NOTICES = array(
     9        10501 => 'FIRST_MONTH_OVER_LIMIT',
     10        10502 => 'SECOND_MONTH_OVER_LIMIT',
     11        10504 => 'THIRD_MONTH_APPROACHING_LIMIT',
     12        10508 => 'THIRD_MONTH_OVER_LIMIT',
     13        10516 => 'FOUR_PLUS_MONTHS_OVER_LIMIT',
     14    );
    1315
    1416    private static $last_comment = '';
  • akismet/trunk/views/notice.php

    r2585639 r2586158  
    140140    <?php endif; ?>
    141141</div>
    142 <?php elseif ( $type == 'usage-limit' ) :?>
     142<?php elseif ( $type == 'usage-limit' && isset( Akismet::$LIMIT_NOTICES[ $code ] ) ) :?>
    143143<div class="error akismet-usage-limit-alert">
    144144    <div class="akismet-usage-limit-logo">
     
    148148        <h3>
    149149        <?php
    150         switch ( $code ) {
    151             case Akismet::LIMIT_NOTICE_FIRST_MONTH_OVER_LIMIT:
    152             case Akismet::LIMIT_NOTICE_SECOND_MONTH_OVER_LIMIT:
     150        switch ( Akismet::$LIMIT_NOTICES[ $code ] ) {
     151            case 'FIRST_MONTH_OVER_LIMIT':
     152            case 'SECOND_MONTH_OVER_LIMIT':
    153153                esc_html_e( 'Your Akismet account usage is over your plan\'s limit', 'akismet' );
    154154                break;
    155             case Akismet::LIMIT_NOTICE_THIRD_MONTH_APPROACHING_LIMIT:
     155            case 'THIRD_MONTH_APPROACHING_LIMIT':
    156156                esc_html_e( 'Your Akismet account usage is approaching your plan\'s limit', 'akismet' );
    157157                break;
    158             case Akismet::LIMIT_NOTICE_THIRD_MONTH_OVER_LIMIT:
    159             case Akismet::LIMIT_NOTICE_FOUR_PLUS_MONTHS_OVER_LIMIT:
     158            case 'THIRD_MONTH_OVER_LIMIT':
     159            case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
    160160                esc_html_e( 'Your account has been restricted', 'akismet' );
    161161                break;
     
    166166        <p>
    167167        <?php
    168         switch ( $code ) {
    169             case Akismet::LIMIT_NOTICE_FIRST_MONTH_OVER_LIMIT:
     168        switch ( Akismet::$LIMIT_NOTICES[ $code ] ) {
     169            case 'FIRST_MONTH_OVER_LIMIT':
    170170                printf(
    171171                    __( 'Since %s, your account made %s API calls, compared to your plan\'s limit of %s. <a href="%s" target="_blank">Learn more</a> about usage limits.', 'akismet' ),
     
    176176                );
    177177                break;
    178             case Akismet::LIMIT_NOTICE_SECOND_MONTH_OVER_LIMIT:
     178            case 'SECOND_MONTH_OVER_LIMIT':
    179179                esc_html_e( 'Your Akismet usage has been over your plan\'s limit for two consecutive months. Next month, we will restrict your account after you reach the limit. Please consider upgrading your plan.', 'akismet' );
    180180                break;
    181             case Akismet::LIMIT_NOTICE_THIRD_MONTH_APPROACHING_LIMIT:
     181            case 'THIRD_MONTH_APPROACHING_LIMIT':
    182182                esc_html_e( 'Your Akismet usage is nearing your plan\'s 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' );
    183183                break;
    184             case Akismet::LIMIT_NOTICE_THIRD_MONTH_OVER_LIMIT:
    185             case Akismet::LIMIT_NOTICE_FOUR_PLUS_MONTHS_OVER_LIMIT:
     184            case 'THIRD_MONTH_OVER_LIMIT':
     185            case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
    186186                esc_html_e( 'Your Akismet usage has been over your plan\'s 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' );
    187187                break;
Note: See TracChangeset for help on using the changeset viewer.