当前位置: 首页>>代码示例>>PHP>>正文


PHP Akismet::get_last_comment方法代码示例

本文整理汇总了PHP中Akismet::get_last_comment方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::get_last_comment方法的具体用法?PHP Akismet::get_last_comment怎么用?PHP Akismet::get_last_comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akismet的用法示例。


在下文中一共展示了Akismet::get_last_comment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: callback_wp_insert_comment

 /**
  * Tracks comment creation
  *
  * @action wp_insert_comment
  */
 public static function callback_wp_insert_comment($comment_id, $comment)
 {
     if (in_array($comment->comment_type, self::get_ignored_comment_types())) {
         return;
     }
     $user_id = self::get_comment_author($comment, 'id');
     $user_name = self::get_comment_author($comment, 'name');
     $post_id = $comment->comment_post_ID;
     $post_type = get_post_type($post_id);
     $post_title = ($post = get_post($post_id)) ? "\"{$post->post_title}\"" : __('a post', 'stream');
     $comment_status = 1 == $comment->comment_approved ? __('approved automatically', 'stream') : __('pending approval', 'stream');
     $is_spam = false;
     // Auto-marked spam comments
     if (class_exists('Akismet') && Akismet::matches_last_comment($comment)) {
         $ak_last_comment = Akismet::get_last_comment();
         if ('true' == $ak_last_comment['akismet_result']) {
             $is_spam = true;
             $comment_status = __('automatically marked as spam by Akismet', 'stream');
         }
     }
     $comment_type = mb_strtolower(self::get_comment_type_label($comment_id));
     if ($comment->comment_parent) {
         $parent_user_id = get_comment_author($comment->comment_parent, 'id');
         $parent_user_name = get_comment_author($comment->comment_parent, 'name');
         self::log(_x('Reply to %1$s\'s %5$s by %2$s on %3$s %4$s', "1: Parent comment's author, 2: Comment author, 3: Post title, 4: Comment status, 5: Comment type", 'stream'), compact('parent_user_name', 'user_name', 'post_title', 'comment_status', 'comment_type', 'post_id', 'parent_user_id'), $comment_id, $post_type, 'replied', $user_id);
     } else {
         self::log(_x('New %4$s by %1$s on %2$s %3$s', '1: Comment author, 2: Post title 3: Comment status, 4: Comment type', 'stream'), compact('user_name', 'post_title', 'comment_status', 'comment_type', 'post_id', 'is_spam'), $comment_id, $post_type, $is_spam ? 'spammed' : 'created', $user_id);
     }
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:34,代码来源:class-wp-stream-connector-comments.php

示例2: callback_wp_insert_comment

 /**
  * Tracks comment creation
  *
  * @action wp_insert_comment
  *
  * @param int $comment_id
  * @param object $comment
  */
 public function callback_wp_insert_comment($comment_id, $comment)
 {
     if (in_array($comment->comment_type, $this->get_ignored_comment_types())) {
         return;
     }
     $user_id = $this->get_comment_author($comment, 'id');
     $user_name = $this->get_comment_author($comment, 'name');
     $post_id = $comment->comment_post_ID;
     $post_type = get_post_type($post_id);
     $post_title = ($post = get_post($post_id)) ? "\"{$post->post_title}\"" : esc_html__('a post', 'stream');
     $comment_status = 1 === $comment->comment_approved ? esc_html__('approved automatically', 'stream') : esc_html__('pending approval', 'stream');
     $is_spam = false;
     // Auto-marked spam comments
     $options = wp_stream_get_instance()->settings->options;
     $ak_tracking = isset($options['advanced_akismet_tracking']) ? $options['advanced_akismet_tracking'] : false;
     if (class_exists('Akismet') && $ak_tracking && \Akismet::matches_last_comment($comment)) {
         $ak_last_comment = \Akismet::get_last_comment();
         if ('true' === $ak_last_comment['akismet_result']) {
             $is_spam = true;
             $comment_status = esc_html__('automatically marked as spam by Akismet', 'stream');
         }
     }
     $comment_type = mb_strtolower($this->get_comment_type_label($comment_id));
     if ($comment->comment_parent) {
         $parent_user_id = get_comment_author($comment->comment_parent, 'id');
         $parent_user_name = get_comment_author($comment->comment_parent, 'name');
         $this->log(_x('Reply to %1$s\'s %5$s by %2$s on %3$s %4$s', "1: Parent comment's author, 2: Comment author, 3: Post title, 4: Comment status, 5: Comment type", 'stream'), compact('parent_user_name', 'user_name', 'post_title', 'comment_status', 'comment_type', 'post_id', 'parent_user_id'), $comment_id, $post_type, 'replied', $user_id);
     } else {
         $this->log(_x('New %4$s by %1$s on %2$s %3$s', '1: Comment author, 2: Post title 3: Comment status, 4: Comment type', 'stream'), compact('user_name', 'post_title', 'comment_status', 'comment_type', 'post_id', 'is_spam'), $comment_id, $post_type, $is_spam ? 'spammed' : 'created', $user_id);
     }
 }
开发者ID:evgenykireev,项目名称:stream,代码行数:39,代码来源:class-connector-comments.php


注:本文中的Akismet::get_last_comment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。