prepare( "SELECT `post_id` FROM {$wpdb->postmeta} WHERE `meta_key` = %s AND `meta_value` = %s", "_bbps_is_premium", "1" ); $premium_forums = $wpdb->get_col($forum_query); if (empty($premium_forums)) { return []; } $forum_ids = array_map("intval", $premium_forums); $placeholder = implode(",", array_fill(0, count($forum_ids), "%d")); $topics_query = $wpdb->prepare( "SELECT `ID` FROM {$wpdb->posts} WHERE `post_parent` IN ($placeholder) AND `post_type` = %s", array_merge($forum_ids, ["topic"]) ); $premium_topics = $wpdb->get_col($topics_query); return array_map("intval", $premium_topics); } function bbps_topic_resolved($topic_id) { return get_post_meta($topic_id, "_bbps_topic_status", true) == 2; } function bbps_is_post_count_enabled() { return get_option("bbps_enable_post_count"); } function bbps_is_user_rank_enabled() { return get_option("bbps_enable_user_rank"); } function bbps_is_resolved_enabled() { $options = get_option("bbps_used_status"); return isset($options["res"]) ? $options["res"] : false; } function bbps_is_not_resolved_enabled() { $options = get_option("bbps_used_status"); return isset($options["notres"]) ? $options["notres"] : false; } function bbps_is_not_support_enabled() { $options = get_option("bbps_used_status"); return isset($options["notsup"]) ? $options["notsup"] : false; } function bbps_is_moderator_enabled() { $options = get_option("bbps_status_permissions"); return isset($options["mod"]) ? $options["mod"] : false; } function bbps_is_admin_enabled() { $options = get_option("bbps_status_permissions"); return isset($options["admin"]) ? $options["admin"] : false; } function bbps_is_user_enabled() { $options = get_option("bbps_status_permissions"); return isset($options["user"]) ? $options["user"] : false; } function bbps_is_topic_move_enabled() { return get_option("bbps_enable_topic_move"); } function bbps_is_topic_urgent_enabled() { return get_option("bbps_status_permissions_urgent"); } function bbps_is_topic_claim_enabled() { return get_option("bbps_claim_topic"); } function bbps_is_topic_claim_display_enabled() { return get_option("bbps_claim_topic_display"); } function bbps_is_topic_assign_enabled() { return get_option("bbps_topic_assign"); } function bbps_is_new_topic_label_enabled() { return get_option("bbps_enable_new_topic_label"); } function bbps_is_closed_topic_label_enabled() { return get_option("bbps_enable_closed_topic_label"); } function bbps_is_sticky_topic_label_enabled() { return get_option("bbps_enable_sticky_topic_label"); } function bbps_is_search_integration_enabled() { return get_option("bbps_enable_search_integration"); } function bbps_is_search_url_rewrite_enabled() { return get_option("bbps_enable_search_url_rewrite"); } function bbps_is_post_author_label_enabled() { return get_option("bbps_enable_post_author_label"); } function bbps_is_private_replies_enabled() { return get_option("bbps_enable_private_replies"); } function bbps_get_private_replies_capability() { return get_option("bbps_private_replies_capability", "moderate"); } function bbps_is_seo_optimization_enabled() { return get_option("bbps_enable_seo_optimization"); } function bbps_is_meta_descriptions_enabled() { return get_option("bbps_enable_meta_descriptions"); } function bbps_is_open_graph_enabled() { return get_option("bbps_enable_open_graph"); } function bbps_is_twitter_cards_enabled() { return get_option("bbps_enable_twitter_cards"); } function bbps_is_schema_markup_enabled() { return get_option("bbps_enable_schema_markup"); } function bbps_is_canonical_urls_enabled() { return get_option("bbps_enable_canonical_urls"); } function bbps_is_email_fix_enabled() { return get_option("bbps_enable_email_fix"); } function bbps_is_title_length_fix_enabled() { return get_option("bbps_enable_title_length_fix"); } function bbps_is_remove_topic_tags_enabled() { return get_option("bbps_remove_topic_tags"); } function bbps_is_default_forum_enabled() { return get_option("bbps_enable_default_forum"); } if (bbps_is_default_forum_enabled()) { add_filter('bbp_get_form_topic_forum', 'bbps_set_default_forum'); add_action('bbp_theme_before_topic_form_forum', 'bbps_set_default_forum_js'); add_filter('bbp_get_dropdown_forums', 'bbps_modify_forum_dropdown', 10, 2); } function bbps_set_default_forum($forum_id) { if (empty($forum_id)) { $default_forum_id = get_option('bbps_default_forum_id'); if (!empty($default_forum_id)) { return intval($default_forum_id); } } return $forum_id; } function bbps_set_default_forum_js() { $default_forum_id = get_option('bbps_default_forum_id'); if (!empty($default_forum_id)) { ?> ID; if ($user_id == 0) { $user_id = 99999999; } $bbp_t["post_author"] = $user_id; $bbp_t["author"] = $user_id; $bbp_t["post_type"] = "topic"; $bbp_t["show_stickies"] = 0; $bbp_t["posts_per_page"] = 30; return $bbp_t; } } function bbps_hide_author_link($author_link, $args = 0) { $retval = ""; if ( !bbps_is_premium_forum(bbp_get_forum_id()) || current_user_can("administrator") || current_user_can("bbp_moderator") ) { $retval = $author_link; } return $retval; } add_filter("bbp_suppress_private_author_link", "bbps_hide_author_link", 5, 2); function bbps_hide_forum_meta($retval, $forum_id = 0) { if ( !bbps_is_premium_forum(bbp_get_forum_id()) || current_user_can("administrator") || current_user_can("bbp_moderator") ) { return $retval; } else { return "-"; } } add_filter("bbp_suppress_private_forum_meta", "bbps_hide_forum_meta", 10, 2); function bbps_get_update_capabilities() { $current_user = wp_get_current_user(); $user_id = $current_user->ID; $topic_author_id = bbp_get_topic_author_id(); $permissions = get_option("bbps_status_permissions"); $can_edit = false; if ( isset($permissions["admin"]) && $permissions["admin"] == 1 && current_user_can("administrator") ) { $can_edit = true; } if ( isset($permissions["mod"]) && $permissions["mod"] == 1 && current_user_can("bbp_moderator") ) { $can_edit = true; } if ( $user_id == $topic_author_id && isset($permissions["user"]) && $permissions["user"] == 1 ) { $can_edit = true; } return $can_edit; } add_action( "bbp_template_before_single_topic", "bbps_add_support_forum_features" ); function bbps_add_support_forum_features() { if (bbps_is_support_forum(bbp_get_forum_id())) { $can_edit = bbps_get_update_capabilities(); if ($can_edit) { $topic_id = bbp_get_topic_id(); $status = bbps_get_topic_status($topic_id); $forum_id = bbp_get_forum_id(); if (isset($_GET["bbps_message"])) { $message_type = sanitize_text_field($_GET["bbps_message"]); if ($message_type === "moved") { echo '

' . esc_html__( "Topic has been successfully moved.", "bbpress-support-toolkit" ) . "

"; } elseif ($message_type === "move_error") { echo '

' . esc_html__( "Error: Unable to move topic.", "bbpress-support-toolkit" ) . "

"; } } ?>
" name="bbps_topic_move_submit" />
bbp_get_forum_post_type(), "post_status" => bbp_get_public_status_id(), "posts_per_page" => -1, "orderby" => "menu_order title", "order" => "ASC", "meta_query" => [ "relation" => "OR", [ "key" => "_bbp_forum_type", "value" => bbp_get_forum_post_type(), "compare" => "=", ], [ "key" => "_bbp_forum_type", "compare" => "NOT EXISTS", ], ], ]); echo '"; wp_reset_postdata(); } function bbps_get_topic_status($topic_id) { $default = get_option("bbps_default_status"); $status = get_post_meta($topic_id, "_bbps_topic_status", true); $switch = $status ? $status : $default; switch ($switch) { case 1: return __("Not Resolved", "bbpress-support-toolkit"); case 2: return __("Resolved", "bbpress-support-toolkit"); case 3: return __("Not a Support Question", "bbpress-support-toolkit"); default: return __("Not Resolved", "bbpress-support-toolkit"); } } function bbps_generate_status_options($topic_id, $status, $button = true) { $dropdown_options = get_option("bbps_used_status"); $status_value = get_post_meta($topic_id, "_bbps_topic_status", true); $default = get_option("bbps_default_status"); $value = $status_value ? $status_value : $default; if ($button): ?>
" name="bbps_support_submit" />
$id, "recorded" => time(), "time" => sanitize_text_field($_POST["bbps_minutes_spent"]), ]; update_post_meta($topic_id, "_bbps_topic_minutes", $thread_time); } } } add_action("init", "bbps_handle_actions"); function bbps_handle_actions() { if ( !empty($_POST["bbps_action"]) && $_POST["bbps_action"] == "bbps_update_status" ) { bbps_update_status(); } if (!empty($_POST["bbps_topic_move_submit"])) { bbps_move_topic(); } if (isset($_GET["action"]) && isset($_GET["topic_id"])) { $action = sanitize_text_field($_GET["action"]); $topic_id = intval($_GET["topic_id"]); if ( $action == "bbps_make_topic_urgent" && wp_verify_nonce($_GET["nonce"], "bbps_urgent_" . $topic_id) ) { bbps_urgent_topic(); } if ( $action == "bbps_make_topic_not_urgent" && wp_verify_nonce($_GET["nonce"], "bbps_urgent_" . $topic_id) ) { bbps_not_urgent_topic(); } if ( $action == "bbps_claim_topic" && wp_verify_nonce($_GET["nonce"], "bbps_claim_" . $topic_id) ) { bbps_claim_topic(); } if ( $action == "bbps_unclaim_topic" && wp_verify_nonce($_GET["nonce"], "bbps_claim_" . $topic_id) ) { bbps_unclaim_topic(); } } } function bbps_move_topic() { if ( !isset($_POST["bbps_move_nonce"]) || !wp_verify_nonce($_POST["bbps_move_nonce"], "bbps_move_topic") ) { return false; } if ( !current_user_can("administrator") && !current_user_can("bbp_moderator") ) { wp_die( esc_html__( "You do not have permission to move topics.", "bbpress-support-toolkit" ) ); } $topic_id = intval($_POST["bbps_topic_id"]); $new_forum_id = intval($_POST["bbp_forum_id"]); $old_forum_id = intval($_POST["bbp_old_forum_id"]); if ( !$topic_id || !$new_forum_id || !$old_forum_id || $new_forum_id === $old_forum_id ) { return false; } global $wpdb; $wpdb->query("START TRANSACTION"); try { $result = $wpdb->update( $wpdb->posts, ["post_parent" => $new_forum_id], ["ID" => $topic_id], ["%d"], ["%d"] ); if ($result === false) { throw new Exception("Failed to update topic parent"); } update_post_meta($topic_id, "_bbp_forum_id", $new_forum_id); $replies = get_posts([ "post_type" => bbp_get_reply_post_type(), "post_parent" => $topic_id, "posts_per_page" => -1, "post_status" => ["publish", "private", "hidden"], ]); foreach ($replies as $reply) { update_post_meta($reply->ID, "_bbp_forum_id", $new_forum_id); } if (function_exists("bbp_update_forum")) { bbp_update_forum(["forum_id" => $new_forum_id]); bbp_update_forum(["forum_id" => $old_forum_id]); } $wpdb->query("COMMIT"); do_action("bbps_topic_moved", $topic_id, $old_forum_id, $new_forum_id); $redirect_url = add_query_arg( "bbps_message", "moved", bbp_get_topic_permalink($topic_id) ); wp_redirect($redirect_url); exit(); } catch (Exception $e) { $wpdb->query("ROLLBACK"); error_log("BBPS Move Topic Error: " . $e->getMessage()); return false; } } function bbps_increment_post_count() { $current_user = wp_get_current_user(); $post_type = get_post_type(); if ($post_type == "topic" || $post_type == "reply") { $user_id = $current_user->ID; $user_rank = get_user_meta($user_id, "_bbps_rank_info", true); if (empty($user_rank)) { bbps_create_user_ranking_meta($user_id); } bbps_check_ranking($user_id); } } add_action("save_post", "bbps_increment_post_count"); function bbps_check_ranking($user_id) { $user_rank = get_user_meta($user_id, "_bbps_rank_info", true); if (!is_array($user_rank)) { $user_rank = ["post_count" => 0, "current_ranking" => ""]; } $post_count = isset($user_rank["post_count"]) ? $user_rank["post_count"] : 0; $current_rank = isset($user_rank["current_ranking"]) ? $user_rank["current_ranking"] : ""; $post_count = $post_count + 1; $rankings = get_option("bbps_reply_count"); if (is_array($rankings)) { foreach ($rankings as $rank) { if ( !is_array($rank) || !isset($rank["end"], $rank["start"], $rank["title"]) ) { continue; } if ($post_count - 1 == $rank["end"]) { $current_rank = ""; } if ($post_count == $rank["start"]) { $current_rank = $rank["title"]; } } } $meta = [ "post_count" => $post_count, "current_ranking" => $current_rank, ]; update_user_meta($user_id, "_bbps_rank_info", $meta); } function bbps_create_user_ranking_meta($user_id) { $meta = [ "post_count" => "0", "current_ranking" => "", ]; update_user_meta($user_id, "_bbps_rank_info", $meta); } function bbps_display_user_title() { if (get_option("bbps_enable_user_rank") == 1) { $user_id = bbp_get_reply_author_id(); $user_rank = get_user_meta($user_id, "_bbps_rank_info", true); if (is_array($user_rank) && !empty($user_rank["current_ranking"])) { echo '
' . esc_html($user_rank["current_ranking"]) . "
"; } } } function bbps_display_user_post_count() { if (get_option("bbps_enable_post_count") == 1) { $user_id = bbp_get_reply_author_id(); $user_rank = get_user_meta($user_id, "_bbps_rank_info", true); if (is_array($user_rank) && !empty($user_rank["post_count"])) { echo '
' . sprintf( __("Post count: %s", "bbpress-support-toolkit"), esc_html($user_rank["post_count"]) ) . "
"; } } } add_action("bbp_theme_after_reply_author_details", "bbps_display_user_title"); add_action( "bbp_theme_after_reply_author_details", "bbps_display_user_post_count" ); function bbps_urgent_topic() { $topic_id = intval($_GET["topic_id"]); if (!wp_verify_nonce($_GET["nonce"], "bbps_urgent_" . $topic_id)) { return; } if ( !current_user_can("administrator") && !current_user_can("bbp_moderator") ) { return; } update_post_meta($topic_id, "_bbps_urgent_topic", 1); } function bbps_not_urgent_topic() { $topic_id = intval($_GET["topic_id"]); if (!wp_verify_nonce($_GET["nonce"], "bbps_urgent_" . $topic_id)) { return; } if ( !current_user_can("administrator") && !current_user_can("bbp_moderator") ) { return; } delete_post_meta($topic_id, "_bbps_urgent_topic"); } function bbps_claim_topic() { $user_id = intval($_GET["user_id"]); $topic_id = intval($_GET["topic_id"]); if (!wp_verify_nonce($_GET["nonce"], "bbps_claim_" . $topic_id)) { return; } if ( !current_user_can("administrator") && !current_user_can("bbp_moderator") ) { return; } bbp_add_user_subscription($user_id, $topic_id); update_post_meta($topic_id, "_bbps_topic_claimed", $user_id); } function bbps_unclaim_topic() { $user_id = intval($_GET["user_id"]); $topic_id = intval($_GET["topic_id"]); if (!wp_verify_nonce($_GET["nonce"], "bbps_claim_" . $topic_id)) { return; } if ( !current_user_can("administrator") && !current_user_can("bbp_moderator") ) { return; } bbp_remove_user_subscription($user_id, $topic_id); delete_post_meta($topic_id, "_bbps_topic_claimed"); } function bbps_is_new_topic($topic_id = 0) { if (!bbps_is_new_topic_label_enabled()) { return false; } $topic_id = $topic_id ? $topic_id : bbp_get_topic_id(); $days = get_option("bbps_new_topic_days", 30); $offset = $days * 24 * 60 * 60; return get_post_time('U', false, $topic_id) > (current_time('timestamp') - $offset); } function bbps_is_closed_topic($topic_id = 0) { if (!bbps_is_closed_topic_label_enabled()) { return false; } $topic_id = $topic_id ? $topic_id : bbp_get_topic_id(); return bbp_is_topic_closed($topic_id); } add_action("bbp_theme_before_topic_title", "bbps_modify_title"); function bbps_modify_title($title = "", $topic_id = 0) { $topic_id = bbp_get_topic_id($topic_id); if (bbps_is_new_topic($topic_id)) { echo '' . esc_html__("New", "bbpress-support-toolkit") . ""; } if (bbps_is_closed_topic($topic_id)) { echo '' . esc_html__("Closed", "bbpress-support-toolkit") . ""; } if (bbps_is_sticky_topic_label_enabled() && bbp_is_topic_sticky($topic_id) && !bbp_is_topic_closed($topic_id)) { echo '' . esc_html__("Sticky", "bbpress-support-toolkit") . ""; } if (get_post_meta($topic_id, "_bbps_topic_status", true) == 2) { echo '' . esc_html__("Resolved", "bbpress-support-toolkit") . ""; } if (get_post_meta($topic_id, "_bbps_topic_status", true) == 3) { echo '' . esc_html__("Not Support Question", "bbpress-support-toolkit") . ""; } if ( get_post_meta($topic_id, "_bbps_urgent_topic", true) == 1 && (current_user_can("administrator") || current_user_can("bbp_moderator")) ) { echo '' . esc_html__("Urgent", "bbpress-support-toolkit") . ""; } if (get_post_meta($topic_id, "_bbps_topic_claimed", true) > 0) { if (get_option("bbps_claim_topic_display") == 1) { $claimed_user_id = get_post_meta( $topic_id, "_bbps_topic_claimed", true ); $user_info = get_userdata($claimed_user_id); if ($user_info) { echo '[' . esc_html($user_info->user_login) . "]"; } } else { echo '' . esc_html__("Claimed", "bbpress-support-toolkit") . ""; } } } if (bbps_is_post_author_label_enabled()) { add_action("bbp_theme_after_reply_author_details", "bbps_display_post_author_label"); } function bbps_display_post_author_label() { $topic_author_id = bbp_get_topic_author_id(); $reply_author_id = bbp_get_reply_author_id(); if ($topic_author_id == $reply_author_id) { echo '
' . esc_html__("Original Poster", "bbpress-support-toolkit") . "
"; } } if (bbps_is_search_integration_enabled()) { add_filter("pre_get_posts", "bbps_include_forum_posts_in_search"); add_filter("the_excerpt", "bbps_enhance_search_excerpt"); add_filter("get_the_excerpt", "bbps_enhance_search_excerpt"); } function bbps_include_forum_posts_in_search($query) { if (!is_admin() && $query->is_main_query() && $query->is_search()) { $current_types = $query->get('post_type'); if (empty($current_types)) { $current_types = array('post'); } else if (!is_array($current_types)) { $current_types = array($current_types); } if (post_type_exists('topic') && !in_array('topic', $current_types)) { $current_types[] = 'topic'; } if (post_type_exists('reply') && !in_array('reply', $current_types)) { $current_types[] = 'reply'; } if (!get_option("bbps_include_posts_in_search") && in_array('post', $current_types)) { $current_types = array_diff($current_types, array('post')); } $query->set('post_type', $current_types); $query->set('posts_per_page', get_option("bbps_search_results_count", 20)); $meta_query = array( 'relation' => 'AND', array( 'relation' => 'OR', array( 'key' => '_bbp_forum_id', 'compare' => 'EXISTS' ), array( 'key' => '_bbp_forum_id', 'compare' => 'NOT EXISTS' ) ) ); if (!current_user_can('administrator') && !current_user_can('bbp_moderator')) { $premium_forums = get_posts(array( 'post_type' => 'forum', 'meta_key' => '_bbps_is_premium', 'meta_value' => '1', 'fields' => 'ids', 'posts_per_page' => -1 )); if (!empty($premium_forums)) { $meta_query[] = array( 'key' => '_bbp_forum_id', 'value' => $premium_forums, 'compare' => 'NOT IN' ); } } $query->set('meta_query', $meta_query); $query->set('orderby', array('post_type' => 'ASC', 'date' => 'DESC')); } return $query; } function bbps_enhance_search_excerpt($excerpt) { if (is_search()) { global $post; if ($post->post_type == 'topic') { $forum_title = get_the_title($post->post_parent); $excerpt = '' . __('Topic in:', 'bbpress-support-toolkit') . ' ' . $forum_title . '
' . $excerpt; } elseif ($post->post_type == 'reply') { $topic_id = get_post_meta($post->ID, '_bbp_topic_id', true); $topic_title = get_the_title($topic_id); $excerpt = '' . __('Reply in:', 'bbpress-support-toolkit') . ' ' . $topic_title . '
' . $excerpt; } } return $excerpt; } if (bbps_is_private_replies_enabled()) { add_filter("bbp_get_reply_content", "bbps_filter_private_replies", 10, 2); add_action("bbp_theme_before_reply_form_content", "bbps_add_private_reply_checkbox"); add_action("bbp_new_reply", "bbps_save_private_reply_meta"); } function bbps_filter_private_replies($content, $reply_id) { if (get_post_meta($reply_id, "_bbps_private_reply", true)) { $topic_id = bbp_get_reply_topic_id($reply_id); $topic_author_id = bbp_get_topic_author_id($topic_id); $reply_author_id = bbp_get_reply_author_id($reply_id); $current_user_id = get_current_user_id(); $can_view = ( $current_user_id == $topic_author_id || $current_user_id == $reply_author_id || current_user_can(bbps_get_private_replies_capability()) ); if (!$can_view) { return '' . esc_html__("This reply is private.", "bbpress-support-toolkit") . ''; } } return $content; } function bbps_add_private_reply_checkbox() { if (!is_user_logged_in()) { return; } ?>


function bbps_redirect_search(form) { var searchTerm = form.querySelector(\'input[name="s"]\').value; if (searchTerm) { window.location.href = "' . home_url('/search/') . '" + encodeURIComponent(searchTerm); return false; } return true; } '; return $form; } // ======================================== // Additional Features Integration // ======================================== // 1. Disable User Page Feature function bbps_is_disable_user_page_enabled() { return get_option('bbps_disable_user_page', 0); } if (bbps_is_disable_user_page_enabled()) { add_filter('bbp_show_user_profile', '__return_false'); } // 2. Remove Avatars Feature function bbps_is_remove_avatars_enabled() { return get_option('bbps_remove_avatars', 0); } if (bbps_is_remove_avatars_enabled()) { // Remove from replies and topics function bbps_return_empty(){ return ''; } add_filter('bbp_get_topic_author_avatar', 'bbps_return_empty'); add_filter('bbp_get_reply_author_avatar', 'bbps_return_empty'); // Remove from a few weird places like freshness function bbps_remove_avatar_section($author_links, $r, $args){ foreach ($author_links as $link) { if (strpos($link, 'bbp-author-avatar') !== false){ $author_links = array_diff($author_links, array($link)); break; } } return $author_links; } add_filter('bbp_get_author_links', 'bbps_remove_avatar_section', 10 , 3); function bbps_reply_padding_fix(){ echo ''; } add_action('bbp_template_before_replies_loop', 'bbps_reply_padding_fix'); // Remove from user profile page function bbps_return_1(){ return 1; } add_filter('bbp_single_user_details_avatar_size', 'bbps_return_1'); function bbps_hide_profile_avatar(){ echo ''; } add_action('bbp_template_before_user_details', 'bbps_hide_profile_avatar'); } // 3. Redirect Single Replies Feature function bbps_is_redirect_single_replies_enabled() { return get_option('bbps_redirect_single_replies', 0); } if (bbps_is_redirect_single_replies_enabled()) { class BBPS_Single_Reply_Redirect { public function __construct() { add_action( 'bbp_template_redirect', array( $this, 'template_redirect' ) ); } public function template_redirect() { if( bbp_is_single_reply() && ! bbp_is_reply_edit() ) { wp_redirect( bbp_get_reply_url() ); exit; } } } new BBPS_Single_Reply_Redirect(); } // 4. Custom Reply Notifications Feature function bbps_is_custom_notifications_enabled() { return get_option('bbps_custom_notifications', 0); } if (bbps_is_custom_notifications_enabled()) { class BBPS_Topic_Reply_Notifications { function __construct() { add_filter( 'bbp_forum_subscription_mail_message', array( __CLASS__, 'topic_message' ), 10, 3 ); add_filter( 'bbp_forum_subscription_mail_title', array( __CLASS__, 'topic_title' ), 10, 3 ); add_filter( 'bbp_subscription_mail_message', array( __CLASS__, 'reply_message' ), 10, 3 ); add_filter( 'bbp_subscription_mail_title', array( __CLASS__, 'reply_title' ), 10, 3 ); } public static function topic_message( $message, $topic_id, $forum_id ) { $topic_content = strip_tags( bbp_get_topic_content( $topic_id ) ); $topic_url = bbp_get_topic_permalink( $topic_id ); $topic_author = bbp_get_topic_author_display_name( $topic_id ); $forum_name = bbp_get_forum_title( $forum_id ); $custom_message = get_option( 'bbps_topic_notice_body' ); $message = $custom_message ? $custom_message : $message; $message = str_replace( '{author}', $topic_author, $message ); $message = str_replace( '{content}', $topic_content, $message ); $message = str_replace( '{url}', $topic_url, $message ); $message = str_replace( '{forum_name}', $forum_name, $message ); return $message; } public static function topic_title( $title, $topic_id, $forum_id ) { $subject = get_option( 'bbps_topic_notice_title' ); if ( ! is_string( $subject ) && strlen( $subject ) == 0 ) { return $title; } $search = '{title}'; $replace = strip_tags( bbp_get_topic_title( $topic_id ) ); $title = str_replace( $search, $replace, $subject ); return $title; } public static function reply_message( $message, $reply_id, $topic_id ) { $reply_content = strip_tags( bbp_get_reply_content( $reply_id ) ); $reply_url = bbp_get_reply_url( $reply_id ); $reply_author = bbp_get_reply_author_display_name( $reply_id ); $custom_message = get_option( 'bbps_reply_notice_body' ); $message = $custom_message ? $custom_message : $message; $message = str_replace( '{author}', $reply_author, $message ); $message = str_replace( '{content}', $reply_content, $message ); $message = str_replace( '{url}', $reply_url, $message ); return $message; } public static function reply_title( $title, $reply_id, $topic_id ) { $subject = get_option( 'bbps_reply_notice_title' ); if ( ! is_string( $subject ) && strlen( $subject ) == 0 ) { return $title; } $search = '{title}'; $replace = strip_tags( bbp_get_topic_title( $topic_id ) ); $title = str_replace( $search, $replace, $subject ); return $title; } } new BBPS_Topic_Reply_Notifications(); }