Plugin Directory

Changeset 3016639

Timestamp:
01/02/2024 08:12:09 PM (7 months ago)
Author:
cfinke
Message:

Add the akismet_request_args filter to allow request args in Akismet API requests to be filtered.

Location:
akismet/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • akismet/trunk/akismet.php

    r3014492 r3016639  
    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>. Akismet Anti-spam 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: 5.3.1a5
     9Version: 5.3.1a
    1010Requires at least: 5.8
    1111Requires PHP: 5.6.20
     
    4040}
    4141
    42 define( 'AKISMET_VERSION', '5.3.1a5' );
     42define( 'AKISMET_VERSION', '5.3.1a' );
    4343define( 'AKISMET__MINIMUM_WP_VERSION', '5.8' );
    4444define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • akismet/trunk/class.akismet-admin.php

    r3003470 r3016639  
    853853        $akismet_user = false;
    854854
    855         $subscription_verification = Akismet::http_post( Akismet::build_query( array( 'key' => $api_key, 'blog' => get_option( 'home' ) ) ), 'get-subscription' );
     855        $request_args = array(
     856            'key' => $api_key,
     857            'blog' => get_option( 'home' ),
     858        );
     859
     860        $request_args = apply_filters( 'akismet_request_args', $request_args, 'get-subscription' );
     861
     862        $subscription_verification = Akismet::http_post( Akismet::build_query( $request_args ), 'get-subscription' );
    856863
    857864        if ( ! empty( $subscription_verification[1] ) ) {
     
    868875
    869876        foreach( array( '6-months', 'all' ) as $interval ) {
    870             $response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' );
     877            $request_args = array(
     878                'blog' => get_option( 'home' ),
     879                'key' => $api_key,
     880                'from' => $interval,
     881            );
     882
     883            $request_args = apply_filters( 'akismet_request_args', $request_args, 'get-stats' );
     884
     885            $response = Akismet::http_post( Akismet::build_query( $request_args ), 'get-stats' );
    871886
    872887            if ( ! empty( $response[1] ) ) {
     
    879894
    880895    public static function verify_wpcom_key( $api_key, $user_id, $extra = array() ) {
    881         $akismet_account = Akismet::http_post( Akismet::build_query( array_merge( array(
    882             'user_id'          => $user_id,
    883             'api_key'          => $api_key,
    884             'get_account_type' => 'true'
    885         ), $extra ) ), 'verify-wpcom-key' );
     896        $request_args = array_merge(
     897            array(
     898                'user_id' => $user_id,
     899                'api_key' => $api_key,
     900                'get_account_type' => 'true',
     901            ),
     902            $extra
     903        );
     904
     905        $request_args = apply_filters( 'akismet_request_args', $request_args, 'verify-wpcom-key' );
     906
     907        $akismet_account = Akismet::http_post( Akismet::build_query( $request_args ), 'verify-wpcom-key' );
    886908
    887909        if ( ! empty( $akismet_account[1] ) )
  • akismet/trunk/class.akismet-cli.php

    r1900374 r3016639  
    147147        }
    148148 
    149         $response = Akismet::http_post(
    150             Akismet::build_query( array(
    151                 'blog' => get_option( 'home' ),
    152                 'key'  => $api_key,
    153                 'from' => $interval,
    154             ) ),
    155             'get-stats'
     149        $request_args = array(
     150            'blog' => get_option( 'home' ),
     151            'key'  => $api_key,
     152            'from' => $interval,
    156153        );
    157154 
     155
     156
     157
     158
    158159        if ( empty( $response[1] ) ) {
    159160            WP_CLI::error( __( 'Currently unable to fetch stats. Please try again.', 'akismet' ) );
  • akismet/trunk/class.akismet-rest-api.php

    r1965973 r3016639  
    265265        $stat_totals = array();
    266266
    267         $response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' );
     267        $request_args = array(
     268            'blog' => get_option( 'home' ),
     269            'key' => $api_key,
     270            'from' => $interval,
     271        );
     272
     273        $request_args = apply_filters( 'akismet_request_args', $request_args, 'get-stats' );
     274
     275        $response = Akismet::http_post( Akismet::build_query( $request_args ), 'get-stats' );
    268276
    269277        if ( ! empty( $response[1] ) ) {
     
    319327
    320328    private static function key_is_valid( $key ) {
    321         $response = Akismet::http_post(
    322             Akismet::build_query(
    323                 array(
    324                     'key' => $key,
    325                     'blog' => get_option( 'home' )
    326                 )
    327             ),
    328             'verify-key'
     329        $request_args = array(
     330            'key' => $key,
     331            'blog' => get_option( 'home' ),
    329332        );
     333
     334
     335
     336
    330337
    331338        if ( $response[1] == 'valid' ) {
  • akismet/trunk/class.akismet.php

    r2966139 r3016639  
    109109
    110110        if ( is_null( $access_token ) ) {
    111             $response = self::http_post( self::build_query( array( 'api_key' => self::get_api_key() ) ), 'token' );
     111            $request_args = array( 'api_key' => self::get_api_key() );
     112
     113            $request_args = apply_filters( 'akismet_request_args', $request_args, 'token' );
     114
     115            $response = self::http_post( self::build_query( $request_args ), 'token' );
    112116
    113117            $access_token = $response[1];
     
    118122
    119123    public static function check_key_status( $key, $ip = null ) {
    120         return self::http_post( Akismet::build_query( array( 'key' => $key, 'blog' => get_option( 'home' ) ) ), 'verify-key', $ip );
     124        $request_args = array(
     125            'key' => $key,
     126            'blog' => get_option( 'home' ),
     127        );
     128
     129        $request_args = apply_filters( 'akismet_request_args', $request_args, 'verify-key' );
     130
     131        return self::http_post( self::build_query( $request_args ), 'verify-key', $ip );
    121132    }
    122133
     
    136147
    137148    public static function deactivate_key( $key ) {
    138         $response = self::http_post( Akismet::build_query( array( 'key' => $key, 'blog' => get_option( 'home' ) ) ), 'deactivate' );
     149        $request_args = array(
     150            'key' => $key,
     151            'blog' => get_option( 'home' ),
     152        );
     153
     154        $request_args = apply_filters( 'akismet_request_args', $request_args, 'deactivate' );
     155
     156        $response = self::http_post( self::build_query( $request_args ), 'deactivate' );
    139157
    140158        if ( $response[1] != 'deactivated' )
     
    284302        }
    285303
    286         $response = self::http_post( Akismet::build_query( $comment ), 'comment-check' );
     304        /**
     305         * Filter the data that is used to generate the request body for the API call.
     306         *
     307         * @since 5.3.1
     308         *
     309         * @param array $comment An array of request data.
     310         * @param string $endpoint The API endpoint being requested.
     311         */
     312        $comment = apply_filters( 'akismet_request_args', $comment, 'comment-check' );
     313
     314        $response = self::http_post( self::build_query( $comment ), 'comment-check' );
    287315
    288316        do_action( 'akismet_comment_check_response', $response );
     
    301329        if ( isset( $response[0]['x-akismet-pro-tip'] ) )
    302330            $commentdata['akismet_pro_tip'] = $response[0]['x-akismet-pro-tip'];
     331
     332
     333
     334
    303335
    304336        if ( isset( $response[0]['x-akismet-error'] ) ) {
     
    443475                    update_comment_meta( $comment->comment_ID, 'akismet_pro_tip', self::$last_comment['akismet_pro_tip'] );
    444476                }
     477
     478
     479
     480
    445481            }
    446482        }
     
    712748            $c['is_test'] = 'true';
    713749
    714         $response = self::http_post( Akismet::build_query( $c ), 'comment-check' );
     750        $c = apply_filters( 'akismet_request_args', $c, 'comment-check' );
     751
     752        $response = self::http_post( self::build_query( $c ), 'comment-check' );
    715753
    716754        if ( ! empty( $response[1] ) ) {
     
    874912        }
    875913
    876         $response = Akismet::http_post( Akismet::build_query( $comment ), 'submit-spam' );
     914        $comment = apply_filters( 'akismet_request_args', $comment, 'submit-spam' );
     915
     916        $response = self::http_post( self::build_query( $comment ), 'submit-spam' );
    877917
    878918        update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
     
    932972        }
    933973
    934         $response = self::http_post( Akismet::build_query( $comment ), 'submit-ham' );
     974        $comment = apply_filters( 'akismet_request_args', $comment, 'submit-ham' );
     975
     976        $response = self::http_post( self::build_query( $comment ), 'submit-ham' );
    935977
    936978        update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
  • akismet/trunk/readme.txt

    r3003470 r3016639  
    3939* Add a link to the 'Account overview' page on akismet.com.
    4040* Fix a minor error that occurs when another plugin removes all comment actions from the dashboard.
     41
    4142
    4243= 5.3 =
Note: See TracChangeset for help on using the changeset viewer.