function kleo_bbp_add_role_class($author_role, $r) { $reply_id = bbp_get_reply_id($r['reply_id']); $role = strtolower(esc_attr(bbp_get_user_display_role(bbp_get_reply_author_id($reply_id)))); $author_role = str_replace('class="', 'class="role-' . $role . ' ', $author_role); return $author_role; }
function origamiez_bbpress_shortcodes($content, $reply_id) { $reply_author = bbp_get_reply_author_id($reply_id); if (user_can($reply_author, 'publish_forums')) { $content = do_shortcode($content); } return $content; }
/** * @covers ::bbp_reply_author_id * @covers ::bbp_get_reply_author_id */ public function test_bbp_get_reply_author_id() { $u = $this->factory->user->create(); $t = $this->factory->topic->create(); $r = $this->factory->reply->create(array('post_parent' => $t, 'post_author' => $u, 'reply_meta' => array('topic_id' => $t))); $reply = bbp_get_reply_author_id($r); $this->assertSame($u, $reply); }
function pw_bbp_shortcodes($content, $reply_id) { $reply_author = bbp_get_reply_author_id($reply_id); if (user_can($reply_author, pw_bbp_parse_capability())) { return do_shortcode($content); } return $content; }
function site__bbpress_bbp_theme_after_reply_author_details() { $twitter = get_user_meta(bbp_get_reply_author_id(), 'twitter', true); if (preg_match("|https?://(www\\.)?twitter\\.com/(#!/)?@?([^/]*)|", $twitter, $matches)) { $twitter_username = $matches[3]; } else { $twitter_username = ltrim(get_user_meta(bbp_get_reply_author_id(), 'twitter', true), '@'); } if (!empty($twitter_username)) { echo '<a href="https://twitter.com/' . $twitter_username . '" target="_blank"><i class="fa fa-twitter"></i> ' . $twitter_username . '</a>'; } }
function bbp_user_online_status() { global $bbpuos_options; echo '<ul>'; $user_id = bbp_get_reply_author_id($reply_id); if ($bbpuos_options['activate'] == true) { echo '<li>'; if (is_user_online($user_id)) { echo "Online"; } else { echo "Offline"; } echo '</li>'; } }
function append_message_trigger($author_link, $r) { //we need to make sure it is a reply if (!bbp_get_reply_id()) { return $author_link; } wp_enqueue_script('popoverasync', ig_uploader()->plugin_url . 'assets/popover/popoverasync.js', array('jquery', 'ig-bootstrap', 'jquery-frame-transport')); wp_enqueue_style('igu-uploader', ig_uploader()->plugin_url . 'assets/style.css'); $new_links = explode($r['sep'], $author_link); $author_id = bbp_get_reply_author_id(bbp_get_reply_id($r['post_id'])); $message_link = do_shortcode("[pm_user user_id={$author_id} class='btn btn-xs btn-primary']"); $message_link = sprintf('<div style="%s">%s</div>', 'margin-top:5px', $message_link); array_splice($new_links, 1, 0, array($message_link)); $new_links = implode($r['sep'], $new_links); //$logger = new IG_Logger('file', 'message_bbpress.txt'); //$logger->log(var_export($new_links, true), IG_Logger::ERROR_LEVEL_DEBUG); return $new_links; }
/** * Reset main query vars and filter 'the_content' to output a bbPress * template part as needed. * * @since bbPress (r3032) * @param string $template * @uses bbp_is_single_user() To check if page is single user * @uses bbp_get_single_user_template() To get user template * @uses bbp_is_single_user_edit() To check if page is single user edit * @uses bbp_get_single_user_edit_template() To get user edit template * @uses bbp_is_single_view() To check if page is single view * @uses bbp_get_single_view_template() To get view template * @uses bbp_is_forum_edit() To check if page is forum edit * @uses bbp_get_forum_edit_template() To get forum edit template * @uses bbp_is_topic_merge() To check if page is topic merge * @uses bbp_get_topic_merge_template() To get topic merge template * @uses bbp_is_topic_split() To check if page is topic split * @uses bbp_get_topic_split_template() To get topic split template * @uses bbp_is_topic_edit() To check if page is topic edit * @uses bbp_get_topic_edit_template() To get topic edit template * @uses bbp_is_reply_edit() To check if page is reply edit * @uses bbp_get_reply_edit_template() To get reply edit template * @uses bbp_set_theme_compat_template() To set the global theme compat template */ function bbp_template_include_theme_compat($template = '') { // Bail if the template already matches a bbPress template. This includes // archive-* and single-* WordPress post_type matches (allowing // themes to use the expected format) as well as all bbPress-specific // template files for users, topics, forums, etc... if (!empty(bbpress()->theme_compat->bbpress_template)) { return $template; } /** Users *************************************************************/ if (bbp_is_single_user_edit() || bbp_is_single_user()) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => esc_attr(bbp_get_displayed_user_field('display_name')), 'post_status' => bbp_get_public_status_id(), 'is_archive' => false, 'comment_status' => 'closed')); /** Forums ************************************************************/ // Forum archive } elseif (bbp_is_forum_archive()) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_forum_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed')); // Single Forum } elseif (bbp_is_forum_edit() || bbp_is_single_forum()) { // Reset post bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_forum_id()), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed')); /** Topics ************************************************************/ // Topic archive } elseif (bbp_is_topic_archive()) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed')); // Single Topic } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) { // Reset post bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_topic_id()), 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed')); /** Replies ***********************************************************/ // Reply archive } elseif (is_post_type_archive(bbp_get_reply_post_type())) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed')); // Single Reply } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) { // Reset post bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_reply_id()), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed')); /** Views *************************************************************/ } elseif (bbp_is_single_view()) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed')); /** Topic Tags ********************************************************/ // Topic Tag Edit } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) { // Stash the current term in a new var set_query_var('bbp_topic_tag', get_query_var('term')); // Reset the post with our new title bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed')); } /** * If we are relying on bbPress's built in theme compatibility to load * the proper content, we need to intercept the_content, replace the * output, and display ours instead. * * To do this, we first remove all filters from 'the_content' and hook * our own function into it, which runs a series of checks to determine * the context, and then uses the built in shortcodes to output the * correct results from inside an output buffer. * * Uses bbp_get_theme_compat_templates() to provide fall-backs that * should be coded without superfluous mark-up and logic (prev/next * navigation, comments, date/time, etc...) * * Hook into the 'bbp_get_bbpress_template' to override the array of * possible templates, or 'bbp_bbpress_template' to override the result. */ if (bbp_is_theme_compat_active()) { // Remove all filters from the_content bbp_remove_all_filters('the_content'); // Add a filter on the_content late, which we will later remove add_filter('the_content', 'bbp_replace_the_content'); // Find the appropriate template file $template = bbp_get_theme_compat_templates(); } return apply_filters('bbp_template_include_theme_compat', $template); }
/** * Return the row class of a reply * * @since bbPress (r2678) * * @param int $reply_id Optional. Reply ID * @param array Extra classes you can pass when calling this function * @uses bbp_get_reply_id() To validate the reply id * @uses bbp_get_reply_forum_id() To get the reply's forum id * @uses bbp_get_reply_topic_id() To get the reply's topic id * @uses get_post_class() To get all the classes including ours * @uses apply_filters() Calls 'bbp_get_reply_class' with the classes * @return string Row class of the reply */ function bbp_get_reply_class($reply_id = 0, $classes = array()) { $bbp = bbpress(); $reply_id = bbp_get_reply_id($reply_id); $count = isset($bbp->reply_query->current_post) ? $bbp->reply_query->current_post : 1; $classes = (array) $classes; $classes[] = (int) $count % 2 ? 'even' : 'odd'; $classes[] = 'bbp-parent-forum-' . bbp_get_reply_forum_id($reply_id); $classes[] = 'bbp-parent-topic-' . bbp_get_reply_topic_id($reply_id); $classes[] = 'bbp-reply-position-' . bbp_get_reply_position($reply_id); $classes[] = 'user-id-' . bbp_get_reply_author_id($reply_id); $classes[] = bbp_get_reply_author_id($reply_id) === bbp_get_topic_author_id(bbp_get_reply_topic_id($reply_id)) ? 'topic-author' : ''; $classes = array_filter($classes); $classes = get_post_class($classes, $reply_id); $classes = apply_filters('bbp_get_reply_class', $classes, $reply_id); $retval = 'class="' . implode(' ', $classes) . '"'; return $retval; }
/** * Update the activity stream entry when a reply status changes * * @param int $post_id * @param obj $post * @uses get_post_type() * @uses bbp_get_reply_post_type() * @uses bbp_get_reply_id() * @uses bbp_is_reply_anonymous() * @uses bbp_get_public_status_id() * @uses bbp_get_closed_status_id() * @uses bbp_get_reply_topic_id() * @uses bbp_get_reply_forum_id() * @uses bbp_get_reply_author_id() * @return Bail early if not a reply, or reply is by anonymous user */ public function reply_update($reply_id, $post) { // Bail early if not a reply if (get_post_type($post) != bbp_get_reply_post_type()) { return; } $reply_id = bbp_get_reply_id($reply_id); // Bail early if reply is by anonymous user if (bbp_is_reply_anonymous($reply_id)) { return; } $anonymous_data = array(); // Action based on new status if ($post->post_status == bbp_get_public_status_id()) { // Validate reply data $topic_id = bbp_get_reply_topic_id($reply_id); $forum_id = bbp_get_reply_forum_id($reply_id); $reply_author_id = bbp_get_reply_author_id($reply_id); $this->reply_create($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author_id); } else { $this->reply_delete($reply_id); } }
/** * Handles the front end edit reply submission * * @param string $action The requested action to compare this function to * @uses bbp_add_error() To add an error message * @uses bbp_get_reply() To get the reply * @uses bbp_verify_nonce_request() To verify the nonce and check the request * @uses bbp_is_reply_anonymous() To check if the reply was by an anonymous user * @uses current_user_can() To check if the current user can edit that reply * @uses bbp_filter_anonymous_post_data() To filter anonymous data * @uses is_wp_error() To check if the value retrieved is a {@link WP_Error} * @uses remove_filter() To remove kses filters if needed * @uses esc_attr() For sanitization * @uses apply_filters() Calls 'bbp_edit_reply_pre_title' with the title and * reply id * @uses apply_filters() Calls 'bbp_edit_reply_pre_content' with the content * reply id * @uses wp_set_post_terms() To set the topic tags * @uses bbp_has_errors() To get the {@link WP_Error} errors * @uses wp_save_post_revision() To save a reply revision * @uses bbp_update_reply_revision_log() To update the reply revision log * @uses wp_update_post() To update the reply * @uses bbp_get_reply_topic_id() To get the reply topic id * @uses bbp_get_topic_forum_id() To get the topic forum id * @uses bbp_get_reply_to() To get the reply to id * @uses do_action() Calls 'bbp_edit_reply' with the reply id, topic id, forum * id, anonymous data, reply author, bool true (for edit), * and the reply to id * @uses bbp_get_reply_url() To get the paginated url to the reply * @uses wp_safe_redirect() To redirect to the reply url * @uses bbPress::errors::get_error_message() To get the {@link WP_Error} error * message */ function bbp_edit_reply_handler($action = '') { // Bail if action is not bbp-edit-reply if ('bbp-edit-reply' !== $action) { return; } // Define local variable(s) $revisions_removed = false; $reply = $reply_id = $reply_author = $topic_id = $forum_id = $anonymous_data = 0; $reply_title = $reply_content = $reply_edit_reason = $terms = ''; /** Reply *****************************************************************/ // Reply id was not passed if (empty($_POST['bbp_reply_id'])) { bbp_add_error('bbp_edit_reply_id', __('<strong>ERROR</strong>: Reply ID not found.', 'bbpress')); return; // Reply id was passed } elseif (is_numeric($_POST['bbp_reply_id'])) { $reply_id = (int) $_POST['bbp_reply_id']; $reply = bbp_get_reply($reply_id); } // Nonce check if (!bbp_verify_nonce_request('bbp-edit-reply_' . $reply_id)) { bbp_add_error('bbp_edit_reply_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress')); return; } // Reply does not exist if (empty($reply)) { bbp_add_error('bbp_edit_reply_not_found', __('<strong>ERROR</strong>: The reply you want to edit was not found.', 'bbpress')); return; // Reply exists } else { // Check users ability to create new reply if (!bbp_is_reply_anonymous($reply_id)) { // User cannot edit this reply if (!current_user_can('edit_reply', $reply_id)) { bbp_add_error('bbp_edit_reply_permissions', __('<strong>ERROR</strong>: You do not have permission to edit that reply.', 'bbpress')); return; } // Set reply author $reply_author = bbp_get_reply_author_id($reply_id); // It is an anonymous post } else { // Filter anonymous data $anonymous_data = bbp_filter_anonymous_post_data(); } } // Remove kses filters from title and content for capable users and if the nonce is verified if (current_user_can('unfiltered_html') && !empty($_POST['_bbp_unfiltered_html_reply']) && wp_create_nonce('bbp-unfiltered-html-reply_' . $reply_id) === $_POST['_bbp_unfiltered_html_reply']) { remove_filter('bbp_edit_reply_pre_title', 'wp_filter_kses'); remove_filter('bbp_edit_reply_pre_content', 'bbp_encode_bad', 10); remove_filter('bbp_edit_reply_pre_content', 'bbp_filter_kses', 30); } /** Reply Topic ***********************************************************/ $topic_id = bbp_get_reply_topic_id($reply_id); /** Topic Forum ***********************************************************/ $forum_id = bbp_get_topic_forum_id($topic_id); // Forum exists if (!empty($forum_id) && $forum_id !== bbp_get_reply_forum_id($reply_id)) { // Forum is a category if (bbp_is_forum_category($forum_id)) { bbp_add_error('bbp_edit_reply_forum_category', __('<strong>ERROR</strong>: This forum is a category. No replies can be created in this forum.', 'bbpress')); // Forum is not a category } else { // Forum is closed and user cannot access if (bbp_is_forum_closed($forum_id) && !current_user_can('edit_forum', $forum_id)) { bbp_add_error('bbp_edit_reply_forum_closed', __('<strong>ERROR</strong>: This forum has been closed to new replies.', 'bbpress')); } // Forum is private and user cannot access if (bbp_is_forum_private($forum_id)) { if (!current_user_can('read_private_forums')) { bbp_add_error('bbp_edit_reply_forum_private', __('<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new replies in it.', 'bbpress')); } // Forum is hidden and user cannot access } elseif (bbp_is_forum_hidden($forum_id)) { if (!current_user_can('read_hidden_forums')) { bbp_add_error('bbp_edit_reply_forum_hidden', __('<strong>ERROR</strong>: This forum is hidden and you do not have the capability to read or create new replies in it.', 'bbpress')); } } } } /** Reply Title ***********************************************************/ if (!empty($_POST['bbp_reply_title'])) { $reply_title = esc_attr(strip_tags($_POST['bbp_reply_title'])); } // Filter and sanitize $reply_title = apply_filters('bbp_edit_reply_pre_title', $reply_title, $reply_id); /** Reply Content *********************************************************/ if (!empty($_POST['bbp_reply_content'])) { $reply_content = $_POST['bbp_reply_content']; } // Filter and sanitize $reply_content = apply_filters('bbp_edit_reply_pre_content', $reply_content, $reply_id); // No reply content if (empty($reply_content)) { bbp_add_error('bbp_edit_reply_content', __('<strong>ERROR</strong>: Your reply cannot be empty.', 'bbpress')); } /** Reply Blacklist *******************************************************/ if (!bbp_check_for_blacklist($anonymous_data, $reply_author, $reply_title, $reply_content)) { bbp_add_error('bbp_reply_blacklist', __('<strong>ERROR</strong>: Your reply cannot be edited at this time.', 'bbpress')); } /** Reply Status **********************************************************/ // Maybe put into moderation if (!bbp_check_for_moderation($anonymous_data, $reply_author, $reply_title, $reply_content)) { // Set post status to pending if public if (bbp_get_public_status_id() === $reply->post_status) { $reply_status = bbp_get_pending_status_id(); } // Use existing post_status } else { $reply_status = $reply->post_status; } /** Reply To **************************************************************/ // Handle Reply To of the reply; $_REQUEST for non-JS submissions if (isset($_REQUEST['bbp_reply_to'])) { $reply_to = bbp_validate_reply_to($_REQUEST['bbp_reply_to']); } /** Topic Tags ************************************************************/ // Either replace terms if (bbp_allow_topic_tags() && current_user_can('assign_topic_tags') && !empty($_POST['bbp_topic_tags'])) { $terms = esc_attr(strip_tags($_POST['bbp_topic_tags'])); // ...or remove them. } elseif (isset($_POST['bbp_topic_tags'])) { $terms = ''; // Existing terms } else { $terms = bbp_get_topic_tag_names($topic_id); } /** Additional Actions (Before Save) **************************************/ do_action('bbp_edit_reply_pre_extras', $reply_id); // Bail if errors if (bbp_has_errors()) { return; } /** No Errors *************************************************************/ // Add the content of the form to $reply_data as an array // Just in time manipulation of reply data before being edited $reply_data = apply_filters('bbp_edit_reply_pre_insert', array('ID' => $reply_id, 'post_title' => $reply_title, 'post_content' => $reply_content, 'post_status' => $reply_status, 'post_parent' => $topic_id, 'post_author' => $reply_author, 'post_type' => bbp_get_reply_post_type())); // Toggle revisions to avoid duplicates if (post_type_supports(bbp_get_reply_post_type(), 'revisions')) { $revisions_removed = true; remove_post_type_support(bbp_get_reply_post_type(), 'revisions'); } // Insert topic $reply_id = wp_update_post($reply_data); // Toggle revisions back on if (true === $revisions_removed) { $revisions_removed = false; add_post_type_support(bbp_get_reply_post_type(), 'revisions'); } /** Topic Tags ************************************************************/ // Just in time manipulation of reply terms before being edited $terms = apply_filters('bbp_edit_reply_pre_set_terms', $terms, $topic_id, $reply_id); // Insert terms $terms = wp_set_post_terms($topic_id, $terms, bbp_get_topic_tag_tax_id(), false); // Term error if (is_wp_error($terms)) { bbp_add_error('bbp_reply_tags', __('<strong>ERROR</strong>: There was a problem adding the tags to the topic.', 'bbpress')); } /** Revisions *************************************************************/ // Revision Reason if (!empty($_POST['bbp_reply_edit_reason'])) { $reply_edit_reason = esc_attr(strip_tags($_POST['bbp_reply_edit_reason'])); } // Update revision log if (!empty($_POST['bbp_log_reply_edit']) && "1" === $_POST['bbp_log_reply_edit']) { $revision_id = wp_save_post_revision($reply_id); if (!empty($revision_id)) { bbp_update_reply_revision_log(array('reply_id' => $reply_id, 'revision_id' => $revision_id, 'author_id' => bbp_get_current_user_id(), 'reason' => $reply_edit_reason)); } } /** No Errors *************************************************************/ if (!empty($reply_id) && !is_wp_error($reply_id)) { // Update counts, etc... do_action('bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, true, $reply_to); /** Additional Actions (After Save) ***********************************/ do_action('bbp_edit_reply_post_extras', $reply_id); /** Redirect **********************************************************/ // Redirect to $redirect_to = bbp_get_redirect_to(); // Get the reply URL $reply_url = bbp_get_reply_url($reply_id, $redirect_to); // Allow to be filtered $reply_url = apply_filters('bbp_edit_reply_redirect_to', $reply_url, $redirect_to); /** Successful Edit ***************************************************/ // Redirect back to new reply wp_safe_redirect($reply_url); // For good measure exit; /** Errors ****************************************************************/ } else { $append_error = is_wp_error($reply_id) && $reply_id->get_error_message() ? $reply_id->get_error_message() . ' ' : ''; bbp_add_error('bbp_reply_error', __('<strong>ERROR</strong>: The following problem(s) have been found with your reply:' . $append_error . 'Please try again.', 'bbpress')); } }
/** * 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 /** * Apocrypha Theme Forum Single Reply * Andrew Clayton * Version 2.0 * 7-22-2014 */ // Get the reply author object $author = new Apoc_User(bbp_get_reply_author_id(), 'reply'); ?> <li id="post-<?php bbp_reply_id(); ?> " class="reply"> <header class="reply-header"> <time class="reply-time" datetime="<?php echo get_the_time('Y-m-d\\TH:i'); ?> "><?php echo bp_core_time_since(strtotime(get_the_time('c')), current_time('timestamp')); ?> </time> <?php apoc_report_post_button('reply'); ?> <div class="reply-admin-links"> <?php
/** * Display the Support status of an User under his replies or topics in the Forum **/ function bbp_display_badge() { $user_id = bbp_get_reply_author_id(); /*$caps = get_user_meta($user_id, 'wp_capabilities', true); $roles = array_keys((array)$caps); if (strtolower($roles[0]) == 'keymaster' || strtolower($roles[0]) == 'administrator' || strtolower($roles[0]) == 'moderator') { return; } */ $dat = get_userdata($user_id); $roles = implode(', ', $dat->roles); if (strpos(strtolower($roles), 'keymaster') !== false || strpos(strtolower($roles), 'administrator') !== false || strpos(strtolower($roles), 'moderator') !== false) { return; } px_verify_badge_style(); $buy_date = get_user_meta($user_id, 'px_envato_purchase_date'); // $support_amount = get_user_meta( $user_id, 'px_envato_support_amount'); NOT WORKING YET // $support_until = get_user_meta( $user_id, 'px_envato_support_until'); // Calculate the if support is valid if (isset($buy_date[0]) && $buy_date[0] != 0) { $short_date = explode('T', $buy_date[0]); $short_date = $short_date[0]; $date1 = new DateTime($short_date); $date2 = new DateTime(current_time('Y-m-d')); $interval = $date1->diff($date2); if ($interval->days <= 182) { $supported = 1; } else { $supported = 2; } } else { if (strpos(strtolower($roles), 'blocked') !== false) { $supported = 3; } else { $supported = 4; } } if ($supported == 1) { ?> <div id="user-badge-<?php echo $user_id; ?> " class="badge-supported"> Supported </div> <?php } else { if ($supported == 2) { ?> <div id="user-badge-<?php echo $user_id; ?> " class="badge-unsupported"> Support Expired </div> <?php } else { if ($supported == 3) { ?> <div id="user-badge-<?php echo $user_id; ?> " class="badge-blocked"> Blocked </div> <?php } else { if ($supported == 4) { ?> <div id="user-badge-<?php echo $user_id; ?> " class="badge-unknowen"> Unknowen Support Status </div> <?php } } } } }
/** * Insert Rank In bbPress Reply * @since 1.6 * @version 1.0 */ public function insert_rank_bb_reply() { $output = ''; $user_id = bbp_get_reply_author_id(); if ($user_id == 0) { return; } foreach ($this->point_types as $type_id => $label) { // Load type $mycred = mycred($type_id); // User is excluded from this type if ($mycred->exclude_user($user_id)) { continue; } // No settings if (!isset($mycred->rank['bp_location'])) { continue; } // Not shown if (!in_array($mycred->rank['bp_location'], array('reply', 'both'))) { continue; } // Get rank (if user has one $users_rank = mycred_get_users_rank_id($user_id, $type_id); if ($users_rank === NULL) { continue; } // Parse template $template = $mycred->rank['bp_template']; $template = str_replace('%rank_title%', get_the_title($users_rank), $template); $template = str_replace('%rank_logo%', mycred_get_rank_logo($users_rank), $template); // Let others play $output .= apply_filters('mycred_bb_reply_ranks_row', $template, $user_id, $users_rank, $mycred, $this); } if ($output == '') { return; } echo '<div id="mycred-my-rank">' . apply_filters('mycred_bb_rank_in_reply', $output, $user_id, $this) . '</div>'; }
/** * Insert Badges into bbPress * @version 1.1 */ public function insert_into_bbpress_reply() { $user_id = bbp_get_reply_author_id(); if ($user_id > 0) { if (isset($this->badges['show_all_bb']) && $this->badges['show_all_bb'] == 1) { mycred_render_my_badges(array('show' => 'all', 'width' => MYCRED_BADGE_WIDTH, 'height' => MYCRED_BADGE_HEIGHT, 'user_id' => $user_id)); } else { mycred_display_users_badges($user_id); } } }
/** * Pass the reply attributes for processing * * @since 2.0.0 bbPress (r2746) * * @param int $reply_id Reply id * @uses current_user_can() To check if the current user is capable of * editing the reply * @uses do_action() Calls 'bbp_reply_attributes_metabox_save' with the * reply id and parent id * @return int Parent id */ public function attributes_metabox_save($reply_id) { if ($this->bail()) { return $reply_id; } // Bail if doing an autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $reply_id; } // Bail if not a post request if (!bbp_is_post_request()) { return $reply_id; } // Check action exists if (empty($_POST['action'])) { return $reply_id; } // Nonce check if (empty($_POST['bbp_reply_metabox']) || !wp_verify_nonce($_POST['bbp_reply_metabox'], 'bbp_reply_metabox_save')) { return $reply_id; } // Current user cannot edit this reply if (!current_user_can('edit_reply', $reply_id)) { return $reply_id; } // Get the reply meta post values $topic_id = !empty($_POST['parent_id']) ? (int) $_POST['parent_id'] : 0; $forum_id = !empty($_POST['bbp_forum_id']) ? (int) $_POST['bbp_forum_id'] : bbp_get_topic_forum_id($topic_id); $reply_to = !empty($_POST['bbp_reply_to']) ? (int) $_POST['bbp_reply_to'] : 0; // Get reply author data $anonymous_data = bbp_filter_anonymous_post_data(); $author_id = bbp_get_reply_author_id($reply_id); $is_edit = isset($_POST['hidden_post_status']) && $_POST['hidden_post_status'] !== 'draft'; // Formally update the reply bbp_update_reply($reply_id, $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit, $reply_to); // Allow other fun things to happen do_action('bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id, $reply_to); do_action('bbp_author_metabox_save', $reply_id, $anonymous_data); return $reply_id; }
public function AddBBPressForumThreadUserRating($author_link, $args) { RWLogger::LogEnterence('AddBBPressForumThreadUserRating'); $post_id = 0; $defaults = array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80, 'sep' => ' '); $r = wp_parse_args($args, $defaults); extract($r); $reply_id = bbp_get_reply_id($post_id); RWLogger::Log('AddBBPressForumThreadUserRating', 'post_id = ' . $post_id); RWLogger::Log('AddBBPressForumThreadUserRating', 'reply_id = ' . $reply_id); if (bbp_is_reply_anonymous($reply_id)) { return $author_link; } $options = array('show-info' => 'false'); // If accumulated user rating, then make sure it can not be directly rated. if ($this->IsUserAccumulatedRating()) { $options['read-only'] = 'true'; $options['show-report'] = 'false'; } $author_id = bbp_get_reply_author_id($reply_id); return $author_link . $this->EmbedRatingIfVisible($author_id, $author_id, bbp_get_reply_author_display_name($reply_id), bbp_get_reply_author_url($reply_id), 'user', false, false, false, $options); }
function gpbbp_display_user_brand_with_username($author_name, $reply_id) { $author_id = bbp_get_reply_author_id($reply_id); $author_brand = gpbbp_get_author_brand($author_id); $author_name_brand_display = $author_name . '<br>' . $author_brand; return $author_name_brand_display; }
bbp_forum_title(bbp_get_topic_forum_id()); ?> </a> <?php } ?> </p> </div> <div class="forum-count"> <?php bbp_topic_post_count(); ?> </div> <div class="forum-freshness"> <?php echo apoc_get_avatar(array('user_id' => bbp_get_reply_author_id(bbp_get_topic_last_active_id()), 'link' => true, 'size' => 50)); ?> <div class="freshest-meta"> <span class="freshest-author">By <?php bbp_author_link(array('post_id' => bbp_get_topic_last_active_id(), 'type' => 'name')); ?> </span> <span class="freshest-time"><?php bbp_topic_last_active_time(); ?> </span> </div> </div> </li>
<div class="topic-reply"> <div class="author"> <?php do_action('bbp_theme_before_reply_author_details'); $args = ['sep' => '', 'show_role' => true, 'type' => 'avatar']; bbp_reply_author_link($args); ?> </div> <div class="content"> <div class="replyheader"> <div id="country" style="float:left;margin-right:.5em;"> <?php $user = get_userdata(bbp_get_reply_author_id()); $country = xprofile_get_field_data(42, $user->ID); dh_get_flag_by_location($country); ?> </div> <div class="smallusername"> <?php if (!empty($user->user_nicename)) { $user_nicename = $user->user_nicename; echo "" . $user_nicename; } ?>
<?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>
/** * Sends the new reply notification email to moderators on private replies * * @since 1.2 * * @param $message string The email message * @param $reply_id int The ID of the reply * @param $topic_id int The ID of the reply's topic * * @return void */ public function subscription_email($message, $reply_id, $topic_id) { if (!$this->is_private($reply_id)) { return false; // reply isn't private so do nothing } $topic_author = bbp_get_topic_author_id($topic_id); $reply_author = bbp_get_reply_author_id($reply_id); $reply_author_name = bbp_get_reply_author_display_name($reply_id); // Strip tags from text and setup mail data $topic_title = strip_tags(bbp_get_topic_title($topic_id)); $reply_content = strip_tags(bbp_get_reply_content($reply_id)); $reply_url = bbp_get_reply_url($reply_id); $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $do_not_reply = '<noreply@' . ltrim(get_home_url(), '^(http|https)://') . '>'; $subject = apply_filters('bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id); // Array to hold BCC's $headers = array(); // Setup the From header $headers[] = 'From: ' . get_bloginfo('name') . ' ' . $do_not_reply; // Get topic subscribers and bail if empty $user_ids = bbp_get_topic_subscribers($topic_id, true); if (empty($user_ids)) { return false; } // Loop through users foreach ((array) $user_ids as $user_id) { // Don't send notifications to the person who made the post if (!empty($reply_author) && (int) $user_id === (int) $reply_author) { continue; } if (user_can($user_id, 'moderate') || (int) $topic_author === (int) $user_id) { // Get email address of subscribed user $headers[] = 'Bcc: ' . get_userdata($user_id)->user_email; } } wp_mail($do_not_reply, $subject, $message, $headers); }
/** * Insert Balance * @since 0.1 * @version 1.2 */ public function insert_balance() { $reply_id = bbp_get_reply_id(); // Skip Anonymous replies if (bbp_is_reply_anonymous($reply_id)) { return; } // Get reply author $reply_author = bbp_get_reply_author_id($reply_id); // Check for exclusions and guests if ($this->core->exclude_user($reply_author) || $reply_id == 0) { return; } // Get balance $balance = $this->core->get_users_cred($reply_author, $this->mycred_type); // Layout $layout = $this->core->plural() . ': ' . $this->core->format_creds($balance); $layout = apply_filters('mycred_bbp_authors_balance', $layout, $balance, $reply_author, $this->mycred_type); echo '<div class="mycred-balance">' . $layout . '</div>'; }
<?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>
<?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 do_action('bbp_theme_after_reply_author_details'); ?> </div><!-- .bbp-reply-author --> <div class="bbp-reply-content"> <div class="mom-bbp-reply-author mom-main-font"> <span class="mom-main-color"> <?php if (class_exists('userpro_api')) { /* Integrating UserPro */ global $userpro; $link = preg_replace("/(?<=href=(\"|'))[^\"']+(?=(\"|'))/", $userpro->permalink(bbp_get_reply_author_id()), bbp_get_reply_author_link(array('sep' => '', 'size' => 0))); echo $link . userpro_show_badges(bbp_get_reply_author_id()); } else { bbp_reply_author_link(array('sep' => '', 'show_role' => false, 'type' => 'name')); } ?> </span> <?php _e('on:', 'framework'); ?> <?php bbp_reply_post_date(); ?> <a href="<?php bbp_reply_url(); ?> " class="bbp-reply-permalink alignright">#<?php bbp_reply_id();
/** * Delete Reply * @since 1.2 * @version 1.2.1 */ public function delete_reply($reply_id) { // Get Author $reply_author = bbp_get_reply_author_id($reply_id); // If gained, points, deduct if ($this->has_entry('new_forum_reply', $reply_id, $reply_author)) { // Execute $this->core->add_creds('deleted_reply', $reply_author, $this->prefs['delete_reply']['creds'], $this->prefs['delete_reply']['log'], $reply_id, '', $this->mycred_type); } }
<?php do_action('bbp_theme_before_reply_form_subscription'); ?> <p> <input name="bbp_topic_subscription" id="bbp_topic_subscription" type="checkbox" value="bbp_subscribe"<?php bbp_form_topic_subscribed(); ?> tabindex="<?php bbp_tab_index(); ?> " /> <?php if (bbp_is_reply_edit() && bbp_get_reply_author_id() !== bbp_get_current_user_id()) { ?> <label for="bbp_topic_subscription"><?php esc_html_e('Notify the author of follow-up replies via email', 'monsoon'); ?> </label> <?php } else { ?> <label for="bbp_topic_subscription"><?php esc_html_e('Notify me of follow-up replies via email', 'monsoon'); ?> </label>
/** * Return author ID of last reply of forum * * @since bbPress (r2625) * * @param int $forum_id Optional. Forum id * @uses bbp_get_forum_id() To get the forum id * @uses bbp_get_forum_last_reply_author_id() To get the forum's last * reply's author id * @uses bbp_get_reply_author_id() To get the reply's author id * @uses apply_filters() Calls 'bbp_get_forum_last_reply_author_id' with * the author id and forum id * @return int Forum's last reply author id */ function bbp_get_forum_last_reply_author_id($forum_id = 0) { $forum_id = bbp_get_forum_id($forum_id); $author_id = bbp_get_reply_author_id(bbp_get_forum_last_reply_id($forum_id)); return apply_filters('bbp_get_forum_last_reply_author_id', $author_id, $forum_id); }