コード例 #1
0
ファイル: counts.php プロジェクト: joeyblake/bbpress
 /**
  * @covers ::bbp_user_post_count
  * @covers ::bbp_get_user_post_count
  */
 function test_bbp_get_user_post_count()
 {
     $u = $this->factory->user->create();
     $int_value = 3;
     $integer = true;
     // Add reply count
     bbp_update_user_reply_count($u, $int_value);
     // Count
     $count = bbp_get_user_post_count($u, $integer);
     $this->assertSame($int_value, $count);
     // Add topic count
     bbp_update_user_topic_count($u, $int_value);
     $double_value = $int_value * 2;
     // Count + Count
     $double_count = bbp_get_user_post_count($u, true);
     $this->assertSame($double_value, $double_count);
     // Output
     $double_formatted_value = bbp_number_format($double_value);
     $this->expectOutputString($double_formatted_value);
     bbp_user_post_count($u);
 }
コード例 #2
0
ファイル: options.php プロジェクト: joeyblake/bbpress
/**
 * Output a users total post count
 *
 * @since 2.1.0 bbPress (r3632)
 *
 * @param int $user_id
 * @param boolean $integer Optional. Whether or not to format the result
 * @uses bbp_get_user_post_count()
 * @return string
 */
function bbp_user_post_count($user_id = 0, $integer = false)
{
    echo bbp_get_user_post_count($user_id, $integer);
}
コード例 #3
0
ファイル: bbp-user-options.php プロジェクト: rmccue/bbPress
/**
 * Output a users total post count
 *
 * @since bbPress (r3632)
 *
 * @param int $user_id
 * @uses bbp_get_user_post_count()
 * @return string
 */
function bbp_user_post_count($user_id = 0)
{
    echo bbp_get_user_post_count($user_id);
}
コード例 #4
0
ファイル: akismet.php プロジェクト: joeyblake/bbpress
 /**
  * Converts topic/reply data into Akismet comment checking format
  *
  * @since 2.0.0 bbPress (r3277)
  *
  * @param string $post_data
  *
  * @uses get_userdata() To get the user data
  * @uses bbp_filter_anonymous_user_data() To get anonymous user data
  * @uses bbp_get_topic_permalink() To get the permalink of the topic
  * @uses bbp_get_reply_url() To get the permalink of the reply
  * @uses bbp_current_author_ip() To get the IP address of the current user
  * @uses BBP_Akismet::maybe_spam() To check if post is spam
  * @uses BBP_Akismet::get_user_roles() To get the role(s) of the current user
  * @uses do_action() To call the 'bbp_akismet_spam_caught' hook
  * @uses add_filter() To call the 'bbp_new_reply_pre_set_terms' hook
  *
  * @return array Array of post data
  */
 public function check_post($post_data)
 {
     // Define local variables
     $user_data = array();
     $post_permalink = '';
     // Post is not published
     if (bbp_get_public_status_id() !== $post_data['post_status']) {
         return $post_data;
     }
     // Cast the post_author to 0 if it's empty
     if (empty($post_data['post_author'])) {
         $post_data['post_author'] = 0;
     }
     /** Author ************************************************************/
     $user_data['last_active'] = '';
     $user_data['registered'] = date('Y-m-d H:i:s');
     $user_data['total_posts'] = (int) bbp_get_user_post_count($post_data['post_author']);
     // Get user data
     $userdata = get_userdata($post_data['post_author']);
     $anonymous_data = bbp_filter_anonymous_post_data();
     // Author is anonymous
     if (!empty($anonymous_data)) {
         $user_data['name'] = $anonymous_data['bbp_anonymous_name'];
         $user_data['email'] = $anonymous_data['bbp_anonymous_email'];
         $user_data['website'] = $anonymous_data['bbp_anonymous_website'];
         // Author is logged in
     } elseif (!empty($userdata)) {
         $user_data['name'] = $userdata->display_name;
         $user_data['email'] = $userdata->user_email;
         $user_data['website'] = $userdata->user_url;
         $user_data['registered'] = $userdata->user_registered;
         // Missing author data, so set some empty strings
     } else {
         $user_data['name'] = '';
         $user_data['email'] = '';
         $user_data['website'] = '';
     }
     /** Post **************************************************************/
     if (!empty($post_data['post_parent'])) {
         // Use post parent for permalink
         $post_permalink = get_permalink($post_data['post_parent']);
         // Use post parent to get datetime of last reply on this topic
         $reply_id = bbp_get_topic_last_reply_id($post_data['post_parent']);
         if (!empty($reply_id)) {
             $user_data['last_active'] = get_post_field('post_date', $reply_id);
         }
     }
     // Pass title & content together into comment content
     $_post_content = trim($post_data['post_title'] . "\n\n" . $post_data['post_content']);
     // Put post_data back into usable array
     $_post = array('comment_author' => $user_data['name'], 'comment_author_email' => $user_data['email'], 'comment_author_url' => $user_data['website'], 'comment_content' => $_post_content, 'comment_post_ID' => $post_data['post_parent'], 'comment_type' => $post_data['post_type'], 'comment_total' => $user_data['total_posts'], 'comment_last_active_gmt' => $user_data['last_active'], 'comment_account_registered_gmt' => $user_data['registered'], 'permalink' => $post_permalink, 'referrer' => $_SERVER['HTTP_REFERER'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'user_ID' => $post_data['post_author'], 'user_ip' => bbp_current_author_ip(), 'user_role' => $this->get_user_roles($post_data['post_author']));
     // Check the post_data
     $_post = $this->maybe_spam($_post);
     // Get the result
     $post_data['bbp_akismet_result'] = $_post['bbp_akismet_result'];
     unset($_post['bbp_akismet_result']);
     // Store the data as submitted
     $post_data['bbp_post_as_submitted'] = $_post;
     // Allow post_data to be manipulated
     do_action_ref_array('bbp_akismet_check_post', $post_data);
     // Spam
     if ('true' === $post_data['bbp_akismet_result']) {
         // Let plugins do their thing
         do_action('bbp_akismet_spam_caught');
         // This is spam
         $post_data['post_status'] = bbp_get_spam_status_id();
         // We don't want your spam tags here
         add_filter('bbp_new_reply_pre_set_terms', array($this, 'filter_post_terms'), 1, 3);
         // @todo Spam counter?
     }
     // @todo Topic/reply moderation? No true/false response - 'pending' or 'draft'
     // @todo Auto-delete old spam?
     // Log the last post
     $this->last_post = $post_data;
     // Pass the data back to the filter
     return $post_data;
 }