/** * Displays the output, the login form * * @since bbPress (r2827) * * @param mixed $args Arguments * @param array $instance Instance * @uses apply_filters() Calls 'bbp_login_widget_title' with the title * @uses get_template_part() To get the login/logged in form */ public function widget($args = array(), $instance = array()) { // Get widget settings $settings = $this->parse_settings($instance); // Typical WordPress filter $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base); // bbPress filters $settings['title'] = apply_filters('bbp_login_widget_title', $settings['title'], $instance, $this->id_base); $settings['register'] = apply_filters('bbp_login_widget_register', $settings['register'], $instance, $this->id_base); $settings['lostpass'] = apply_filters('bbp_login_widget_lostpass', $settings['lostpass'], $instance, $this->id_base); echo $args['before_widget']; if (!empty($settings['title'])) { echo $args['before_title'] . $settings['title'] . $args['after_title']; } if (!is_user_logged_in()) { ?> <form method="post" action="<?php bbp_wp_login_action(array('context' => 'login_post')); ?> " class="bbp-login-form"> <fieldset> <legend><?php _e('Log In', 'bbpress'); ?> </legend> <div class="bbp-username form-group"> <label for="user_login" class="sr-only"><?php _e('Username', 'bbpress'); ?> : </label> <div class="input-group"> <span class="input-group-addon"> <span class="glyphicon ipt-icomoon-user"></span> </span> <input placeholder="<?php _e('Username', 'bbpress'); ?> " class="form-control" type="text" name="log" value="<?php bbp_sanitize_val('user_login', 'text'); ?> " size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?> " /> </div> </div> <div class="bbp-password form-group"> <label for="user_pass" class="sr-only"><?php _e('Password', 'bbpress'); ?> : </label> <div class="input-group"> <span class="input-group-addon"> <span class="glyphicon ipt-icomoon-console"></span> </span> <input placeholder="<?php _e('Password', 'bbpress'); ?> " class="form-control" type="password" name="pwd" value="<?php bbp_sanitize_val('user_pass', 'password'); ?> " size="20" id="user_pass" tabindex="<?php bbp_tab_index(); ?> " /> </div> </div> <?php do_action('login_form'); ?> <div class="bbp-remember-me checkbox"> <input type="checkbox" name="rememberme" value="forever" <?php checked(bbp_get_sanitize_val('rememberme', 'checkbox'), true, true); ?> id="rememberme" tabindex="<?php bbp_tab_index(); ?> " /> <label for="rememberme"><?php _e('Remember Me', 'bbpress'); ?> </label> </div> <div class="bbp-submit-wrapper btn-group"> <?php if (!empty($settings['lostpass'])) { ?> <a href="<?php echo esc_url($settings['lostpass']); ?> " title="<?php esc_attr_e('Lost Password', 'bbpress'); ?> " class="bbp-lostpass-link btn btn-default"><span class="glyphicon ipt-icomoon-info"></span></a> <?php } ?> <?php if (!empty($settings['register'])) { ?> <a href="<?php echo esc_url($settings['register']); ?> " title="<?php esc_attr_e('Register', 'bbpress'); ?> " class="bbp-register-link btn btn-default"><span class="glyphicon ipt-icomoon-signup"></span> <?php _e('Register', 'bbpress'); ?> </a> <?php } ?> <button class="btn btn-primary" type="submit" name="user-submit" id="user-submit" tabindex="<?php bbp_tab_index(); ?> " class="button submit user-submit"><span class="glyphicon ipt-icomoon-switch"></span> <?php _e('Log In', 'bbpress'); ?> </button> </div> <?php bbp_user_login_fields(); ?> </fieldset> </form> <?php } else { ?> <div class="bbp-logged-in"> <a href="<?php bbp_user_profile_url(bbp_get_current_user_id()); ?> " class="submit user-submit thumbnail pull-left"><?php echo get_avatar(bbp_get_current_user_id(), '64'); ?> </a> <h4><?php bbp_user_profile_link(bbp_get_current_user_id()); ?> </h4> <div class="btn-group"> <a class="btn btn-default btn-sm" href="<?php bbp_user_profile_edit_url(bbp_get_current_user_id()); ?> " title="<?php printf(esc_attr__("Edit Your Profile", 'ipt_kb')); ?> "><span class="glyphicon glyphicon-edit"></span> <?php _e('Edit', 'bbpress'); ?> </a> <?php bbp_logout_link(); ?> </div> <div class="clearfix"></div> <div class="list-group"> <a href="<?php bbp_user_profile_url(bbp_get_current_user_id()); ?> " class="list-group-item bbp-user-forum-role <?php if (bbp_is_user_home() && bbp_is_single_user_profile()) { echo 'active'; } ?> "> <span class="glyphicon ipt-icomoon-user4"></span> <?php printf(__('%s Forum Role', 'ipt_kb'), '<span class="badge">' . bbp_get_user_display_role(bbp_get_current_user_id()) . '</span>'); ?> </a> <a href="<?php bbp_user_topics_created_url(bbp_get_current_user_id()); ?> " class="list-group-item bbp-user-topic-count <?php if (bbp_is_user_home() && bbp_is_single_user_topics()) { echo 'active'; } ?> "> <span class="glyphicon ipt-icomoon-bubbles4"></span> <?php printf(__('%s Topics Started', 'ipt_kb'), '<span class="badge">' . bbp_get_user_topic_count_raw(bbp_get_current_user_id()) . '</span>'); ?> </a> <a href="<?php bbp_user_replies_created_url(bbp_get_current_user_id()); ?> " class="list-group-item bbp-user-reply-count <?php if (bbp_is_user_home() && bbp_is_single_user_replies()) { echo 'active'; } ?> "> <span class="glyphicon ipt-icomoon-reply"></span> <?php printf(__('%s Replies Created', 'ipt_kb'), '<span class="badge">' . bbp_get_user_reply_count_raw(bbp_get_current_user_id()) . '</span>'); ?> </a> <?php if (bbp_is_favorites_active()) { ?> <a href="<?php bbp_favorites_permalink(bbp_get_current_user_id()); ?> " class="list-group-item bbp-user-favorite-count <?php if (bbp_is_user_home() && bbp_is_favorites()) { echo 'active'; } ?> " title="<?php printf(esc_attr__("Your Favorites", 'ipt_kb')); ?> "> <span class="glyphicon ipt-icomoon-heart"></span> <?php printf(__('%s Favorites', 'ipt_kb'), '<span class="badge">' . count(bbp_get_user_favorites_topic_ids(bbp_get_current_user_id())) . '</span>'); ?> </a> <?php } ?> <?php if (bbp_is_subscriptions_active()) { ?> <a href="<?php bbp_subscriptions_permalink(bbp_get_current_user_id()); ?> " class="list-group-item bbp-user-subscribe-count <?php if (bbp_is_user_home() && bbp_is_subscriptions()) { echo 'active'; } ?> " title="<?php printf(esc_attr__("Your Subscriptions", 'ipt_kb')); ?> "> <span class="glyphicon ipt-icomoon-bookmarks"></span> <?php printf(__('%s Subscriptions', 'ipt_kb'), '<span class="badge">' . count(bbp_get_user_subscribed_topic_ids(bbp_get_current_user_id())) . '</span>'); ?> </a> <?php } ?> </div> </div> <?php } echo $args['after_widget']; }
<?php do_action('bbp_theme_before_reply_author_details'); ?> <?php bbp_reply_author_link(array('sep' => '', 'show_role' => true)); ?> <div class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?> </div> <div class="bbps-post-count"><?php printf(__('Post count: %s', 'framework'), bbp_get_user_reply_count_raw(bbp_get_reply_author_id())); ?> </div> <?php if (bbp_is_user_keymaster()) { ?> <?php do_action('bbp_theme_before_reply_author_admin_details'); ?> <div class="bbp-reply-ip"><?php bbp_author_ip(bbp_get_reply_id()); ?> </div>
<?php if (bbp_get_displayed_user_field('description')) { ?> <p class="bbp-user-description"><?php bbp_displayed_user_field('description'); ?> </p> <?php } ?> <p class="bbp-user-forum-role"><?php printf(__('Forum Role: %s', 'firmasite'), bbp_get_user_display_role()); ?> </p> <p class="bbp-user-topic-count"><?php printf(__('Topics Started: %s', 'firmasite'), bbp_get_user_topic_count_raw()); ?> </p> <p class="bbp-user-reply-count"><?php printf(__('Replies Created: %s', 'firmasite'), bbp_get_user_reply_count_raw()); ?> </p> </div> </div><!-- #bbp-author-topics-started --> <?php do_action('bbp_template_after_user_profile');
" class="list-group-item active bbp-user-forum-role"><span class="glyphicon ipt-icon-user4"></span> <?php printf(__('%s Forum Role', 'ipt_kb'), '<span class="badge">' . bbp_get_user_display_role() . '</span>'); ?> </a> <a href="<?php bbp_user_topics_created_url(); ?> " class="list-group-item bbp-user-topic-count"><span class="glyphicon ipt-icon-bubbles4"></span> <?php printf(__('%s Topics Started:', 'ipt_kb'), '<span class="badge">' . bbp_get_user_topic_count_raw() . '</span>'); ?> </a> <a href="<?php bbp_user_replies_created_url(); ?> " class="list-group-item bbp-user-reply-count"><span class="glyphicon ipt-icon-reply"></span> <?php printf(__('%s Replies Created', 'ipt_kb'), '<span class="badge">' . bbp_get_user_reply_count_raw() . '</span>'); ?> </a> <?php if (bbp_is_favorites_active()) { ?> <a href="<?php bbp_favorites_permalink(); ?> " class="list-group-item bbp-user-favorite-count"><span class="glyphicon ipt-icon-heart"></span> <?php printf(__('%s Favorites', 'ipt_kb'), '<span class="badge">' . count(bbp_get_user_favorites_topic_ids()) . '</span>'); ?> </a> <?php } ?>
<?php if (bbp_get_displayed_user_field('description')) { ?> <p class="bbp-user-description"><?php bbp_displayed_user_field('description'); ?> </p> <?php } ?> <p class="bbp-user-forum-role"><?php printf(__('Forum Role: %s', 'bbpress'), bbp_get_user_display_role()); ?> </p> <p class="bbp-user-topic-count"><?php printf(__('Topics Started: %s', 'bbpress'), bbp_get_user_topic_count_raw()); ?> </p> <p class="bbp-user-reply-count"><?php printf(__('Replies Created: %s', 'bbpress'), bbp_get_user_reply_count_raw()); ?> </p> </div> </div><!-- #bbp-author-topics-started --> <?php do_action('bbp_template_after_user_profile');
<?php do_action('bbp_theme_before_reply_author_details'); ?> <?php bbp_reply_author_link(array('sep' => '', 'show_role' => true)); ?> <div class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?> </div> <div class="bbps-post-count"><?php printf(__('Post count: %s', 'evolve'), bbp_get_user_reply_count_raw(bbp_get_reply_author_id())); ?> </div> <?php if (bbp_is_user_keymaster()) { ?> <?php do_action('bbp_theme_before_reply_author_admin_details'); ?> <div class="bbp-reply-ip"><?php bbp_author_ip(bbp_get_reply_id()); ?> </div>
/** * Bump the reply count for a user by a certain amount. * * @since 2.6.0 bbPress (r5309) * * @param int $user_id * @param int $difference * @uses bbp_get_user_reply_count() To get the users current reply count * @uses bbp_set_user_reply_count() To set the users new reply count */ function bbp_bump_user_reply_count($user_id = 0, $difference = 1) { // Bail if no bump if (empty($difference)) { return false; } // Validate user ID $user_id = bbp_get_user_id($user_id); if (empty($user_id)) { return false; } // Check meta for count, or query directly if not found $count = bbp_get_user_reply_count($user_id, true); if (empty($count)) { $count = bbp_get_user_reply_count_raw($user_id); } $difference = (int) $difference; $user_reply_count = (int) ($count + $difference); // Add them up and filter them $new_count = (int) apply_filters('bbp_bump_user_reply_count', $user_reply_count, $user_id, $difference, $count); return bbp_update_user_reply_count($user_id, $new_count); }
/** * EDD Forum Sidebar * * @since 1.0.0 * @return void */ function edd_bbp_sidebar() { global $post; $user_id = get_the_author_meta('ID'); $user_data = get_userdata($user_id); ?> <div class="box"> <?php do_action('edd_bbp_sidebar'); ?> <h3><?php echo get_the_author_meta('first_name') . ' ' . get_the_author_meta('last_name'); ?> </h3> <p class="bbp-user-forum-role"><?php printf('Forum Role: %s', bbp_get_user_display_role($user_id)); ?> </p> <p class="bbp-user-topic-count"><?php printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id)); ?> </p> <p class="bbp-user-reply-count"><?php printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id)); ?> </p> <div class="rcp_support_status"> <h4>Priority Support Access</h4> <?php if (function_exists('rcp_is_active')) { if (rcp_is_active($user_id)) { ?> <p>Has <strong>Priority Support</strong> access.</p> <?php } elseif (rcp_is_expired($user_id)) { ?> <p><strong>Priority Support</strong> access has <span style="color:red;">expired</span>.</p> <?php } else { ?> <p>Has no priority support accesss</p> <?php } } ?> </div><!-- /.rcp_support_status --> <div class="edd_users_purchases"> <h4>User's Purchases:</h4> <?php $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any'); if ($purchases) { echo '<ul>'; foreach ($purchases as $purchase) { echo '<li>'; echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>'; $downloads = edd_get_payment_meta_downloads($purchase->ID); foreach ($downloads as $download) { echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>'; } if (function_exists('edd_software_licensing')) { $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID); if ($licenses) { echo '<strong>Licenses:</strong><br/>'; foreach ($licenses as $license) { $key = edd_software_licensing()->get_license_key($license->ID); echo '<a href="' . admin_url('edit.php?post_type=download&page=edd-licenses&s=' . $key) . '">' . $key . '</a>'; echo ' - ' . edd_software_licensing()->get_license_status($license->ID); echo '<br/>'; } } echo '<hr/>'; } echo '</li>'; } echo '</ul>'; } else { echo '<p>This user has never purchased anything.</p>'; } ?> </div> </div> <?php }
<?php if (bbp_get_displayed_user_field('description')) { ?> <p class="bbp-user-description"><?php bbp_displayed_user_field('description'); ?> </p> <?php } ?> <p class="bbp-user-forum-role"><?php printf(esc_html__('Forum Role: %s', 'monsoon'), bbp_get_user_display_role()); ?> </p> <p class="bbp-user-topic-count"><?php printf(esc_html__('Topics Started: %s', 'monsoon'), bbp_get_user_topic_count_raw()); ?> </p> <p class="bbp-user-reply-count"><?php printf(esc_html__('Replies Created: %s', 'monsoon'), bbp_get_user_reply_count_raw()); ?> </p> </div> </div><!-- #bbp-author-topics-started --> <?php do_action('bbp_template_after_user_profile');
<?php /** * Replies Loop - Single Reply * * @package bbPress * @subpackage Theme */ $cb_current_user = bbp_get_reply_author_id(); $cb_bbp_total_post_count = bbp_get_user_reply_count_raw($cb_current_user) + bbp_get_user_topic_count_raw($cb_current_user); ?> <div id="post-<?php bbp_reply_id(); ?> " class="bbp-reply-header"> <div class="bbp-meta"> <span class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?> </span> <?php if (bbp_is_single_user_replies()) { ?> <span class="bbp-header"> <?php _e('in reply to: ', 'bbpress');
/** * The shortcode handler for the [show_avatar] shortcode. * * Example: [show_avatar id=pbearne@tycoelectronics.com avatar_size=30 align=right] */ function shortcode_handler($atts, $content = null) { $extraClass = ''; $hrefStart = ''; $name = ''; $bio = ''; $last_post = ''; $style = ''; $email = ''; $link = ''; $id = ''; // get id or email if (!empty($atts['id'])) { $id = preg_replace('[^\\w\\.\\@\\-]', '', $atts['id']); } if (empty($id) && !empty($atts['email'])) { $id = preg_replace('[^\\w\\.\\@\\-]', '', $atts['email']); } // get avatar size $bio_length = -1; if (!empty($atts['max_bio_length'])) { $bio_length = intval($atts['max_bio_length']); } // get avatar size $avatar_size = false; if (!empty($atts['avatar_size'])) { $avatar_size = intval($atts['avatar_size']); } // get alignment if (!empty($atts['align'])) { switch ($atts['align']) { case 'left': $style = "float: left; margin-right: 10px;"; break; case 'right': $style = "float: right; margin-left: 10px;"; break; case 'center': $style = "text-align: center; width: 100%;"; break; } } if (!empty($id)) { $avatar = get_avatar($id, $avatar_size); } else { $avatar = __("[show_author shortcode: please set id/email attribute]"); } // is there an user link request if (!empty($atts['user_link']) || !empty($atts['show_biography']) || !empty($atts['show_postcount']) || !empty($atts['show_name']) || !empty($atts['show_email'])) { // try to fetch user profile $isUser = true; if (!is_numeric($id)) { if (email_exists($id)) { $id = email_exists($id); } else { $isUser = false; } } if ($isUser) { $all_meta_for_user = get_user_meta($id); if (count($all_meta_for_user) == 0) { $isUser = false; } } if ($isUser) { if (!empty($atts['user_link'])) { switch ($atts['user_link']) { case 'authorpage': $link = get_author_posts_url($id); break; case 'website': $link = get_the_author_meta('user_url', $id); if (empty($link) || $link == 'http://') { $link = false; } break; case 'blog': if (AA_is_wpmu()) { $blog = get_active_blog_for_user($id); if (!empty($blog->siteurl)) { $link = $blog->siteurl; } } break; case 'bp_memberpage': if (function_exists('bp_core_get_user_domain')) { $link = bp_core_get_user_domain($id); } elseif (function_exists('bp_core_get_userurl')) { // BP versions < 1.1 $link = bp_core_get_userurl($id); } break; case 'bbpress_memberpage': if (function_exists('bbp_get_user_profile_url')) { $link = bbp_get_user_profile_url($id); } if (empty($link) || $link == 'http://') { $link = false; } break; case 'last_post': $recent = get_posts(array('author' => $id, 'orderby' => 'date', 'order' => 'desc', 'numberposts' => 1)); $link = get_permalink($recent[0]->ID); break; case 'last_post_filtered': $recent = get_posts(array('author' => $id, 'orderby' => 'date', 'order' => 'desc', 'numberposts' => 1)); $link = get_permalink($recent[0]->ID); break; case 'last_post_all': $last_post = get_most_recent_post_of_user($id); $link = get_permalink($last_post['post_id']); break; } if ($link) { $hrefStart = '<a href="' . $link . '">'; } } if (!empty($atts['show_name'])) { $name = '<br />' . get_the_author_meta('display_name', $id); $extraClass .= ' with-name'; } if (!empty($atts['show_email'])) { $userEmail = get_the_author_meta('user_email', $id); $email = "<div class='email'><a href='mailto:" . $userEmail . "''>" . $userEmail . "</a></div>"; if (empty($email)) { $extraClass .= 'email-missing'; } else { $extraClass .= ' with-email'; } } if (!empty($atts['show_postcount'])) { $name .= ' (' . ($postcount = $this->userlist->get_user_postcount($id) . ')'); } if (!empty($atts['show_bbpress_post_count'])) { if (function_exists('bbp_get_user_topic_count_raw')) { $BBPRESS_postcount = bbp_get_user_topic_count_raw($id) + bbp_get_user_reply_count_raw($id); $name .= ' (' . ($postcount = $BBPRESS_postcount . ')'); } } if (!empty($atts['show_biography'])) { $biography = get_the_author_meta('description', $id); if (0 < $bio_length) { $biography = $this->userlist->truncate_html(wpautop($biography, true), apply_filters('aa_user_bio_length', $bio_length)); } else { $biography = wpautop($biography, true); } if (!empty($atts['show_name'])) { $bio = '<div class="bio bio-length-' . $atts['max_bio_length'] . '">' . $biography . '</div>'; } if (empty($bio)) { $extraClass .= ' biography-missing'; } else { $extraClass .= ' with-biography bio-length-' . $bio_length; } } // show last_post? if (isset($atts['show_last_post']) && strlen($atts['show_last_post']) > 0) { $last_post = '<div class="last_post">' . $this->userlist->aa_get_last_post($id) . '</div>'; if (empty($last_post)) { $extraClass .= ' last-post-missing'; } else { $extraClass .= ' with-last-post'; } } } } $hrefend = ''; if (!empty($hrefStart)) { $hrefend = '</a>'; } if (!empty($style)) { $style = ' style="' . $style . '"'; } return '<div class="shortcode-show-avatar ' . $extraClass . '"' . $style . '>' . $hrefStart . $avatar . $name . $last_post . $hrefend . $bio . $email . '</div>' . $content; }
/** * Forum Sidebar * * @since 1.0.0 * @return void */ function wi_bbp_sidebar() { global $post; $user_id = get_the_author_meta('ID'); $user_data = get_userdata($user_id); ?> <div class="box"> <?php do_action('wi_bbp_sidebar'); ?> <h3><?php echo get_the_author_meta('first_name') . ' ' . get_the_author_meta('last_name'); ?> </h3> <p class="bbp-user-forum-role"><?php printf('Forum Role: %s', bbp_get_user_display_role($user_id)); ?> </p> <p class="bbp-user-topic-count"><?php printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id)); ?> </p> <p class="bbp-user-reply-count"><?php printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id)); ?> </p> <div class="wi_users_purchases"> <h3><?php _e('User\'s Purchases:', 'wi_bbp'); ?> </h3> <?php $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any'); if ($purchases) { echo '<ul>'; foreach ($purchases as $purchase) { echo '<li>'; echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=give-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>'; $downloads = edd_get_payment_meta_downloads($purchase->ID); foreach ($downloads as $download) { echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>'; } //Check license key if (function_exists('edd_software_licensing')) { $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID); if ($licenses) { echo '<strong>Licenses:</strong><br/>'; foreach ($licenses as $license) { $key = edd_software_licensing()->get_license_key($license->ID); echo '<a href="' . admin_url('edit.php?post_type=download&page=give-licenses&s=' . $key) . '">' . $key . '</a>'; echo ' - ' . edd_software_licensing()->get_license_status($license->ID); echo '<br/>'; } } echo '<hr/>'; } echo '</li>'; } echo '</ul>'; } else { echo '<p>This user has never purchased anything.</p>'; } ?> </div> </div> <?php }
_e('Forum Role', 'omega-td'); ?> </dt> <dd><?php echo bbp_get_user_display_role(); ?> </dd> <dt><?php _e('Topics Started', 'omega-td'); ?> </dt> <dd><?php echo bbp_get_user_topic_count_raw(); ?> </dd> <dt><?php _e('Replies Created', 'omega-td'); ?> </dt> <dd><?php echo bbp_get_user_reply_count_raw(); ?> </dd> </dl> </div> </div><!-- #bbp-author-topics-started --> <?php do_action('bbp_template_after_user_profile');
/** * @covers ::bbp_get_user_reply_count_raw */ public function test_bbp_get_user_reply_count_raw() { $u = $this->factory->user->create(); $t = $this->factory->topic->create(); $r = $this->factory->reply->create_many(3, array('post_parent' => $t, 'post_author' => $u, 'reply_meta' => array('topic_id' => $t))); $count = bbp_get_user_reply_count_raw($u); $this->assertSame(3, $count); $r = $this->factory->reply->create_many(3, array('post_parent' => $t, 'post_author' => $u, 'reply_meta' => array('topic_id' => $t))); $count = bbp_get_user_reply_count_raw($u); $this->assertSame(6, $count); }
<?php /** * Replies Loop - Single Reply * * @package bbPress * @subpackage Theme */ $reply_id = bbp_get_reply_id(); $user_id = bbp_get_reply_author_id($reply_id); $topic_count = bbp_get_user_topic_count_raw($user_id); $reply_count = bbp_get_user_reply_count_raw($user_id); $post_count = (int) $topic_count + $reply_count; ?> <li id="post-<?php bbp_reply_id(); ?> " <?php bbp_reply_class(0, array('media')); ?> > <?php do_action('bbp_theme_before_reply_author_details'); ?> <div class="bbp_author_details"> <?php bbp_reply_author_link(array('sep' => '', 'size' => 92));
/** * The shortcode handler for the [show_avatar] shortcode. * * Example: [show_avatar id=pbearne@tycoelectronics.com avatar_size=30 align=right] */ function shortcode_handler($atts, $content = null) { $extraClass = ""; $hrefStart = ""; $name = ""; $bio = ""; $style = ""; $email = ""; $link = ""; $id = ''; // get id or email if (!empty($atts['id'])) { $id = preg_replace('[^\\w\\.\\@\\-]', '', $atts['id']); } if (empty($id) && !empty($atts['email'])) { $id = preg_replace('[^\\w\\.\\@\\-]', '', $atts['email']); } // get avatar size $avatar_size = false; if (!empty($atts['avatar_size'])) { $avatar_size = intval($atts['avatar_size']); } // get alignment if (!empty($atts['align'])) { switch ($atts['align']) { case 'left': $style = "float: left; margin-right: 10px;"; break; case 'right': $style = "float: right; margin-left: 10px;"; break; case 'center': $style = "text-align: center; width: 100%;"; break; } } if (!empty($id)) { $avatar = get_avatar($id, $avatar_size); } else { $avatar = __("[show_author shortcode: please set id/email attribute]"); } // is there an user link request if (!empty($atts['user_link']) || !empty($atts['show_biography']) || !empty($atts['show_postcount']) || !empty($atts['show_name']) || !empty($atts['show_email'])) { // try to fetch user profile $isUser = true; if (!is_numeric($id)) { if (email_exists($id)) { $id = email_exists($id); } else { $isUser = false; } } if ($isUser) { $all_meta_for_user = get_user_meta($id); if (count($all_meta_for_user) == 0) { $isUser = false; } } if ($isUser) { if (!empty($atts['user_link'])) { switch ($atts['user_link']) { case 'authorpage': $link = get_author_posts_url($id); break; case 'website': $link = get_the_author_meta('user_url', $id); if (empty($link) || $link == 'http://') { $link = false; } break; case 'blog': if (AA_is_wpmu()) { $blog = get_active_blog_for_user($id); if (!empty($blog->siteurl)) { $link = $blog->siteurl; } } break; case 'bp_memberpage': if (function_exists('bp_core_get_user_domain')) { $link = bp_core_get_user_domain($id); } elseif (function_exists('bp_core_get_userurl')) { // BP versions < 1.1 $link = bp_core_get_userurl($id); } break; case 'bbpress_memberpage': if (function_exists('bbp_get_user_profile_url')) { $link = bbp_get_user_profile_url($id); } if (empty($link) || $link == 'http://') { $link = false; } break; } if ($link) { $hrefStart = '<a href="' . $link . '">'; } } if (!empty($atts['show_name'])) { $name = '<br />' . get_the_author_meta('display_name', $id); $extraClass .= ' with-name'; } if (!empty($atts['show_email'])) { $userEmail = get_the_author_meta('user_email', $id); $email = "<div class='email'><a href='mailto:" . $userEmail . "''>" . $userEmail . "</a></div>"; if (empty($email)) { $extraClass .= 'email-missing'; } else { $extraClass .= ' with-email'; } } if (!empty($atts['show_postcount'])) { require_once 'UserList.class.php'; $this->userlist = new UserList(); $name .= ' (' . ($postcount = $this->userlist->get_user_postcount($id) . ')'); } if (!empty($atts['show_bbpress_post_count'])) { if (function_exists('bbp_get_user_topic_count_raw')) { $BBPRESS_postcount = bbp_get_user_topic_count_raw($id) + bbp_get_user_reply_count_raw($id); $name .= ' (' . ($postcount = $BBPRESS_postcount . ')'); } } if (!empty($atts['show_biography'])) { $bio = get_the_author_meta('description', $id); if (!empty($atts['show_name'])) { $bio = '<div class="bio">' . $bio . '</div>'; } if (empty($bio)) { $extraClass .= 'biography-missing'; } else { $extraClass .= ' with-biography'; } } } } $hrefend = ''; if (!empty($hrefStart)) { $hrefend = '</a>'; } if (!empty($style)) { $style = ' style="' . $style . '"'; } return '<div class="shortcode-show-avatar ' . $extraClass . '"' . $style . '>' . $hrefStart . $avatar . $name . $hrefend . $bio . $email . '</div>' . $content; }
/** * Given two users, this function compares the user's post count. * * @access private * * @param WP_User $a * @param WP_User $b * * @return int result of a string compare of the user display names. */ function _user_cmp_BBPRESS_post_count($a, $b) { $ac = bbp_get_user_topic_count_raw($a->user_id) + bbp_get_user_reply_count_raw($a->user_id); $bc = bbp_get_user_topic_count_raw($b->user_id) + bbp_get_user_reply_count_raw($b->user_id); if ($ac == $bc) { return 0; } return $this->_sort_direction() * ($ac < $bc ? -1 : 1); }
/** * Add post date, author post count and author ip to the author element. */ public function add_author_post_date_count_ip() { ?> <div class="bbp-reply-post-date"><?php bbp_reply_post_date(bbp_get_reply_id()); ?> </div> <div class="bbps-post-count"><?php printf(__('Post count: %s', 'Avada'), bbp_get_user_reply_count_raw(bbp_get_reply_author_id()) + bbp_get_user_topic_count_raw(bbp_get_reply_author_id())); ?> </div> <?php if (bbp_is_user_keymaster()) { ?> <?php do_action('bbp_theme_before_topic_author_admin_details'); ?> <div class="bbp-reply-ip fusion-reply-id"><?php bbp_author_ip(bbp_get_topic_id()); ?> </div> <?php do_action('bbp_theme_after_topic_author_admin_details'); ?> <?php } }
<?php do_action('bbp_theme_before_reply_author_details'); ?> <?php bbp_reply_author_link(array('sep' => '', 'show_role' => true)); ?> <div class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?> </div> <div class="bbps-post-count"><?php sprintf(__('Post count: %s', 'Avada'), bbp_get_user_reply_count_raw(bbp_get_reply_author_id()) + bbp_get_user_topic_count_raw(bbp_get_reply_author_id())); ?> </div> <?php if (bbp_is_user_keymaster()) { ?> <?php do_action('bbp_theme_before_reply_author_admin_details'); ?> <div class="bbp-reply-ip"><?php bbp_author_ip(bbp_get_reply_id()); ?> </div>
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { //No EDD? Bail if (!class_exists('Easy_Digital_Downloads')) { return false; } //Not EDD admin? Bail if (!current_user_can('view_shop_sensitive_data')) { return false; } //Handle before_widget args echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } $user_id = get_the_author_meta('ID'); $user_data = get_userdata($user_id); ?> <div class="box"> <?php do_action('wi_bbp_sidebar'); ?> <h3><?php echo get_the_author_meta('first_name') . ' ' . get_the_author_meta('last_name'); ?> </h3> <p class="bbp-user-forum-role"><?php printf('Forum Role: %s', bbp_get_user_display_role($user_id)); ?> </p> <p class="bbp-user-topic-count"><?php printf('Topics Started: %s', bbp_get_user_topic_count_raw($user_id)); ?> </p> <p class="bbp-user-reply-count"><?php printf('Replies Created: %s', bbp_get_user_reply_count_raw($user_id)); ?> </p> <div class="wi_users_purchases"> <h3><?php _e('User\'s Purchases:', 'wi_bbp'); ?> </h3> <?php $purchases = edd_get_users_purchases($user_data->user_email, 100, false, 'any'); if ($purchases) { echo '<ul>'; foreach ($purchases as $purchase) { echo '<li>'; echo '<strong><a href="' . admin_url('edit.php?post_type=download&page=give-payment-history&view=view-order-details&id=' . $purchase->ID) . '">#' . $purchase->ID . ' - ' . edd_get_payment_status($purchase, true) . '</a></strong><br/>'; $downloads = edd_get_payment_meta_downloads($purchase->ID); foreach ($downloads as $download) { echo get_the_title($download['id']) . ' - ' . date('F j, Y', strtotime($purchase->post_date)) . '<br/>'; } //Check license key if (function_exists('edd_software_licensing')) { $licenses = edd_software_licensing()->get_licenses_of_purchase($purchase->ID); if ($licenses) { echo '<strong>' . __('Licenses:', 'edd') . '</strong><br/>'; foreach ($licenses as $license) { $key = edd_software_licensing()->get_license_key($license->ID); $download_id = edd_software_licensing()->get_download_by_license($key); $title = get_the_title($download_id); //output license URL echo $title . ' - <a href="' . admin_url('edit.php?post_type=download&page=give-licenses&s=' . $key) . '">' . $key . '</a>'; echo ' - ' . edd_software_licensing()->get_license_status($license->ID); echo '<br/>'; } } echo '<hr/>'; } echo '</li>'; } echo '</ul>'; } else { echo '<p>' . __('This user has never purchased anything.', 'wi_bbp') . '</p>'; } ?> </div> </div> <?php //After widget args echo $args['after_widget']; return false; }
/** * Update a user's total post count * @version 1.0.0 */ function apoc_update_post_count($user_id, $type = 'all') { // Only do this for registered users if (0 == $user_id) { return false; } // Get existing post count $posts = get_user_meta($user_id, 'post_count', true); // If the meta does not yet exist, do a full update if (empty($posts)) { $posts = array(); $type == 'all'; } // Articles if ('all' == $type || 'articles' == $type) { $articles = get_user_article_count($user_id); $posts['articles'] = $articles > 0 ? $articles : 0; } // Comments if ('all' == $type || 'comments' == $type) { $comments = get_user_comment_count($user_id); $posts['comments'] = $comments > 0 ? $comments : 0; } // Forum topics and replies if ('all' == $type || 'forums' == $type) { $topics = bbp_get_user_topic_count_raw($user_id); $posts['topics'] = $topics > 0 ? $topics : 0; $replies = bbp_get_user_reply_count_raw($user_id); $posts['replies'] = $replies > 0 ? $replies : 0; } // Compute the total $posts['total'] = $posts['articles'] + $posts['topics'] + $posts['replies'] + $posts['comments']; // Save it update_user_meta($user_id, 'post_count', $posts); }
<?php } ?> <p class="bbp-user-forum-role"><span class="bold"><?php printf(__('Forum Role:', 'corporative')); ?> </span><?php printf(bbp_get_user_display_role()); ?> </p> <p class="bbp-user-topic-count"><span class="bold"><?php printf(__('Topics Started:', 'corporative')); ?> </span><?php printf(bbp_get_user_topic_count_raw()); ?> </p> <p class="bbp-user-reply-count"><span class="bold"><?php printf(__('Replies Created:', 'corporative')); ?> </span><?php printf(bbp_get_user_reply_count_raw()); ?> </p> </div> </div><!-- #bbp-author-topics-started --> <?php do_action('bbp_template_after_user_profile');
<?php if (bbp_get_displayed_user_field('description')) { ?> <p class="bbp-user-description"><?php bbp_displayed_user_field('description'); ?> </p> <?php } ?> <p class="bbp-user-forum-role"><?php printf(__('Forum Role: %s', 'wpdance'), bbp_get_user_display_role()); ?> </p> <p class="bbp-user-topic-count"><?php printf(__('Topics Started: %s', 'wpdance'), bbp_get_user_topic_count_raw()); ?> </p> <p class="bbp-user-reply-count"><?php printf(__('Replies Created: %s', 'wpdance'), bbp_get_user_reply_count_raw()); ?> </p> </div> </div><!-- #bbp-author-topics-started --> <?php do_action('bbp_template_after_user_profile');