我有自定义代码,可以使用wp_insert_comment
. 做Akismet plugin
是否公开可以使用相同的钩子、函数和类,以及可能涉及用户内容提交自定义表单的其他地方?还是需要编写自定义代码来调用Akismet API?
Akimet插件是否公开了任何可与定制代码一起工作的挂钩、函数、类?
1 个回复
最合适的回答,由SO网友:s_ha_dum 整理而成
我grep
ed是Akismet插件的一个稍微老化的副本,这些是我找到的钩子——先过滤,然后操作。
admin.php:374: if ( apply_filters( \'akismet_show_user_comments_approved\', get_option(\'akismet_show_user_comments_approved\') ) == \'true\' ) { akismet.php:144: $akismet_ua = apply_filters( \'akismet_ua\', $akismet_ua ); akismet.php:201: if ( $incr = apply_filters(\'akismet_spam_count_incr\', 1) ) akismet.php:336: $akismet_nonce_option = apply_filters( \'akismet_comment_nonce\', get_option( \'akismet_comment_nonce\' ) ); akismet.php:391: if ( $incr = apply_filters(\'akismet_spam_count_incr\', 1) ) akismet.php:439: if ( apply_filters(\'akismet_optimize_table\', ($n == 11)) ) // lucky number akismet.php:448: $interval = apply_filters( \'akismet_delete_commentmeta_interval\', 15 ); akismet.php:472: if ( apply_filters( \'akismet_optimize_table\', ( $n == 11 ), \'commentmeta\' ) ) { // lucky number akismet.php:586:$akismet_comment_nonce_option = apply_filters( \'akismet_comment_nonce\', get_option( \'akismet_comment_nonce\' ) ); admin.php:548: do_action(\'akismet_submit_nonspam_comment\', $comment_id, $response[1]); admin.php:599: do_action(\'akismet_submit_spam_comment\', $comment_id, $response[1]); admin.php:740: do_action( \'comment_remove_author_url\' ); admin.php:755: do_action( \'comment_add_author_url\' ); akismet.php:376: do_action( \'akismet_comment_check_response\', $response ); akismet.php:383: do_action( \'akismet_spam_caught\' ); akismet.php:434: do_action( \'delete_comment\', $comment_ids ); legacy.php:85: do_action( \'delete_comment\', $comment_ids ); legacy.php:222:do_action( \'akismet_tabs\' ); // so plugins can add more tabs easily正如你所看到的,其中一些特别引用了评论,尽管我不知道你需要做什么。至于其他“用户内容提交”,我也不知道你到底需要做什么。
不过我想提个建议。与其寻找钩子(可能存在也可能不存在)来满足您的需要,不如看看various functions provided by the Akismet plugin. 例如,其中一些功能akismet_http_post()
, 提供对Akismet API的非常方便的访问,至少在我看来是这样的。
结束