Changeset 888811
- Timestamp:
- 04/07/2014 02:30:26 PM (12 years ago)
- Location:
- akismet/trunk
- Files:
-
- 2 edited
-
class.akismet-admin.php (modified) (4 diffs)
-
views/notice.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
akismet/trunk/class.akismet-admin.php
r886566 r888811 183 183 '<p><strong>' . esc_html__( 'Akismet Configuration' , 'akismet') . '</strong></p>' . 184 184 '<p><strong>' . esc_html__( 'API Key' , 'akismet') . '</strong> - ' . esc_html__( 'Enter/remove an API key.' , 'akismet') . '</p>' . 185 '<p><strong>' . esc_html__( ' Delete spam on posts more than a month old' , 'akismet') . '</strong> - ' . esc_html__( 'Automatically delete spam comments on posts that are older than a monthold.' , 'akismet') . '</p>' .185 '<p><strong>' . esc_html__( 'Automatically delete spam from posts older than 30 days' , 'akismet') . '</strong> - ' . esc_html__( 'Automatically delete spam comments on posts that are older than 30 days old.' , 'akismet') . '</p>' . 186 186 '<p><strong>' . esc_html__( 'Show the number of approved comments beside each comment author' , 'akismet') . '</strong> - ' . esc_html__( 'Show the number of approved comments beside each comment author in the comments list page.' , 'akismet') . '</p>', 187 187 ) … … 743 743 return $akismet_user; 744 744 } 745 746 public static function verify_wpcom_key( $api_key, $user_id, $token = '' ) { 747 $akismet_account = Akismet::http_post( http_build_query( array( 748 'user_id' => $user_id, 749 'api_key' => $api_key, 750 'token' => $token, 751 'get_account_type' => 'true' 752 ) ), 'verify-wpcom-key' ); 753 754 if ( ! empty( $akismet_account[1] ) ) 755 $akismet_account = json_decode( $akismet_account[1] ); 756 757 Akismet::log( compact( 'akismet_account' ) ); 758 759 return $akismet_account; 760 } 745 761 746 762 public static function display_alert() { … … 788 804 return; 789 805 } 790 806 807 //the user can choose to auto connect their API key by clicking a button on the akismet done page 808 //if jetpack, get verified api key by using connected wpcom user id 809 //if no jetpack, get verified api key by using an akismet token 810 791 811 $akismet_user = false; 792 793 if ( class_exists( 'Jetpack' ) ) { 794 if ( $jetpack_user = self::get_jetpack_user() ) { 795 796 $akismet_user = Akismet::http_post( http_build_query( array( 797 'user_id' => $jetpack_user['user_id'], 798 'api_key' => $jetpack_user['api_key'], 799 'get_account_type' => 'true' 800 ) ), 'verify-wpcom-key' ); 801 802 if ( ! empty( $akismet_user[1] ) ) 803 $akismet_user = json_decode( $akismet_user[1] ); 804 805 Akismet::log( compact( 'akismet_user' ) ); 806 } 807 808 if ( isset( $_GET['action'] ) ) { 809 if ( $_GET['action'] == 'save-key' ) { 810 //auto save jetpack user if the correct wp user id is passed back from akismet done page 811 if ( isset( $_GET['id'] ) && (int) $_GET['id'] == $akismet_user->ID ) { 812 self::save_key( $akismet_user->api_key ); 813 self::display_notice(); 814 self::display_configuration_page(); 815 return; 816 } 812 813 if ( isset( $_GET['token'] ) && preg_match('/^(\d+)-[0-9a-f]{20}$/', $_GET['token'] ) ) 814 $akismet_user = self::verify_wpcom_key( '', '', $_GET['token'] ); 815 elseif ( $jetpack_user = self::get_jetpack_user() ) 816 $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'] ); 817 818 if ( isset( $_GET['action'] ) ) { 819 if ( $_GET['action'] == 'save-key' ) { 820 if ( is_object( $akismet_user ) ) { 821 self::save_key( $akismet_user->api_key ); 822 self::display_notice(); 823 self::display_configuration_page(); 824 return; 817 825 } 818 826 } … … 866 874 Akismet::view( 'notice', array( 'type' => 'active-notice', 'time_saved' => $time_saved ) ); 867 875 } 876 877 if ( !empty( $akismet_user->limit_reached ) && in_array( $akismet_user->limit_reached, array( 'yellow', 'red' ) ) ) { 878 Akismet::view( 'notice', array( 'type' => 'limit-reached', 'level' => $akismet_user->limit_reached ) ); 879 } 868 880 } 869 881 870 if ( !isset( self::$notices['status'] ) && in_array( $akismet_user->status, array( 'cancelled', 'suspended', 'missing' ) ) ) 882 if ( !isset( self::$notices['status'] ) && in_array( $akismet_user->status, array( 'cancelled', 'suspended', 'missing' ) ) ) 871 883 Akismet::view( 'notice', array( 'type' => $akismet_user->status ) ); 872 884 -
akismet/trunk/views/notice.php
r883068 r888811 79 79 <h3 class="key-status"><?php esc_html_e( 'The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.' , 'akismet'); ?></h3> 80 80 </div> 81 <?php elseif ( $type == 'limit-reached' && in_array( $level, array( 'yellow', 'red' ) ) ) :?> 82 <div class="wrap alert critical"> 83 <?php if ( $level == 'yellow' ): ?> 84 <h3 class="key-status failed"><?php esc_html_e("You're using your Akismet key on more sites than your Pro subscription allows.", 'akismet'); ?></h3> 85 <p class="description"><?php printf( __('If you would like to use Akismet on more than 10 sites, you will need to <a href="%s" target="_blank">upgrade to an Enterprise subscription</a>. If you have any questions, please <a href="%s" target="_blank">get in touch with our support team</a>', 'akismet'), 'https://akismet.com/account/', 'https://akismet.com/contact/'); ?></p> 86 <?php elseif ( $level == 'red' ): ?> 87 <h3 class="key-status failed"><?php esc_html_e("You're using Akismet on far too many sites for your Pro subscription.", 'akismet'); ?></h3> 88 <p class="description"><?php printf( __('To continue your service, <a href="%s" target="_blank">upgrade to an Enterprise subscription</a>, which covers an unlimited number of sites. Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet'), 'https://akismet.com/account/', 'https://akismet.com/contact/'); ?></p> 89 <?php endif; ?> 90 </div> 81 91 <?php endif;?>
Note: See TracChangeset
for help on using the changeset viewer.