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


PHP Akismet::get_user_roles方法代码示例

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


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

示例1: submit_nonspam_comment

 public static function submit_nonspam_comment($comment_id)
 {
     global $wpdb, $current_user, $current_site;
     $comment_id = (int) $comment_id;
     $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id));
     if (!$comment) {
         // it was deleted
         return;
     }
     // use the original version stored in comment_meta if available
     $as_submitted = get_comment_meta($comment_id, 'akismet_as_submitted', true);
     if ($as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content'])) {
         $comment = (object) array_merge((array) $comment, $as_submitted);
     }
     $comment->blog = get_bloginfo('url');
     $comment->blog_lang = get_locale();
     $comment->blog_charset = get_option('blog_charset');
     $comment->permalink = get_permalink($comment->comment_post_ID);
     $comment->user_role = '';
     if (is_object($current_user)) {
         $comment->reporter = $current_user->user_login;
     }
     if (is_object($current_site)) {
         $comment->site_domain = $current_site->domain;
     }
     if (isset($comment->user_ID)) {
         $comment->user_role = Akismet::get_user_roles($comment->user_ID);
     }
     if (Akismet::is_test_mode()) {
         $comment->is_test = 'true';
     }
     $post = get_post($comment->comment_post_ID);
     $comment->comment_post_modified_gmt = $post->post_modified_gmt;
     $response = Akismet::http_post(http_build_query($comment), 'submit-ham');
     if ($comment->reporter) {
         Akismet::update_comment_history($comment_id, sprintf(__('%s reported this comment as not spam', 'akismet'), $comment->reporter), 'report-ham');
         update_comment_meta($comment_id, 'akismet_user_result', 'false');
         update_comment_meta($comment_id, 'akismet_user', $comment->reporter);
     }
     do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
 }
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:41,代码来源:class.akismet-admin.php

示例2: recheck_queue

 public static function recheck_queue()
 {
     global $wpdb;
     Akismet::fix_scheduled_recheck();
     if (!(isset($_GET['recheckqueue']) || isset($_REQUEST['action']) && 'akismet_recheck_queue' == $_REQUEST['action'])) {
         return;
     }
     $paginate = '';
     if (isset($_POST['limit']) && isset($_POST['offset'])) {
         $paginate = $wpdb->prepare(" LIMIT %d OFFSET %d", array($_POST['limit'], $_POST['offset']));
     }
     $moderation = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A);
     foreach ((array) $moderation as $c) {
         $c['user_ip'] = $c['comment_author_IP'];
         $c['user_agent'] = $c['comment_agent'];
         $c['referrer'] = '';
         $c['blog'] = get_bloginfo('url');
         $c['blog_lang'] = get_locale();
         $c['blog_charset'] = get_option('blog_charset');
         $c['permalink'] = get_permalink($c['comment_post_ID']);
         $c['user_role'] = '';
         if (isset($c['user_ID'])) {
             $c['user_role'] = Akismet::get_user_roles($c['user_ID']);
         }
         if (Akismet::is_test_mode()) {
             $c['is_test'] = 'true';
         }
         add_comment_meta($c['comment_ID'], 'akismet_rechecking', true);
         $response = Akismet::http_post(Akismet::build_query($c), 'comment-check');
         if ('true' == $response[1]) {
             wp_set_comment_status($c['comment_ID'], 'spam');
             update_comment_meta($c['comment_ID'], 'akismet_result', 'true');
             delete_comment_meta($c['comment_ID'], 'akismet_error');
             delete_comment_meta($c['comment_ID'], 'akismet_delayed_moderation_email');
             Akismet::update_comment_history($c['comment_ID'], __('Akismet re-checked and caught this comment as spam', 'akismet'), 'check-spam');
         } elseif ('false' == $response[1]) {
             update_comment_meta($c['comment_ID'], 'akismet_result', 'false');
             delete_comment_meta($c['comment_ID'], 'akismet_error');
             delete_comment_meta($c['comment_ID'], 'akismet_delayed_moderation_email');
             Akismet::update_comment_history($c['comment_ID'], __('Akismet re-checked and cleared this comment', 'akismet'), 'check-ham');
             // abnormal result: error
         } else {
             update_comment_meta($c['comment_ID'], 'akismet_result', 'error');
             Akismet::update_comment_history($c['comment_ID'], sprintf(__('Akismet was unable to re-check this comment (response: %s)', 'akismet'), substr($response[1], 0, 50)), 'check-error');
         }
         delete_comment_meta($c['comment_ID'], 'akismet_rechecking');
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         wp_send_json(array('processed' => count((array) $moderation)));
     } else {
         $redirect_to = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : admin_url('edit-comments.php');
         wp_safe_redirect($redirect_to);
         exit;
     }
 }
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:55,代码来源:class.akismet-admin.php

