Plugin Directory

Changeset 883068

Timestamp:
03/27/2014 05:55:35 PM (10 years ago)
Author:
eoigal
Message:

update to check key subscription exists before saving key. Add new notices for missing subscription.

Location:
akismet/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • akismet/trunk/class.akismet-admin.php

    r878668 r883068  
    9393                'strings' => array(
    9494                    'Remove this URL' => __( 'Remove this URL' , 'akismet'),
    95                     'Removing...' => __( 'Removing...' , 'akismet'),
    96                     'URL removed' => __( 'URL removed' , 'akismet'),
    97                     '(undo)' => __( '(undo)' , 'akismet'),
    98                     'Re-adding...' => __( 'Re-adding...' , 'akismet'),
     95                    'Removing...' => __( 'Removing...' , 'akismet'),
     96                    'URL removed' => __( 'URL removed' , 'akismet'),
     97                    '(undo)' => __( '(undo)' , 'akismet'),
     98                    'Re-adding...' => __( 'Re-adding...' , 'akismet'),
    9999                )
    100100            ) );
     
    243243
    244244        if ( $key_status == 'valid' ) {
    245             update_option( 'wordpress_api_key', $api_key );
    246             self::$notices[] = 'new-key-valid';
     245            $akismet_user = self::get_akismet_user( $api_key );
     246           
     247            if ( $akismet_user ) {
     248                if ( $akismet_user->status != 'missing' )
     249                    update_option( 'wordpress_api_key', $api_key );
     250               
     251                if ( $akismet_user->status == 'active' )
     252                    self::$notices['status'] = 'new-key-valid';
     253                else
     254                    self::$notices['status'] = $akismet_user->status;
     255            }
     256            else
     257                self::$notices['status'] = 'new-key-invalid';
    247258        }
    248259        elseif ( in_array( $key_status, array( 'invalid', 'failed' ) ) )
    249             self::$notices[] = 'new-key-'.$key_status;
     260            self::$notices[] = 'new-key-'.$key_status;
    250261    }
    251262
     
    719730        return $url;
    720731    }
     732
     733
     734
     735
     736
     737
     738
     739
     740
     741
     742
    721743
    722744    public static function display_alert() {
     
    808830    public static function display_configuration_page() {
    809831        $api_key      = Akismet::get_api_key();
    810         $akismet_user = Akismet::http_post( http_build_query( array( 'key' => $api_key ) ), 'get-subscription' );
    811 
    812         if ( count( $akismet_user ) > 1 )
    813             $akismet_user = json_decode( $akismet_user[1] );
    814         else
    815             $akismet_user = false;
     832        $akismet_user = self::get_akismet_user( $api_key );
    816833
    817834        $blog = parse_url( get_option('home'), PHP_URL_HOST );
     
    846863                Akismet::view( 'notice', array( 'type' => 'active-notice', 'time_saved' => $time_saved ) );
    847864            }
    848             elseif ( in_array( $akismet_user->status, array( 'cancelled', 'suspended' ) ) )
    849                 Akismet::view( 'notice', array( 'type' => $akismet_user->status ) );
    850         }
     865        }
     866       
     867        if ( !isset( self::$notices['status'] ) && in_array( $akismet_user->status, array( 'cancelled', 'suspended', 'missing' ) ) )               
     868            Akismet::view( 'notice', array( 'type' => $akismet_user->status ) );
    851869
    852870        Akismet::log( compact( 'stat_totals', 'akismet_user' ) );
  • akismet/trunk/views/notice.php

    r879359 r883068  
    4242    <p class="description"><?php printf( __('Your firewall may be blocking us. Please contact your host and refer to <a href="%s" target="_blank">our guide about firewalls</a>.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
    4343</div>
    44 <?php elseif ( $type == 'overdue' ) :?>
     44<?php elseif ( $type == '' ) :?>
    4545<div class="wrap alert critical">
    4646    <h3 class="key-status"><?php esc_html_e("Please update your payment details.", 'akismet'); ?></h3>
     
    6262    <p class="description"><?php printf( __('You can help us fight spam and upgrade your account by <a href="%s" target="_blank">contributing a token amount</a>.', 'akismet'), 'https://akismet.com/account/upgrade/'); ?></p>
    6363</div>
     64
     65
     66
     67
     68
    6469<?php elseif ( $type == 'new-key-valid' ) :?>
    6570<div class="wrap alert active">
Note: See TracChangeset for help on using the changeset viewer.