Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: akismet_request_args

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 7 times in this file.

Line Code
104       *
105       * @return string
106       */
107      public static function get_access_token() {
108           static $access_token = null;
109
110           if ( is_null( $access_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' );
116
117                $access_token = $response[1];
118           }
119
120           return $access_token;
121      }
122
123      public static function check_key_status( $key, $ip = null ) {
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 );
132      }
133
134      public static function verify_key( $key, $ip = null ) {
135           // Shortcut for obviously invalid keys.
136           if ( strlen( $key ) != 12 ) {
137                return 'invalid';
138           }
 
Line Code
145           return $response[1];
146      }
147
148      public static function deactivate_key( $key ) {
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' );
157
158           if ( $response[1] != 'deactivated' )
159                return 'failed';
160
161           return $response[1];
162      }
163
 
Line Code
303
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' );
315
316           do_action( 'akismet_comment_check_response', $response );
317
318           $commentdata['comment_as_submitted'] = array_intersect_key( $comment, self::$comment_as_submitted_allowed_keys );
319
320           // Also include any form fields we inject into the comment form, like ak_js
321           foreach ( $_POST as $key => $value ) {
 
Line Code
752
753           $c['user_role'] = '';
754           if ( ! empty( $c['user_ID'] ) ) {
755                $c['user_role'] = Akismet::get_user_roles( $c['user_ID'] );
756           }
757
758           if ( self::is_test_mode() )
759                $c['is_test'] = 'true';
760
761           $c = apply_filters( 'akismet_request_args', $c, 'comment-check' );
762
763           $response = self::http_post( self::build_query( $c ), 'comment-check' );
764
765           if ( ! empty( $response[1] ) ) {
766                return $response[1];
767           }
768
769           return false;
770      }
 
Line Code
927           if ( self::is_test_mode() )
928                $comment->is_test = 'true';
929
930           $post = get_post( $comment->comment_post_ID );
931
932           if ( ! is_null( $post ) ) {
933                $comment->comment_post_modified_gmt = $post->post_modified_gmt;
934           }
935
936           $comment = apply_filters( 'akismet_request_args', $comment, 'submit-spam' );
937
938           $response = self::http_post( self::build_query( $comment ), 'submit-spam' );
939
940           update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
941
942           if ( $comment->reporter ) {
943                update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
944           }
945
 
Line Code
987           if ( Akismet::is_test_mode() )
988                $comment->is_test = 'true';
989
990           $post = get_post( $comment->comment_post_ID );
991
992           if ( ! is_null( $post ) ) {
993                $comment->comment_post_modified_gmt = $post->post_modified_gmt;
994           }
995
996           $comment = apply_filters( 'akismet_request_args', $comment, 'submit-ham' );
997
998           $response = self::http_post( self::build_query( $comment ), 'submit-ham' );
999
1000           update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
1001
1002           if ( $comment->reporter ) {
1003                update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
1004           }
1005