示例3: akismet_get_user_roles

function akismet_get_user_roles($user_id)
{
    _deprecated_function(__FUNCTION__, '3.0', 'Akismet::get_user_roles()');
    return Akismet::get_user_roles($user_id);
}
开发者ID:Didox,项目名称:beminfinito,代码行数:5,代码来源:wrapper.php

示例4: akismet_get_user_roles

function akismet_get_user_roles($user_id)
{
    return Akismet::get_user_roles($user_id);
}
开发者ID:TheHiddenHaku,项目名称:fuzzy-waddle,代码行数:4,代码来源:wrapper.php

示例5: build_akismet_data_package

 /**
  * Build a data package for the Akismet service to inspect.
  *
  * @since 1.6.0
  *
  * @see http://akismet.com/development/api/#comment-check
  * @static
  *
  * @param BP_Activity_Activity $activity Activity item data.
  * @return array $activity_data
  */
 public static function build_akismet_data_package($activity)
 {
     $userdata = get_userdata($activity->user_id);
     $activity_data = array();
     $activity_data['akismet_comment_nonce'] = 'inactive';
     $activity_data['comment_author'] = $userdata->display_name;
     $activity_data['comment_author_email'] = $userdata->user_email;
     $activity_data['comment_author_url'] = bp_core_get_userlink($userdata->ID, false, true);
     $activity_data['comment_content'] = $activity->content;
     $activity_data['comment_type'] = $activity->type;
     $activity_data['permalink'] = bp_activity_get_permalink($activity->id, $activity);
     $activity_data['user_ID'] = $userdata->ID;
     $activity_data['user_role'] = Akismet::get_user_roles($userdata->ID);
     /**
      * Get the nonce if the new activity was submitted through the "what's up, Paul?" form.
      * This helps Akismet ensure that the update was a valid form submission.
      */
     if (!empty($_POST['_bp_as_nonce'])) {
         $activity_data['akismet_comment_nonce'] = wp_verify_nonce($_POST['_bp_as_nonce'], "_bp_as_nonce_{$userdata->ID}") ? 'passed' : 'failed';
     } elseif (!empty($activity->secondary_item_id) && !empty($_POST['_bp_as_nonce_' . $activity->secondary_item_id])) {
         $activity_data['akismet_comment_nonce'] = wp_verify_nonce($_POST["_bp_as_nonce_{$activity->secondary_item_id}"], "_bp_as_nonce_{$userdata->ID}_{$activity->secondary_item_id}") ? 'passed' : 'failed';
     }
     /**
      * Filters activity data before being sent to Akismet to inspect.
      *
      * @since 1.6.0
      *
      * @param array                $activity_data Array of activity data for Akismet to inspect.
      * @param BP_Activity_Activity $activity      Activity item data.
      */
     return apply_filters('bp_akismet_build_akismet_data_package', $activity_data, $activity);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:43,代码来源:bp-activity-akismet.php

示例6: auto_check_comment

 public static function auto_check_comment($commentdata)
 {
     self::$last_comment_result = null;
     $comment = $commentdata;
     $comment['user_ip'] = self::get_ip_address();
     $comment['user_agent'] = self::get_user_agent();
     $comment['referrer'] = self::get_referer();
     $comment['blog'] = get_option('home');
     $comment['blog_lang'] = get_locale();
     $comment['blog_charset'] = get_option('blog_charset');
     $comment['permalink'] = get_permalink($comment['comment_post_ID']);
     if (!empty($comment['user_ID'])) {
         $comment['user_role'] = Akismet::get_user_roles($comment['user_ID']);
     }
     $akismet_nonce_option = apply_filters('akismet_comment_nonce', get_option('akismet_comment_nonce'));
     $comment['akismet_comment_nonce'] = 'inactive';
     if ($akismet_nonce_option == 'true' || $akismet_nonce_option == '') {
         $comment['akismet_comment_nonce'] = 'failed';
         if (isset($_POST['akismet_comment_nonce']) && wp_verify_nonce($_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'])) {
             $comment['akismet_comment_nonce'] = 'passed';
         }
         // comment reply in wp-admin
         if (isset($_POST['_ajax_nonce-replyto-comment']) && check_ajax_referer('replyto-comment', '_ajax_nonce-replyto-comment')) {
             $comment['akismet_comment_nonce'] = 'passed';
         }
     }
     if (self::is_test_mode()) {
         $comment['is_test'] = 'true';
     }
     foreach ($_POST as $key => $value) {
         if (is_string($value)) {
             $comment["POST_{$key}"] = $value;
         }
     }
     $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, $ignore) && is_string($value)) {
             $comment["{$key}"] = $value;
         } else {
             $comment["{$key}"] = '';
         }
     }
     $post = get_post($comment['comment_post_ID']);
     $comment['comment_post_modified_gmt'] = $post->post_modified_gmt;
     $response = self::http_post(http_build_query($comment), 'comment-check');
     do_action('akismet_comment_check_response', $response);
     self::update_alert($response);
     $commentdata['comment_as_submitted'] = $comment;
     $commentdata['akismet_result'] = $response[1];
     if (isset($response[0]['x-akismet-pro-tip'])) {
         $commentdata['akismet_pro_tip'] = $response[0]['x-akismet-pro-tip'];
     }
     if ('true' == $response[1]) {
         // akismet_spam_count will be incremented later by comment_is_spam()
         self::$last_comment_result = 'spam';
         $discard = isset($commentdata['akismet_pro_tip']) && $commentdata['akismet_pro_tip'] === 'discard' && self::allow_discard();
         do_action('akismet_spam_caught', $discard);
         if ($discard) {
             // akismet_result_spam() won't be called so bump the counter here
             if ($incr = apply_filters('akismet_spam_count_incr', 1)) {
                 update_option('akismet_spam_count', get_option('akismet_spam_count') + $incr);
             }
             $redirect_to = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : get_permalink($post);
             wp_safe_redirect(esc_url_raw($redirect_to));
             die;
         }
     }
     // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
     if ('true' != $response[1] && 'false' != $response[1]) {
         if (!current_user_can('moderate_comments')) {
             // Comment status should be moderated
             self::$last_comment_result = '0';
         }
         if (function_exists('wp_next_scheduled') && function_exists('wp_schedule_single_event')) {
             if (!wp_next_scheduled('akismet_schedule_cron_recheck')) {
                 wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
             }
         }
         self::$prevent_moderation_email_for_these_comments[] = $commentdata;
     }
     if (function_exists('wp_next_scheduled') && function_exists('wp_schedule_event')) {
         // WP 2.1+: delete old comments daily
         if (!wp_next_scheduled('akismet_scheduled_delete')) {
             wp_schedule_event(time(), 'daily', 'akismet_scheduled_delete');
         }
     } elseif (mt_rand(1, 10) == 3) {
         // WP 2.0: run this one time in ten
         self::delete_old_comments();
     }
     self::set_last_comment($commentdata);
     self::fix_scheduled_recheck();
     return self::$last_comment;
 }
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:93,代码来源:class.akismet.php


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