options = $options; $this->dbManager = $dbManager; $this->wpdiscuzForm = $wpdiscuzForm; self::$current_time = current_time("timestamp"); add_filter("the_champ_login_interface_filter", [&$this, "wpDiscuzSuperSocializerLogin"], 15, 2); add_filter("pre_comment_user_ip", [&$this, "fixLocalhostIp"], 10); if ($this->options->thread_layouts["defaultAvatarUrlForUser"]) { add_filter("pre_get_avatar", [$this, "preGetDefaultAvatarForUser"], 9, 3); } if ($this->options->thread_layouts["defaultAvatarUrlForGuest"]) { add_filter("pre_get_avatar", [$this, "preGetDefaultAvatarForGuest"], 9, 3); } if ($this->options->subscription["enableUserMentioning"]) { add_filter("comment_text", [&$this, "userMentioning"], 10, 3); } if ($this->options->content["enableShortcodes"]) { add_filter("comment_text", [&$this, "doShortcode"], 10, 3); } add_filter("comment_text", [&$this, "multipleBlockquotesToOne"], 100); add_filter("wp_update_comment_data", [&$this, "commentDataArr"], 10, 3); add_action("post_updated", [&$this, "checkFeedbackShortcodes"], 10, 3); add_action("update_postmeta", [&$this, "checkMetaFeedbackShortcodes"], 10, 4); add_action("added_post_meta", [&$this, "checkMetaFeedbackShortcodes"], 10, 4); add_filter("comment_row_actions", [&$this, "commentRowStickAction"], 10, 2); add_filter("admin_comment_types_dropdown", [&$this, "addCommentTypes"]); add_filter("wpdiscuz_after_comment_author", [&$this, "userNicename"], 1, 3); add_action("wp_ajax_wpdGetInfo", [&$this, "wpdGetInfo"]); add_action("wp_ajax_nopriv_wpdGetInfo", [&$this, "wpdGetInfo"]); if ($this->options->login["showActivityTab"]) { add_action("wp_ajax_wpdGetActivityPage", [&$this, "getActivityPage"]); add_action("wp_ajax_nopriv_wpdGetActivityPage", [&$this, "getActivityPage"]); } if ($this->options->login["showSubscriptionsTab"]) { add_action("wp_ajax_wpdGetSubscriptionsPage", [&$this, "getSubscriptionsPage"]); add_action("wp_ajax_nopriv_wpdGetSubscriptionsPage", [&$this, "getSubscriptionsPage"]); } if ($this->options->login["showFollowsTab"]) { add_action("wp_ajax_wpdGetFollowsPage", [&$this, "getFollowsPage"]); add_action("wp_ajax_nopriv_wpdGetFollowsPage", [&$this, "getFollowsPage"]); } add_action("admin_post_disableAddonsDemo", [&$this, "disableAddonsDemo"]); $requestUri = !empty($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : ""; if (!get_option(self::OPTION_SLUG_DEACTIVATION) && (strpos($requestUri, "/plugins.php") !== false)) { add_action("admin_footer", [&$this, "wpdDeactivationReasonModal"]); } add_filter("wpdiscuz_comment_author", [$this, "umAuthorName"], 10, 2); add_action("add_meta_boxes", [&$this, "addRatingResetButton"], 10, 2); add_filter("nonce_life", [&$this, "setNonceLife"], 15, 2); add_action("wpdiscuz_init", [&$this, "setNonceInCookies"]); add_action("save_post", [$this, "updatePostAuthorsTrs"]); } public function filterKses() { $allowedtags = []; $allowedtags["br"] = []; $allowedtags["a"] = [ "href" => true, "title" => true, "target" => true, "rel" => true, "download" => true, "hreflang" => true, "media" => true, "type" => true ]; $allowedtags["i"] = ["class" => true]; $allowedtags["b"] = []; $allowedtags["u"] = []; $allowedtags["strong"] = []; $allowedtags["s"] = []; $allowedtags["p"] = []; $allowedtags["blockquote"] = ["cite" => true]; $allowedtags["ul"] = []; $allowedtags["li"] = []; $allowedtags["ol"] = []; $allowedtags["code"] = []; $allowedtags["em"] = []; $allowedtags["abbr"] = ["title" => true]; $allowedtags["q"] = ["cite" => true]; $allowedtags["acronym"] = ["title" => true]; $allowedtags["cite"] = []; $allowedtags["strike"] = []; $allowedtags["del"] = ["datetime" => true]; $allowedtags["span"] = [ "id" => true, "class" => true, "title" => true, "contenteditable" => true, "data-name" => true ]; $allowedtags["pre"] = ["class" => true, "spellcheck" => true]; return apply_filters("wpdiscuz_allowedtags", $allowedtags); } public function filterCommentText($commentContent) { if (!current_user_can("unfiltered_html")) { kses_remove_filters(); if ($this->options->form["richEditor"] === "none" && $this->options->form["enableQuickTags"] === 0) { $allowedTags = []; } else { $allowedTags = $this->filterKses(); } $commentContent = wp_kses($commentContent, $allowedTags); } return $commentContent; } public function dateDiff($datetime) { $text = ""; if ($datetime) { $search = ["[number]", "[time_unit]", "[adjective]"]; $replace = []; $now = new DateTime(gmdate('Y-m-d H:i:s')); $ago = new DateTime($datetime); $diff = $now->diff($ago); if ($diff->y) { $replace[] = $diff->y; $replace[] = $diff->y > 1 ? esc_html($this->options->getPhrase("wc_year_text_plural")) : esc_html($this->options->getPhrase("wc_year_text")); } else if ($diff->m) { $replace[] = $diff->m; $replace[] = $diff->m > 1 ? esc_html($this->options->getPhrase("wc_month_text_plural")) : esc_html($this->options->getPhrase("wc_month_text")); } else if ($diff->d) { $replace[] = $diff->d; $replace[] = $diff->d > 1 ? esc_html($this->options->getPhrase("wc_day_text_plural")) : esc_html($this->options->getPhrase("wc_day_text")); } else if ($diff->h) { $replace[] = $diff->h; $replace[] = $diff->h > 1 ? esc_html($this->options->getPhrase("wc_hour_text_plural")) : esc_html($this->options->getPhrase("wc_hour_text")); } else if ($diff->i) { $replace[] = $diff->i; $replace[] = $diff->i > 1 ? esc_html($this->options->getPhrase("wc_minute_text_plural")) : esc_html($this->options->getPhrase("wc_minute_text")); } else if ($diff->s) { $replace[] = $diff->s; $replace[] = $diff->s > 1 ? esc_html($this->options->getPhrase("wc_second_text_plural")) : esc_html($this->options->getPhrase("wc_second_text")); } if ($replace) { $replace[] = esc_html($this->options->getPhrase("wc_ago_text")); $text = str_replace($search, $replace, $this->options->general["dateDiffFormat"]); } else { $text = esc_html($this->options->getPhrase("wc_right_now_text")); } } return $text; } //================== Nonce================================================== public function setNonceLife($lifetime, $action = -1) { if (isset($action) && $action === $this->generateNonceKey()) { return DAY_IN_SECONDS / 2; } return $lifetime; } public function generateNonceKey() { return ($key = get_home_url()) ? md5($key) : self::GLOBAL_NONCE_NAME; } public function generateNonce() { return wp_create_nonce($this->generateNonceKey()); } public function validateNonce() { if (is_user_logged_in() || apply_filters('wpdiscuz_validate_nonce_for_guests', false)) { $nonce = !empty($_COOKIE[self::GLOBAL_NONCE_NAME . '_' . COOKIEHASH]) ? sanitize_text_field($_COOKIE[self::GLOBAL_NONCE_NAME . '_' . COOKIEHASH]) : ""; $timeDependent = wp_verify_nonce($nonce, $this->generateNonceKey()); if (!$timeDependent) { wp_die(__("Nonce is invalid.", "wpdiscuz")); } // unset($_COOKIE[self::GLOBAL_NONCE_NAME . '_' . COOKIEHASH]); $this->setNonceInCookies($timeDependent, false); } } public function setNonceInCookies($timeDependent = 2, $checkNonce = true) { if (headers_sent()) { return; } $validateNonceForGuests = apply_filters('wpdiscuz_validate_nonce_for_guests', false); if (!$validateNonceForGuests && !is_user_logged_in()) { return; } if ($checkNonce) { $nonce = !empty($_COOKIE[self::GLOBAL_NONCE_NAME . '_' . COOKIEHASH]) ? sanitize_text_field($_COOKIE[self::GLOBAL_NONCE_NAME . '_' . COOKIEHASH]) : ""; $timeDependent = wp_verify_nonce($nonce, $this->generateNonceKey()); } if ($timeDependent && $timeDependent < 2) { return; } $expires = time() + HOUR_IN_SECONDS * 10; $nonce = $this->generateNonce(); if (version_compare(phpversion(), "7.3", ">=")) { setcookie(self::GLOBAL_NONCE_NAME . '_' . COOKIEHASH, $nonce, [ 'expires' => $expires, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => true, 'samesite' => 'Strict', ]); } else { setcookie(self::GLOBAL_NONCE_NAME . '_' . COOKIEHASH, $nonce, $expires, '/', "", false, true); } } //========================================================================== public function getNumber($number) { if ($this->options->general["humanReadableNumbers"]) { if (absint($number) >= 1000000) { $number = sprintf(esc_html__("%sM", "wpdiscuz"), str_replace(".0", "", number_format($number / 1000000, 1))); } else if (absint($number) >= 1000) { $number = sprintf(esc_html__("%sK", "wpdiscuz"), str_replace(".0", "", number_format($number / 1000, 1))); } } return $number; } public function makeClickable($ret) { $ret = " " . $ret; $hook = "?"; if (is_ssl() && $this->options->general["commentLinkFilter"] == 1) { $hook = ""; } $ret = preg_replace_callback("#[^\"|\'](https" . $hook . ":\/\/[^\s]+(\.jpe?g|\.png|\.gif|\.bmp))#i", [ &$this, "replaceUrlToImg" ], $ret); // this one is not in an array because we need it to run last, for cleanup of accidental links within links $ret = preg_replace("#(]+?>|>))]+?>([^>]+?)#i", "$1$3", $ret); $ret = trim($ret); return $ret; } public function replaceUrlToImg($matches) { $url = $matches[1]; if (is_ssl() && $this->options->general["commentLinkFilter"] == 2 && strpos($matches[1], "https://") === false) { $url = str_replace("http://", "https://", $url); } $rel = "noreferrer ugc"; if (strpos($url, get_site_url()) !== 0) { $rel .= " nofollow"; } return apply_filters("wpdiscuz_source_to_image_conversion", "comment image", $url); } /** * check if comment has been posted today or not * * @param type $comment WP_Comment object or Datetime value * * @return type */ public static function isPostedToday($comment) { if (is_object($comment)) { return date("Ymd", strtotime(current_time("Ymd"))) <= date("Ymd", strtotime($comment->comment_date)); } else { return date("Ymd", strtotime(current_time("Ymd"))) <= date("Ymd", strtotime($comment)); } } public static function getMicrotime() { list($pfx_usec, $pfx_sec) = explode(" ", microtime()); return ((float)$pfx_usec + (float)$pfx_sec); } /** * check if comment is still editable or not * return boolean */ public function isCommentEditable($comment) { if (!$comment) { return false; } $commentTimestamp = strtotime($comment->comment_date); $timeDiff = self::$current_time - $commentTimestamp; $editableTimeLimit = $this->options->moderation["commentEditableTime"] === "unlimit" ? abs($timeDiff) + 100 : intval($this->options->moderation["commentEditableTime"]); return apply_filters("wpdiscuz_is_comment_editable", $editableTimeLimit && ($timeDiff < $editableTimeLimit), $comment); } /** * checks if the current comment content is in min/max range defined in options */ public function isContentInRange($commentContent, $isReply) { if ($isReply) { $commentMinLength = intval($this->options->content["replyTextMinLength"]); $commentMaxLength = intval($this->options->content["replyTextMaxLength"]); } else { $commentMinLength = intval($this->options->content["commentTextMinLength"]); $commentMaxLength = intval($this->options->content["commentTextMaxLength"]); } $commentContent = trim(strip_tags($commentContent)); $contentLength = function_exists("mb_strlen") ? mb_strlen($commentContent) : strlen($commentContent); return ($contentLength >= $commentMinLength) && ($commentMaxLength == 0 || $contentLength <= $commentMaxLength); } /** * return client real ip */ public static function getRealIPAddr() { $ip = $_SERVER["REMOTE_ADDR"]; $ip = apply_filters("pre_comment_user_ip", $ip); if ($ip === "::1") { $ip = "127.0.0.1"; } return $ip; } public function getUIDData($uid) { $id_strings = explode("_", $uid); return $id_strings; } public function superSocializerFix() { $output = ""; if (function_exists("the_champ_login_button")) { $output .= "
"; $output .= "
"; } else { $output .= "
"; $output .= "
"; } echo $output; } public static function getCommentExcerpt($commentContent, $uniqueId, $options) { $readMoreLink = "… " . esc_html($options->getPhrase("wc_read_more")) . ""; return "

" . wp_trim_words($commentContent, $options->content["commentReadMoreLimit"], $readMoreLink) . "

"; } public static function strWordCount($content) { $words = preg_split("/[\n\r\t ]+/", $content, -1, PREG_SPLIT_NO_EMPTY); $words = array_filter($words, function ($w) { return $w !== " "; }); return count($words); } public function isLoadWpdiscuz($post) { if (!$post || !is_object($post) || (is_front_page() && !$this->options->general["isEnableOnHome"])) { return false; } $form = $this->wpdiscuzForm->getForm($post->ID); return apply_filters("is_load_wpdiscuz", $form->getFormID() && (comments_open($post) || $post->comment_count) && is_singular() && post_type_supports($post->post_type, "comments"), $post); } public function replaceCommentContentCode($content) { if (is_ssl()) { $content = preg_replace_callback("#<\s*?img[^>]*src*=*[\"\']?([^\"\']*)[^>]+>#is", [ &$this, "replaceImageToURL" ], $content); } return preg_replace_callback("#`(.*?)`#is", [&$this, "replaceCodeContent"], stripslashes($content)); } private function replaceImageToURL($matches) { if (strpos($matches[1], "https://") === false && $this->options->general["commentLinkFilter"] == 1) { return "\r\n" . $matches[1] . "\r\n"; } elseif (strpos($matches[1], "https://") === false && $this->options->general["commentLinkFilter"] == 2) { return str_replace("http://", "https://", $matches[0]); } else { return $matches[0]; } } private function replaceCodeContent($matches) { $codeContent = trim($matches[1]); $codeContent = str_replace(["<", ">"], ["<", ">"], $codeContent); return "" . $codeContent . ""; } public function spoiler($content) { return preg_replace_callback(self::$spoilerPattern, [$this, "_spoiler"], $content); } private function _spoiler($matches) { $html = "
"; $title = esc_html($this->options->getPhrase("wc_spoiler")); $matches[3] = str_replace(["”", "“", "″", "′"], "\"", $matches[3]); if (preg_match("@title[^\S]*=[^\S]*\"*([^\"]+)\"@is", $matches[3], $titleMatch)) { $title = trim($titleMatch[1]) ? trim($titleMatch[1]) : esc_html($this->options->getPhrase("wc_spoiler")); } $html .= "
" . $title . "
"; $html .= "
" . $matches[5] . "
"; $html .= "
"; return $html; } public function getCurrentUserDisplayName($current_user) { $displayName = trim($current_user->display_name); if (!$displayName) { $user_nicename = trim($current_user->user_nicename); $displayName = $user_nicename ? $user_nicename : trim($current_user->user_login); } return $displayName; } public function enqueueWpDiscuzStyle($slug, $fileName, $version, $form) { $themes = $form->getThemes(); $theme = $form->getTheme(); $wpdiscuzStyleURL = ""; if (file_exists(get_stylesheet_directory() . "/wpdiscuz/$fileName.css")) { $wpdiscuzStyleURL = get_stylesheet_directory_uri() . "/wpdiscuz/$fileName.css"; } elseif (file_exists(get_template_directory() . "/wpdiscuz/$fileName.css")) { $wpdiscuzStyleURL = get_template_directory_uri() . "/wpdiscuz/$fileName.css"; } else if (file_exists($theme . "/$fileName.css")) { $wpdiscuzStyleURL = $themes[$theme]["url"] . "/$fileName.css"; } if ($wpdiscuzStyleURL) { wp_register_style($slug, $wpdiscuzStyleURL, null, $version); wp_enqueue_style($slug); } } public function wpDiscuzSuperSocializerLogin($html, $theChampLoginOptions) { global $wp_current_filter; if (in_array("comment_form_top", $wp_current_filter) && isset($theChampLoginOptions["providers"]) && is_array($theChampLoginOptions["providers"]) && count($theChampLoginOptions["providers"]) > 0) { $html = ""; $html .= ""; } return $html; } public static function getCurrentUser() { if ($user_ID = get_current_user_id()) { $user = get_userdata($user_ID); } else { $user = wp_set_current_user(0); } return $user; } public function userNicename($html, $comment, $user) { if (apply_filters("wpdiscuz_show_nicename", false) && $this->options->subscription["enableUserMentioning"] && isset($user->user_nicename)) { $html .= "(@" . esc_html($user->user_nicename) . ")"; } return $html; } public function canUserEditComment($comment, $currentUser, $commentListArgs = []) { if (!($comment instanceof WP_Comment)) { return false; } if (isset($commentListArgs["comment_author_email"])) { $storedCookieEmail = $commentListArgs["comment_author_email"]; } else { $storedCookieEmail = isset($_COOKIE["comment_author_email_" . COOKIEHASH]) ? sanitize_email($_COOKIE["comment_author_email_" . COOKIEHASH]) : ""; } return !(!$this->options->moderation["enableEditingWhenHaveReplies"] && $comment->get_children(["post_id" => $comment->comment_post_ID])) && (($storedCookieEmail === $comment->comment_author_email && $_SERVER["REMOTE_ADDR"] === $comment->comment_author_IP) || ($currentUser && $currentUser->ID && $currentUser->ID == $comment->user_id)); } public function addCommentTypes($args) { $args[self::WPDISCUZ_STICKY_COMMENT] = esc_html__("Sticky", "wpdiscuz"); return $args; } public function commentRowStickAction($actions, $comment) { if (!$comment->comment_parent) { $stickText = $comment->comment_type === self::WPDISCUZ_STICKY_COMMENT ? $this->options->getPhrase("wc_unstick_comment", ["comment" => $comment]) : $this->options->getPhrase("wc_stick_comment", ["comment" => $comment]); if (intval(get_comment_meta($comment->comment_ID, self::META_KEY_CLOSED, true))) { $closeText = $this->options->getPhrase("wc_open_comment", ["comment" => $comment]); $closeIcon = "fa-lock"; } else { $closeText = $this->options->getPhrase("wc_close_comment", ["comment" => $comment]); $closeIcon = "fa-unlock"; } $actions["stick"] = " " . esc_html($stickText) . ""; $actions["close"] = " " . esc_html($closeText) . ""; } return $actions; } public function wpdDeactivationReasonModal() { include_once WPDISCUZ_DIR_PATH . "/utils/deactivation-reason-modal.php"; } public function disableAddonsDemo() { if (current_user_can("manage_options") && isset($_GET["_wpnonce"]) && wp_verify_nonce($_GET["_wpnonce"], "disableAddonsDemo") && isset($_GET["show"])) { update_option(self::OPTION_SLUG_SHOW_DEMO, intval($_GET["show"])); wp_redirect(admin_url("admin.php?page=" . WpdiscuzCore::PAGE_SETTINGS)); } } public function getCommentDate($comment) { if ($this->options->general["simpleCommentDate"]) { $dateFormat = $this->options->wp["dateFormat"]; $timeFormat = $this->options->wp["timeFormat"]; if (self::isPostedToday($comment)) { $postedDate = $this->options->getPhrase("wc_posted_today_text") . " " . mysql2date($timeFormat, $comment->comment_date); } else { $postedDate = get_comment_date($dateFormat . " " . $timeFormat, $comment->comment_ID); } } else { $postedDate = $this->dateDiff($comment->comment_date_gmt); } return $postedDate; } public function getPostDate($post) { if ($this->options->general["simpleCommentDate"]) { $dateFormat = $this->options->wp["dateFormat"]; $timeFormat = $this->options->wp["timeFormat"]; if ($this->isPostPostedToday($post)) { $postedDate = $this->options->getPhrase("wc_posted_today_text") . " " . mysql2date($timeFormat, $post->post_date); } else { $postedDate = get_the_date($dateFormat . " " . $timeFormat, $post); } } else { $postedDate = $this->dateDiff($post->post_date_gmt); } return $postedDate; } public function getDate($comment) { if ($this->options->general["simpleCommentDate"]) { $dateFormat = $this->options->wp["dateFormat"]; $timeFormat = $this->options->wp["timeFormat"]; if (self::isPostedToday($comment)) { $postedDate = $this->options->getPhrase("wc_posted_today_text") . " " . mysql2date($timeFormat, $comment); } else { $postedDate = date($dateFormat . " " . $timeFormat, strtotime($comment)); } } else { $postedDate = $this->dateDiff($comment); } return $postedDate; } private function isPostPostedToday($post) { return date("Ymd", strtotime(current_time("Ymd"))) <= date("Ymd", strtotime($post->post_date)); } public function wpdGetInfo() { $this->validateNonce(); $response = ""; $currentUser = self::getCurrentUser(); if ($currentUser && $currentUser->ID) { $currentUserId = $currentUser->ID; $currentUserEmail = $currentUser->user_email; } else { $currentUserId = 0; $currentUserEmail = isset($_COOKIE["comment_author_email_" . COOKIEHASH]) ? sanitize_email($_COOKIE["comment_author_email_" . COOKIEHASH]) : ""; } if (is_user_logged_in()) { $response .= "
"; $response .= "
    "; if ($this->options->login["showActivityTab"]) { $response .= $this->getActivityTitleHtml(); } if ($this->options->login["showSubscriptionsTab"]) { $response .= $this->getSubscriptionsTitleHtml(); } if ($this->options->login["showFollowsTab"]) { $response .= $this->getFollowsTitleHtml(); } $isFirstTab = true; $response .= apply_filters("wpdiscuz_content_modal_title", "", $currentUser); $response .= "
"; $response .= "
"; if ($this->options->login["showActivityTab"]) { $response .= $this->getActivityContentHtml($currentUserId, $currentUserEmail, $isFirstTab); $isFirstTab = false; } if ($this->options->login["showSubscriptionsTab"]) { $response .= $this->getSubscriptionsContentHtml($currentUserId, $currentUserEmail, $isFirstTab); $isFirstTab = false; } if ($this->options->login["showFollowsTab"]) { $response .= $this->getFollowsContentHtml($currentUserId, $currentUserEmail, $isFirstTab); $isFirstTab = false; } $response .= apply_filters("wpdiscuz_content_modal_content", "", $currentUser, $isFirstTab); $response .= "
"; $response .= ""; $response .= "
"; } else if ($currentUserEmail) { $commentBtn = $this->getDeleteAllCommentsButton($currentUserEmail); $subscribeBtn = $this->getDeleteAllSubscriptionsButton($currentUserEmail); $cookieBtnClass = !$commentBtn && !$subscribeBtn ? "wpd-show" : "wpd-hide"; $response .= "
"; $response .= $commentBtn; $response .= $subscribeBtn; $response .= $this->deleteCookiesButton($currentUserEmail, $cookieBtnClass); $response .= "
"; } else { $response .= "
"; $response .= esc_html($this->options->getPhrase("wc_user_settings_no_data")); $response .= "
"; } wp_die($response); } private function getDeleteAllCommentsButton($email) { $html = ""; if (!is_email($email)) { return $html; } $commentCount = get_comments(["author_email" => $email, "count" => true]); if ($commentCount) { $html .= ""; } return $html; } private function getDeleteAllSubscriptionsButton($email) { $html = ""; if (!is_email($email)) { return $html; } $subscriptions = $this->dbManager->getSubscriptions($email, 1, 0); if ($subscriptions) { $html .= ""; } return $html; } private function deleteCookiesButton($email, $cookieBtnClass) { $html = ""; if (!is_email($email)) { return $html; } $html .= ""; return $html; } private function getActivityTitleHtml() { ob_start(); include_once WPDISCUZ_DIR_PATH . "/utils/layouts/activity/title.php"; return ob_get_clean(); } private function getActivityContentHtml($currentUserId, $currentUserEmail, $isFirstTab) { $html = "
"; if ($isFirstTab) { include_once WPDISCUZ_DIR_PATH . "/utils/layouts/activity/content.php"; } else { $html .= "wpdiscuz-loading"; } $html .= "
"; return $html; } public function getActivityPage() { $this->validateNonce(); ob_start(); include_once WPDISCUZ_DIR_PATH . "/utils/layouts/activity/activity-page.php"; $html = ob_get_clean(); wp_die($html); } private function getSubscriptionsTitleHtml() { // $this->validateNonce(); ob_start(); include_once WPDISCUZ_DIR_PATH . "/utils/layouts/subscriptions/title.php"; return ob_get_clean(); } private function getSubscriptionsContentHtml($currentUserId, $currentUserEmail, $isFirstTab) { $html = "
"; if ($isFirstTab) { include_once WPDISCUZ_DIR_PATH . "/utils/layouts/subscriptions/content.php"; } else { $html .= "wpdiscuz-loading"; } $html .= "
"; return $html; } public function getSubscriptionsPage() { $this->validateNonce(); ob_start(); include_once WPDISCUZ_DIR_PATH . "/utils/layouts/subscriptions/subscriptions-page.php"; $html = ob_get_clean(); wp_die($html); } private function getFollowsTitleHtml() { // $this->validateNonce(); ob_start(); include_once WPDISCUZ_DIR_PATH . "/utils/layouts/follows/title.php"; return ob_get_clean(); } private function getFollowsContentHtml($currentUserId, $currentUserEmail, $isFirstTab) { $html = "
"; if ($isFirstTab) { include_once WPDISCUZ_DIR_PATH . "/utils/layouts/follows/content.php"; } else { $html .= "wpdiscuz-loading"; } $html .= "
"; return $html; } public function getFollowsPage() { ob_start(); include_once WPDISCUZ_DIR_PATH . "/utils/layouts/follows/follows-page.php"; $html = ob_get_clean(); wp_die($html); } public static function getIP() { $ip = ""; if (!empty($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) { $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } return $ip; } public static function isBanned() { $mod_keys = trim(get_option('disallowed_keys')); if ('' === $mod_keys) { return false; } $currentUser = wp_get_current_user(); $email = ''; $ip = self::getIP(); if ($currentUser->exists()) { $email = $currentUser->user_email; } $words = explode("\n", $mod_keys); foreach ((array)$words as $word) { $word = trim($word); if (empty($word)) { continue; } $word = preg_quote($word, '#'); $pattern = "#$word#iu"; if (preg_match($pattern, $ip) || preg_match($pattern, $email)) { return true; } } return false; } public static function fixEmailFrom($domain) { $domain = strtolower($domain); if (substr($domain, 0, 4) === "www.") { $domain = substr($domain, 4); } $localhost = ['127.0.0.1', '::1']; if (in_array($_SERVER['REMOTE_ADDR'], $localhost, true)) { $domain .= ".com"; } return $domain; } public function fixLocalhostIp($ip) { if (trim($ip) === "::1") { $ip = "127.0.0.1"; } return $ip; } public function fixURLScheme($url) { if (is_ssl() && strpos($url, "http://") !== false) { $url = str_replace("http://", "https://", $url); } return $url; } public function commentDataArr($data, $comment, $commentarr) { if (!empty($data["wpdiscuz_comment_update"])) { $data["comment_date"] = $comment["comment_date"]; $data["comment_date_gmt"] = $comment["comment_date_gmt"]; } return $data; } public function getTwitterShareContent($comment_content, $commentLink) { $commentLinkLength = strlen($commentLink); $twitt_content = ""; if ($commentLinkLength < 110) { $twitt_content = esc_attr(strip_tags($comment_content)); $length = strlen($twitt_content); $twitt_content = function_exists("mb_substr") ? mb_substr($twitt_content, 0, 135 - $commentLinkLength) : substr($twitt_content, 0, 135 - $commentLinkLength); if (strlen($twitt_content) < $length) { $twitt_content .= "... "; } } return $twitt_content; } public function getWhatsappShareContent($comment_content, $commentLink) { $whatsapp_content = esc_attr(strip_tags($comment_content)); $length = strlen($whatsapp_content); $whatsapp_content = function_exists("mb_substr") ? mb_substr($whatsapp_content, 0, 100) : substr($whatsapp_content, 0, 100); if (strlen($whatsapp_content) < $length) { $whatsapp_content .= "... "; } $whatsapp_content = urlencode($whatsapp_content) . ' URL: ' . urlencode($commentLink); return $whatsapp_content; } public function preGetDefaultAvatarForUser($avatar, $idOrEmail, $args) { if ($this->options->thread_layouts["changeAvatarsEverywhere"] || isset($args["wpdiscuz_gravatar_user_email"])) { $nameAndEmail = $this->getUserNameAndEmail($idOrEmail); if ($nameAndEmail["isUser"]) { $valid = true; if (isset($this->avatars[$nameAndEmail["email"]])) { $valid = $this->avatars[$nameAndEmail["email"]]; } else if ($this->isValidAvatar($nameAndEmail["email"])) { $this->avatars[$nameAndEmail["email"]] = true; } else { $valid = false; $this->avatars[$nameAndEmail["email"]] = false; } if (!$valid) { $class = ["avatar", "avatar-" . (int)$args["size"], "photo"]; if ($args["class"]) { if (is_array($args["class"])) { $class = array_merge($class, $args["class"]); } else { $class[] = $args["class"]; } } $url = $this->options->thread_layouts["defaultAvatarUrlForUser"]; $url2x = $url; $avatar = sprintf("%s", esc_attr($args["alt"]), esc_url_raw($url), esc_attr("$url2x 2x"), esc_attr(implode(" ", $class)), esc_attr((int)$args["height"]), esc_attr((int)$args["width"]), $args["extra_attr"]); } } } return $avatar; } public function preGetDefaultAvatarForGuest($avatar, $idOrEmail, $args) { if ($this->options->thread_layouts["changeAvatarsEverywhere"] || isset($args["wpdiscuz_gravatar_user_email"])) { $nameAndEmail = $this->getUserNameAndEmail($idOrEmail); if (!$nameAndEmail["isUser"]) { $valid = true; if (isset($this->avatars[$nameAndEmail["email"]])) { $valid = $this->avatars[$nameAndEmail["email"]]; } else if ($this->isValidAvatar($nameAndEmail["email"])) { $this->avatars[$nameAndEmail["email"]] = true; } else { $valid = false; $this->avatars[$nameAndEmail["email"]] = false; } if (!$valid) { $class = ["avatar", "avatar-" . (int)$args["size"], "photo"]; if ($args["class"]) { if (is_array($args["class"])) { $class = array_merge($class, $args["class"]); } else { $class[] = $args["class"]; } } $url = $this->options->thread_layouts["defaultAvatarUrlForGuest"]; $url2x = $url; $avatar = sprintf("%s", esc_attr($args["alt"]), esc_url_raw($url), esc_attr("$url2x 2x"), esc_attr(implode(" ", $class)), esc_attr((int)$args["height"]), esc_attr((int)$args["width"]), $args["extra_attr"]); } } } return $avatar; } private function isValidAvatar($email) { $url = "https://www.gravatar.com/avatar/" . md5($email) . "?d=404"; $headers = wp_remote_head($url); return !is_wp_error($headers) && 200 === $headers["response"]["code"]; } private function getUserNameAndEmail($idOrEmail) { $nameAndEmail = ["name" => "guest", "email" => "unknown@example.com", "isUser" => 0]; if (is_object($idOrEmail)) { if (!empty($idOrEmail->comment_author_email)) { $nameAndEmail = [ "name" => $idOrEmail->comment_author, "email" => $idOrEmail->comment_author_email, "isUser" => 1 ]; } } else if (is_numeric($idOrEmail)) { $user = get_user_by("id", $idOrEmail); if ($user) { $nameAndEmail = ["name" => $user->display_name, "email" => $user->user_email, "isUser" => 1]; } } else { $user = get_user_by("email", $idOrEmail); if ($user) { $nameAndEmail = ["name" => $user->display_name, "email" => $user->user_email, "isUser" => 1]; } else { $nameAndEmail["email"] = $idOrEmail; } } return $nameAndEmail; } public function userMentioning($content, $comment, $args = []) { if (apply_filters("wpdiscuz_enable_user_mentioning", true) && !empty($args["is_wpdiscuz_comment"]) && ($users = $this->getMentionedUsers($content))) { foreach ($users as $k => $user) { if ($this->options->login["enableProfileURLs"]) { $user_link = ""; if (class_exists("UM_API")) { $user_link = um_user_profile_url($user["u_id"]); } else if (class_exists("BuddyPress")) { $user_link = self::getBPUserUrl($user["u_id"]); } else { $user_link = get_author_posts_url($user["u_id"]); } if ($user_link) { $replacement = ""; } else { $replacement = "@" . $user["name"] . ""; } } else { $replacement = "@" . $user["name"] . ""; } $replacement .= "$2"; $content = preg_replace("/(" . $user["replace"] . ")([\s\n\r\t\@\,\.\!\?\#\$\%\-\:\;\'\"\`\~\)\(\}\{\|\\\[\]]?)/", $replacement, $content); } } return $content; } public function doShortcode($content, $comment, $args = []) { if (!empty($args["is_wpdiscuz_comment"])) { return do_shortcode($content); } return $content; } public function getMentionedUsers($content) { $users = []; if (preg_match_all("/(@[^\s\,\@\.\!\?\#\$\%\:\;\'\"\`\~\)\(\}\{\|\\\[\]]*)/is", $content, $nicenames)) { $nicenames = array_unique(array_map("strip_tags", $nicenames[0])); foreach ($nicenames as $k => $nicename) { $user = $this->dbManager->getUserByNicename(ltrim($nicename, "@")); if ($user) { $users[] = [ "replace" => $nicename, "u_id" => $user->ID, "name" => $user->display_name, "email" => $user->user_email ]; } } } return $users; } public function checkFeedbackShortcodes($post_ID, $post_after, $post_before) { if (comments_open($post_ID) && ($form = $this->wpdiscuzForm->getForm($post_ID)) && $form->getFormID()) { preg_match_all(self::$inlineFormPattern, $post_before->post_content, $matchesBefore, PREG_SET_ORDER); if ($post_after->post_content) { preg_match_all(self::$inlineFormPattern, $post_after->post_content, $matchesAfter, PREG_SET_ORDER); } else { $matchesAfter = $matchesBefore; $matchesBefore = []; } if ($matchesAfter || $matchesBefore) { $inlineFormsBefore = []; $defaultAtts = ["id" => "", "question" => "", "opened" => 0, "content" => ""]; foreach ($matchesBefore as $k => $matchBefore) { if (isset($matchBefore[3])) { $atts = shortcode_parse_atts($matchBefore[3]); $atts = array_merge($defaultAtts, $atts); if (($atts["id"] = trim($atts["id"])) && ($atts["question"] = strip_tags($atts["question"]))) { $inlineFormsBefore[$atts["id"]] = [ "question" => $atts["question"], "opened" => $atts["opened"], "content" => $matchBefore[5] ]; } } } foreach ($matchesAfter as $k => $matchAfter) { if (isset($matchAfter[3])) { if (function_exists("use_block_editor_for_post") && use_block_editor_for_post($post_ID)) { $matchAfter[3] = json_decode('"' . $matchAfter[3] . '"'); } $atts = shortcode_parse_atts($matchAfter[3]); $atts["content"] = $matchAfter[5]; $atts = array_merge($defaultAtts, $atts); if (($atts["id"] = trim($atts["id"])) && ($atts["question"] = strip_tags($atts["question"]))) { if (isset($inlineFormsBefore[$atts["id"]])) { if ($this->dbManager->getFeedbackFormByUid($post_ID, $atts["id"])) { if ($atts["question"] !== $inlineFormsBefore[$atts["id"]]["question"] || $atts["opened"] !== $inlineFormsBefore[$atts["id"]]["opened"] || $atts["content"] !== $inlineFormsBefore[$atts["id"]]["content"]) { $this->dbManager->updateFeedbackForm($post_ID, $atts["id"], $atts["question"], $atts["opened"], $atts["content"]); } } else { $this->dbManager->addFeedbackForm($post_ID, $atts["id"], $atts["question"], $atts["opened"], $atts["content"]); } unset($inlineFormsBefore[$atts["id"]]); } else { $this->dbManager->addFeedbackForm($post_ID, $atts["id"], $atts["question"], $atts["opened"], $atts["content"]); } } } } foreach ($inlineFormsBefore as $uid => $inlineFormBefore) { $this->dbManager->deleteFeedbackForm($post_ID, $uid); } } } } public function checkMetaFeedbackShortcodes($meta_id, $post_ID, $meta_key, $meta_value) { if ($meta_key === '_edit_lock' || $meta_key === '_edit_last') { return; } if (comments_open($post_ID) && ($form = $this->wpdiscuzForm->getForm($post_ID)) && $form->getFormID()) { $meta_before = get_post_meta($post_ID, $meta_key, true); if (!is_string($meta_before) || !is_string($meta_value)) { return; } preg_match_all(self::$inlineFormPattern, $meta_before, $matchesBefore, PREG_SET_ORDER); if ($meta_value) { preg_match_all(self::$inlineFormPattern, $meta_value, $matchesAfter, PREG_SET_ORDER); } else { $matchesAfter = $matchesBefore; $matchesBefore = []; } if ($matchesAfter || $matchesBefore) { $inlineFormsBefore = []; $defaultAtts = ["id" => "", "question" => "", "opened" => 0, "content" => ""]; foreach ($matchesBefore as $k => $matchBefore) { if (isset($matchBefore[3])) { $matchBefore[3] = str_replace('\"', "'", addslashes($matchBefore[3])); if (preg_match_all(self::$inlineFormAttsPattern, $matchBefore[3], $attsBefore, PREG_SET_ORDER)) { $atts = []; foreach ($attsBefore as $k1 => $attrBefore) { $atts[$attrBefore[1]] = $attrBefore[2]; } $atts = array_merge($defaultAtts, $atts); if (($atts["id"] = trim($atts["id"])) && ($atts["question"] = strip_tags($atts["question"]))) { $inlineFormsBefore[$atts["id"]] = [ "question" => $atts["question"], "opened" => $atts["opened"], "content" => $matchBefore[5] ]; } } } } foreach ($matchesAfter as $k => $matchAfter) { if (isset($matchAfter[3])) { $matchAfter[3] = str_replace('\"', "'", addslashes($matchAfter[3])); if (function_exists("use_block_editor_for_post") && use_block_editor_for_post($post_ID)) { $matchAfter[3] = json_decode('"' . $matchAfter[3] . '"'); } if (preg_match_all(self::$inlineFormAttsPattern, $matchAfter[3], $attsAfter, PREG_SET_ORDER)) { $atts = []; foreach ($attsAfter as $k1 => $attrAfter) { $atts[$attrAfter[1]] = $attrAfter[2]; } $atts["content"] = $matchAfter[5]; $atts = array_merge($defaultAtts, $atts); if (($atts["id"] = trim($atts["id"])) && ($atts["question"] = strip_tags($atts["question"]))) { if (isset($inlineFormsBefore[$atts["id"]])) { if ($this->dbManager->getFeedbackFormByUid($post_ID, $atts["id"])) { if ($atts["question"] !== $inlineFormsBefore[$atts["id"]]["question"] || $atts["opened"] !== $inlineFormsBefore[$atts["id"]]["opened"] || $atts["content"] !== $inlineFormsBefore[$atts["id"]]["content"]) { $this->dbManager->updateFeedbackForm($post_ID, $atts["id"], $atts["question"], $atts["opened"], $atts["content"]); } } else { $this->dbManager->addFeedbackForm($post_ID, $atts["id"], $atts["question"], $atts["opened"], $atts["content"]); } unset($inlineFormsBefore[$atts["id"]]); } else { $this->dbManager->addFeedbackForm($post_ID, $atts["id"], $atts["question"], $atts["opened"], $atts["content"]); } } } } } foreach ($inlineFormsBefore as $uid => $inlineFormBefore) { $this->dbManager->deleteFeedbackForm($post_ID, $uid); } } } } public function getCommentFormPath($theme) { if (file_exists(get_stylesheet_directory() . "/wpdiscuz/comment-form.php")) { return get_stylesheet_directory() . "/wpdiscuz/comment-form.php"; } elseif (file_exists(get_template_directory() . "/wpdiscuz/comment-form.php")) { return get_template_directory() . "/wpdiscuz/comment-form.php"; } else { return apply_filters("wpdiscuz_comment_form_include", $theme . "/comment-form.php"); } } public function getWalkerPath($theme) { if (file_exists(get_stylesheet_directory() . "/wpdiscuz/class.WpdiscuzWalker.php")) { return get_stylesheet_directory() . "/wpdiscuz/class.WpdiscuzWalker.php"; } elseif (file_exists(get_template_directory() . "/wpdiscuz/class.WpdiscuzWalker.php")) { return get_template_directory() . "/wpdiscuz/class.WpdiscuzWalker.php"; } else { return apply_filters("wpdiscuz_walker_include", $theme . "/class.WpdiscuzWalker.php"); } } public function scanDir($path) { $scannedComponents = scandir($path); unset($scannedComponents[0]); unset($scannedComponents[1]); $components = []; foreach ($scannedComponents as $k => $component) { if ("index.html" !== $component) { $components[$component] = $path . $component; } } return $components; } public function getComponents($theme, $layout) { $wpdPath = $theme . "/layouts/{$layout}/"; $wpdComponents = $this->scanDir($wpdPath); $scannedComponents = []; if (is_dir(get_stylesheet_directory() . "/wpdiscuz/layouts/" . $layout)) { $scannedComponents = $this->scanDir(get_stylesheet_directory() . "/wpdiscuz/layouts/" . $layout . "/"); } else if (is_dir(get_template_directory() . "/wpdiscuz/layouts/" . $layout)) { $scannedComponents = $this->scanDir(get_template_directory() . "/wpdiscuz/layouts/" . $layout . "/"); } $components = array_merge($wpdComponents, $scannedComponents); foreach ($components as $key => $component) { $components[$key] = file_get_contents($component); } return $components; } public function restrictCommentingPerUser($email, $comment_parent, $postId) { if ($this->options->moderation["restrictCommentingPerUser"] !== "disable") { $args = ["count" => true, "author_email" => $email]; if ($this->options->moderation["restrictCommentingPerUser"] === "post") { $args["post_id"] = $postId; } if ($this->options->moderation["commentRestrictionType"] === "both") { $count = get_comments($args); if ($count >= $this->options->moderation["userCommentsLimit"]) { wp_die(esc_html(sprintf($this->options->getPhrase("wc_not_allowed_to_comment_more_than"), $count))); } } else if ($this->options->moderation["commentRestrictionType"] === "parent" && !$comment_parent) { $args["parent"] = 0; $count = get_comments($args); if ($count >= $this->options->moderation["userCommentsLimit"]) { wp_die(esc_html(sprintf($this->options->getPhrase("wc_not_allowed_to_create_comment_thread_more_than"), $count))); } } else if ($this->options->moderation["commentRestrictionType"] === "reply" && $comment_parent) { $args["parent__not_in"] = [0]; $count = get_comments($args); if ($count >= $this->options->moderation["userCommentsLimit"]) { wp_die(esc_html(sprintf($this->options->getPhrase("wc_not_allowed_to_reply_more_than"), $count))); } } } } public function isUnapprovedInTree($comments) { foreach ($comments as $comment) { if ($comment->comment_approved === "0") { return true; } if ($children = $comment->get_children()) { return $this->isUnapprovedInTree($children); } } return false; } public function getCommentAuthor($comment, $args) { $user = ["user" => ""]; if ($comment->user_id) { $user["user"] = get_user_by("id", $comment->user_id); } else if ($this->options->login["isUserByEmail"]) { $user["user"] = get_user_by("email", $comment->comment_author_email); } $user["commentAuthorUrl"] = ("http://" === $comment->comment_author_url) ? "" : $comment->comment_author_url; $user["commentAuthorUrl"] = apply_filters("get_comment_author_url", $user["commentAuthorUrl"], $comment->comment_ID, $comment); $user["commentWrapClass"] = []; if ($user["user"]) { $user["authorName"] = $comment->comment_author; $user["authorAvatarField"] = $user["user"]->ID; $user["gravatarUserId"] = $user["user"]->ID; $user["gravatarUserEmail"] = $comment->comment_author_email; $user["profileUrl"] = in_array($user["user"]->ID, $args["posts_authors"]) ? get_author_posts_url($user["user"]->ID) : ""; $user["profileUrl"] = $this->getProfileUrl($user["profileUrl"], $user["user"]); if ($this->options->social["displayIconOnAvatar"] && ($socialProvider = get_user_meta($user["user"]->ID, self::WPDISCUZ_SOCIAL_PROVIDER_KEY, true))) { $user["commentWrapClass"][] = "wpd-soc-user-" . $socialProvider; if ($socialProvider === "facebook") { $user["socIcon"] = ""; } else if ($socialProvider === "instagram") { $user["socIcon"] = ""; } else if ($socialProvider === "twitter") { $user["socIcon"] = ""; } else if ($socialProvider === "google") { $user["socIcon"] = ""; } else if ($socialProvider === "disqus") { $user["socIcon"] = ""; } else if ($socialProvider === "qq") { $user["socIcon"] = ""; } else if ($socialProvider === "weibo") { $user["socIcon"] = ""; } else if ($socialProvider === "weixin") { $user["socIcon"] = ""; } else if ($socialProvider === "vk") { $user["socIcon"] = ""; } else if ($socialProvider === "wordpress") { $user["socIcon"] = ""; } else if ($socialProvider === "linkedin") { $user["socIcon"] = ""; } else if ($socialProvider === "ok") { $user["socIcon"] = ""; } else if ($socialProvider === "yandex") { $user["socIcon"] = ""; } else if ($socialProvider === "mailru") { $user["socIcon"] = ""; } else if ($socialProvider === "baidu") { $user["socIcon"] = ""; } else if ($socialProvider === "telegram") { $user["socIcon"] = ""; } } } else { $user["authorName"] = $comment->comment_author ? $comment->comment_author : esc_html($this->options->getPhrase("wc_anonymous")); $user["authorAvatarField"] = $comment->comment_author_email; $user["gravatarUserId"] = 0; $user["gravatarUserEmail"] = $comment->comment_author_email; $user["profileUrl"] = ""; } $user["authorName"] = apply_filters("wpdiscuz_comment_author", $user["authorName"], $comment); if ($this->options->thread_layouts["showAvatars"] && $this->options->wp["showAvatars"]) { $user["authorAvatarField"] = apply_filters("wpdiscuz_author_avatar_field", $user["authorAvatarField"], $comment, $user["user"], $user["profileUrl"]); $user["gravatarArgs"] = [ "wpdiscuz_gravatar_field" => $user["authorAvatarField"], "wpdiscuz_gravatar_size" => $args["wpdiscuz_gravatar_size"], "wpdiscuz_gravatar_user_id" => $user["gravatarUserId"], "wpdiscuz_gravatar_user_email" => $user["gravatarUserEmail"], "wpdiscuz_current_user" => $user["user"], "wpdiscuz_comment" => $comment ]; $user["avatar"] = get_avatar($user["gravatarArgs"]["wpdiscuz_gravatar_field"], $user["gravatarArgs"]["wpdiscuz_gravatar_size"], "", $user["authorName"], $user["gravatarArgs"]); } $user["authorNameHtml"] = $user["authorName"]; if ($this->options->login["enableProfileURLs"]) { if ($user["profileUrl"]) { $attributes = apply_filters("wpdiscuz_avatar_link_attributes", [ "href" => $user["profileUrl"], "target" => "_blank", "rel" => "noreferrer ugc" ]); if ($attributes && is_array($attributes)) { $attributesHtml = ""; foreach ($attributes as $attribute => $value) { $attributesHtml .= " $attribute='{$value}'"; } $user["authorAvatarSprintf"] = "%s"; } else { $user["authorAvatarSprintf"] = "%s"; } } if ((($href = $user["commentAuthorUrl"]) && $this->options->login["websiteAsProfileUrl"]) || ($href = $user["profileUrl"])) { $rel = "noreferrer ugc"; if (strpos($href, $args["site_url"]) !== 0) { $rel .= " nofollow"; } $attributes = apply_filters("wpdiscuz_author_link_attributes", [ "href" => $href, "rel" => $rel, "target" => "_blank" ]); if ($attributes && is_array($attributes)) { $attributesHtml = ""; foreach ($attributes as $attribute => $value) { $attributesHtml .= " $attribute='$value'"; } $user["authorNameHtml"] = "{$user["authorNameHtml"]}"; } else { $user["authorNameHtml"] = "{$user["authorNameHtml"]}"; } } } $this->fillUserRoleData($user, $args); return $user; } public function fillUserRoleData(&$user, $args) { $user["author_title"] = ""; $user["commentWrapRoleClass"] = []; if ($user["user"]) { if ($this->options->labels["blogRoles"]) { if ($user["user"]->roles && is_array($user["user"]->roles)) { foreach ($user["user"]->roles as $k => $role) { if (isset($this->options->labels["blogRoles"][$role])) { $user["commentWrapRoleClass"][] = "wpd-blog-user"; $user["commentWrapRoleClass"][] = "wpd-blog-" . $role; $rolePhrase = esc_html($this->options->getPhrase("wc_blog_role_" . $role, ["default" => ""])); if (!empty($this->options->labels["blogRoleLabels"][$role])) { $user["author_title"] = apply_filters("wpdiscuz_user_label", $rolePhrase, $user["user"]); } break; } } } else { $user["commentWrapRoleClass"][] = "wpd-blog-guest"; if (!empty($this->options->labels["blogRoleLabels"]["guest"])) { $user["author_title"] = esc_html($this->options->getPhrase("wc_blog_role_guest")); } } } if ($user["user"]->ID == $args["post_author"]) { $user["commentWrapRoleClass"][] = "wpd-blog-user"; $user["commentWrapRoleClass"][] = "wpd-blog-post_author"; if (!empty($this->options->labels["blogRoleLabels"]["post_author"])) { $user["author_title"] = esc_html($this->options->getPhrase("wc_blog_role_post_author")); } } } else { $user["commentWrapRoleClass"][] = "wpd-blog-guest"; if (!empty($this->options->labels["blogRoleLabels"]["guest"])) { $user["author_title"] = esc_html($this->options->getPhrase("wc_blog_role_guest")); } } } public function getProfileUrl($profile_url, $user) { if ($this->options->login["enableProfileURLs"] && $user) { if (class_exists("BuddyPress")) { $profile_url = self::getBPUserUrl($user->ID); } else if (class_exists("UM_API") || class_exists("UM")) { um_fetch_user($user->ID); $profile_url = um_user_profile_url(); } else if (function_exists("WPF")) { $profile_url = wpforo_member($user->ID, "profile_url"); } } return apply_filters("wpdiscuz_profile_url", $profile_url, $user); } public function umAuthorName($author_name, $comment) { if ($comment->user_id) { if (class_exists("UM_API") || class_exists("UM")) { um_fetch_user($comment->user_id); $author_name = um_user("display_name"); um_reset_user(); } } return $author_name; } public function multipleBlockquotesToOne($content) { $content = preg_replace('~<\/blockquote>\s?
~is', '

', $content); $content = preg_replace('~<\/code>\s?~is', '

', $content); return $content; } public static function isUserCanFollowOrSubscribe($email) { return !in_array(strstr($email, "@"), [ "@facebook.com", "@twitter.com", "@ok.ru", "@wechat.com", "@weibo.com", "@baidu.com", "@example.com", ]); } public function addRatingResetButton($postType, $post) { if (!$post || empty($post->ID)) { return; } $form = $this->wpdiscuzForm->getForm($post->ID); if ($form->getFormID() && ($form->getEnableRateOnPost() || $form->getRatingsExists())) { add_meta_box("wpd_reset_ratings", __("Reset Ratings", "wpdiscuz"), [ &$this, "resetRatingsButtons" ], $postType, "side", "low"); } } public function resetRatingsButtons($post) { $form = $this->wpdiscuzForm->getForm($post->ID); $ajax_nonce = wp_create_nonce("wpd-reset-rating"); if ($form->getFormID()) { if ($form->getEnableRateOnPost()) { ?>

getRatingsExists()) { ?>

options->thread_styles["theme"] === "wpd-dark"; $darkCommentAreaBG = $this->options->thread_styles["darkCommentAreaBG"] ? "background:" . $this->options->thread_styles["darkCommentAreaBG"] . ";" : ""; $darkCommentTextColor = $this->options->thread_styles["darkCommentTextColor"] ? "color:" . $this->options->thread_styles["darkCommentTextColor"] . ";" : ""; $darkCommentFieldsBG = $this->options->thread_styles["darkCommentFieldsBG"] ? "background:" . $this->options->thread_styles["darkCommentFieldsBG"] . ";" : ""; $darkCommentFieldsBorderColor = $this->options->thread_styles["darkCommentFieldsBorderColor"] ? "border: 1px solid " . $this->options->thread_styles["darkCommentFieldsBorderColor"] . ";" : ""; $darkCommentFieldsTextColor = $this->options->thread_styles["darkCommentFieldsTextColor"] ? "color:" . $this->options->thread_styles["darkCommentFieldsTextColor"] . ";" : ""; $darkCommentFieldsPlaceholderColor = $this->options->thread_styles["darkCommentFieldsPlaceholderColor"] ? "opacity:1;color:" . $this->options->thread_styles["darkCommentFieldsPlaceholderColor"] . ";" : ""; $defaultCommentAreaBG = $this->options->thread_styles["defaultCommentAreaBG"] ? "background:" . $this->options->thread_styles["defaultCommentAreaBG"] . ";" : ""; $defaultCommentTextColor = $this->options->thread_styles["defaultCommentTextColor"] ? "color:" . $this->options->thread_styles["defaultCommentTextColor"] . ";" : ""; $defaultCommentFieldsBG = $this->options->thread_styles["defaultCommentFieldsBG"] ? "background:" . $this->options->thread_styles["defaultCommentFieldsBG"] . ";" : ""; $defaultCommentFieldsBorderColor = $this->options->thread_styles["defaultCommentFieldsBorderColor"] ? "border: 1px solid " . $this->options->thread_styles["defaultCommentFieldsBorderColor"] . ";" : ""; $defaultCommentFieldsTextColor = $this->options->thread_styles["defaultCommentFieldsTextColor"] ? "color:" . $this->options->thread_styles["defaultCommentFieldsTextColor"] . ";" : ""; $defaultCommentFieldsPlaceholderColor = $this->options->thread_styles["defaultCommentFieldsPlaceholderColor"] ? "opacity:1;color:" . $this->options->thread_styles["defaultCommentFieldsPlaceholderColor"] . ";" : ""; if ($this->options->thread_styles["theme"] !== "wpd-minimal") { $blogRoles = $this->options->labels["blogRoles"]; if (!$blogRoles) { echo ".wc-comment-author a{color:#00B38F;} .wc-comment-label{background:#00B38F;}"; } foreach ($blogRoles as $role => $color) { echo "\r\n"; echo "#wpdcom .wpd-blog-" . esc_html($role) . " .wpd-comment-label{color: #ffffff; background-color: " . esc_html($color) . "; border: none;}\r\n"; echo "#wpdcom .wpd-blog-" . esc_html($role) . " .wpd-comment-author, #wpdcom .wpd-blog-" . esc_html($role) . " .wpd-comment-author a{color: " . esc_html($color) . ";}\r\n"; if ($role === "post_author") { echo "#wpdcom .wpd-blog-post_author .wpd-avatar img{border-color: " . esc_html($color) . ";}"; } if ($role !== "subscriber" && $role !== "guest") { echo "#wpdcom.wpd-layout-1 .wpd-comment .wpd-blog-" . esc_html($role) . " .wpd-avatar img{border-color: " . esc_html($color) . ";}\r\n"; } if ($role === "administrator" || $role === "editor" || $role === "post_author") { echo "#wpdcom.wpd-layout-2 .wpd-comment.wpd-reply .wpd-comment-wrap.wpd-blog-" . esc_html($role) . "{border-" . esc_html($left) . ": 3px solid " . esc_html($color) . ";}\r\n"; } if ($role !== "guest") { echo "#wpdcom.wpd-layout-2 .wpd-comment .wpd-blog-" . esc_html($role) . " .wpd-avatar img{border-bottom-color: " . esc_html($color) . ";}\r\n"; } echo "#wpdcom.wpd-layout-3 .wpd-blog-" . esc_html($role) . " .wpd-comment-subheader{border-top: 1px dashed " . esc_html($color) . ";}\r\n"; if ($role !== "subscriber" && $role !== "guest") { echo "#wpdcom.wpd-layout-3 .wpd-reply .wpd-blog-" . esc_html($role) . " .wpd-comment-right{border-" . esc_html($left) . ": 1px solid " . esc_html($color) . ";}\r\n"; } } ?> options->thread_styles["commentTextSize"] !== "14px") ? "#wpdcom .wpd-comment-text p{font-size:" . esc_html($this->options->thread_styles["commentTextSize"]) . ";}\r\n" : ""; ?> #comments, #respond, .comments-area, #wpdcom.wpd-dark{} #wpdcom .ql-editor > *{} #wpdcom .ql-editor::before{} #wpdcom .ql-toolbar{border-top:none;} #wpdcom .ql-container{border-bottom:none;} #wpdcom .wpd-form-row .wpdiscuz-item input[type="text"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="email"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="url"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="color"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="date"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="datetime"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="datetime-local"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="month"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="number"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="time"], #wpdcom textarea, #wpdcom select{} #wpdcom.wpd-dark .wpdiscuz-item.wpd-field-select select.wpdiscuz_select, #wpdcom.wpd-dark select{} #wpdcom .wpd-form-row .wpdiscuz-item textarea{} #wpdcom input::placeholder, #wpdcom textarea::placeholder, #wpdcom input::-moz-placeholder, #wpdcom textarea::-webkit-input-placeholder{} #wpdcom .wpd-comment-text{} .lity-wrap .wpd-item a{color: #666;} .lity-wrap .wpd-item a:hover{color: #222;} .wpd-inline-shortcode.wpd-active{background-color: #666;} #comments, #respond, .comments-area, #wpdcom{} #wpdcom .ql-editor > *{} #wpdcom .ql-editor::before{} #wpdcom .ql-toolbar{border-top:none;} #wpdcom .ql-container{border-bottom:none;} #wpdcom .wpd-form-row .wpdiscuz-item input[type="text"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="email"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="url"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="color"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="date"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="datetime"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="datetime-local"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="month"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="number"], #wpdcom .wpd-form-row .wpdiscuz-item input[type="time"], #wpdcom textarea, #wpdcom select{} #wpdcom .wpd-form-row .wpdiscuz-item textarea{} #wpdcom input::placeholder, #wpdcom textarea::placeholder, #wpdcom input::-moz-placeholder, #wpdcom textarea::-webkit-input-placeholder{} #wpdcom .wpd-comment-text{} #wpdcom .wpd-thread-head .wpd-thread-info{ border-bottom:2px solid options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpd-thread-head .wpd-thread-info.wpd-reviews-tab svg{fill: options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpd-thread-head .wpdiscuz-user-settings{border-bottom: 2px solid options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpd-thread-head .wpdiscuz-user-settings:hover{color: options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpd-comment .wpd-follow-link:hover{color: options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpd-comment-status .wpd-sticky{color: options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpd-thread-filter .wpdf-active{color: options->thread_styles["primaryColor"]); ?>; border-bottom-color:options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpd-comment-info-bar {border: 1px dashed colorBrightness($this->options->thread_styles["primaryColor"], '0.2')); ?>; background: colorBrightness($this->options->thread_styles["primaryColor"], '0.9')); ?>; } #wpdcom .wpd-comment-info-bar .wpd-current-view i{color: options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpd-filter-view-all:hover{background: options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpdiscuz-item .wpdiscuz-rating > label {color: options->rating["ratingInactiveColor"]); ?>;} #wpdcom .wpdiscuz-item .wpdiscuz-rating:not(:checked) > label:hover, .wpdiscuz-rating:not(:checked) > label:hover ~ label {} #wpdcom .wpdiscuz-item .wpdiscuz-rating > input ~ label:hover, #wpdcom .wpdiscuz-item .wpdiscuz-rating > input:not(:checked) ~ label:hover ~ label, #wpdcom .wpdiscuz-item .wpdiscuz-rating > input:not(:checked) ~ label:hover ~ label{color: options->rating["ratingHoverColor"]); ?>;} #wpdcom .wpdiscuz-item .wpdiscuz-rating > input:checked ~ label:hover, #wpdcom .wpdiscuz-item .wpdiscuz-rating > input:checked ~ label:hover, #wpdcom .wpdiscuz-item .wpdiscuz-rating > label:hover ~ input:checked ~ label, #wpdcom .wpdiscuz-item .wpdiscuz-rating > input:checked + label:hover ~ label, #wpdcom .wpdiscuz-item .wpdiscuz-rating > input:checked ~ label:hover ~ label, .wpd-custom-field .wcf-active-star, #wpdcom .wpdiscuz-item .wpdiscuz-rating > input:checked ~ label{ color:options->rating["ratingActiveColor"]); ?>;} #wpd-post-rating .wpd-rating-wrap .wpd-rating-stars svg .wpd-star{fill: options->rating["ratingInactiveColor"]); ?>;} #wpd-post-rating .wpd-rating-wrap .wpd-rating-stars svg .wpd-active{fill:options->rating["ratingActiveColor"]); ?>;} #wpd-post-rating .wpd-rating-wrap .wpd-rate-starts svg .wpd-star{fill:options->rating["ratingInactiveColor"]); ?>;} #wpd-post-rating .wpd-rating-wrap .wpd-rate-starts:hover svg .wpd-star{fill:options->rating["ratingHoverColor"]); ?>;} #wpd-post-rating.wpd-not-rated .wpd-rating-wrap .wpd-rate-starts svg:hover ~ svg .wpd-star{ fill:options->rating["ratingInactiveColor"]); ?>;} .wpdiscuz-post-rating-wrap .wpd-rating .wpd-rating-wrap .wpd-rating-stars svg .wpd-star{fill:options->rating["ratingInactiveColor"]); ?>;} .wpdiscuz-post-rating-wrap .wpd-rating .wpd-rating-wrap .wpd-rating-stars svg .wpd-active{fill:options->rating["ratingActiveColor"]); ?>;} #wpdcom .wpd-comment .wpd-follow-active{color:#ff7a00;} #wpdcom .page-numbers{color:#555;border:#555 1px solid;} #wpdcom span.current{background:#555;} #wpdcom.wpd-layout-1 .wpd-new-loaded-comment > .wpd-comment-wrap > .wpd-comment-right{background:options->thread_styles["newLoadedCommentBGColor"]); ?>;} #wpdcom.wpd-layout-2 .wpd-new-loaded-comment.wpd-comment > .wpd-comment-wrap > .wpd-comment-right{background:options->thread_styles["newLoadedCommentBGColor"]); ?>;} #wpdcom.wpd-layout-2 .wpd-new-loaded-comment.wpd-comment.wpd-reply > .wpd-comment-wrap > .wpd-comment-right{background:transparent;} #wpdcom.wpd-layout-2 .wpd-new-loaded-comment.wpd-comment.wpd-reply > .wpd-comment-wrap {background:options->thread_styles["newLoadedCommentBGColor"]); ?>;} #wpdcom.wpd-layout-3 .wpd-new-loaded-comment.wpd-comment > .wpd-comment-wrap > .wpd-comment-right{background:options->thread_styles["newLoadedCommentBGColor"]); ?>;} #wpdcom .wpd-follow:hover i, #wpdcom .wpd-unfollow:hover i, #wpdcom .wpd-comment .wpd-follow-active:hover i{color:options->thread_styles["primaryColor"]); ?>;} #wpdcom .wpdiscuz-readmore{cursor:pointer;color:options->thread_styles["primaryColor"]); ?>;} .wpd-custom-field .wcf-pasiv-star, #wpcomm .wpdiscuz-item .wpdiscuz-rating > label {color: options->rating["ratingInactiveColor"]); ?>;} .wpd-wrapper .wpd-list-item.wpd-active{border-top: 3px solid options->thread_styles["primaryColor"]); ?>;} #wpdcom.wpd-layout-2 .wpd-comment.wpd-reply.wpd-unapproved-comment .wpd-comment-wrap{border-: 3px solid options->thread_styles["newLoadedCommentBGColor"]); ?>;} #wpdcom.wpd-layout-3 .wpd-comment.wpd-reply.wpd-unapproved-comment .wpd-comment-right{border-: 1px solid options->thread_styles["newLoadedCommentBGColor"]); ?>;} #wpdcom .wpd-prim-button{background-color: options->thread_styles["primaryButtonBG"]); ?>; color: options->thread_styles["primaryButtonColor"]); ?>;} #wpdcom .wpd_label__check i.wpdicon-on{color: options->thread_styles["primaryButtonBG"]); ?>; border: 1px solid colorBrightness($this->options->thread_styles["primaryButtonBG"], 0.5)); ?>;} #wpd-bubble-wrapper #wpd-bubble-all-comments-count{color:options->thread_styles["bubbleColors"]); ?>;} #wpd-bubble-wrapper > div{background-color:options->thread_styles["bubbleColors"]); ?>;} #wpd-bubble-wrapper > #wpd-bubble #wpd-bubble-add-message{background-color:options->thread_styles["bubbleColors"]); ?>;} #wpd-bubble-wrapper > #wpd-bubble #wpd-bubble-add-message::before{border-left-color:options->thread_styles["bubbleColors"]); ?>; border-right-color:options->thread_styles["bubbleColors"]); ?>;} #wpd-bubble-wrapper.wpd-right-corner > #wpd-bubble #wpd-bubble-add-message::before{border-left-color:options->thread_styles["bubbleColors"]); ?>; border-right-color:options->thread_styles["bubbleColors"]); ?>;} .wpd-inline-icon-wrapper path.wpd-inline-icon-first{fill:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-inline-icon-count{background-color:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-inline-icon-count::before{border--color:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-inline-form-wrapper::before{border-bottom-color:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-inline-form-question{background-color:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-inline-form{background-color:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-last-inline-comments-wrapper{border-color:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-last-inline-comments-wrapper::before{border-bottom-color:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-last-inline-comments-wrapper .wpd-view-all-inline-comments{background:options->thread_styles["inlineFeedbackColors"]); ?>;} .wpd-last-inline-comments-wrapper .wpd-view-all-inline-comments:hover,.wpd-last-inline-comments-wrapper .wpd-view-all-inline-comments:active,.wpd-last-inline-comments-wrapper .wpd-view-all-inline-comments:focus{background-color:options->thread_styles["inlineFeedbackColors"]); ?>;} #wpdcom .ql-snow .ql-tooltip[data-mode="link"]::before{content:"";} #wpdcom .ql-snow .ql-tooltip.ql-editing a.ql-action::after{content:"";} options); if ($this->options->thread_styles["theme"] !== "wpd-minimal") { echo stripslashes($this->options->thread_styles["customCss"]); } $css = ob_get_clean(); /* xMinfy Star ********************************************************* */ if (apply_filters("wpdiscuz_minify_inline_css", true)) { $css = preg_replace('/\/\*((?!\*\/).)*\*\//', "", $css); $css = preg_replace('/\s{2,}/', " ", $css); $css = preg_replace('/\s*([:;{}])\s*/', "$1", $css); $css = preg_replace('/;}/', "}", $css); } /* xMinify End ********************************************************* */ return $css; } /** * Increases or decreases the brightness of a color by a percentage of the current brightness. * * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. * * @return string */ public function colorBrightness($hexCode, $adjustPercent = 1) { if (!$hexCode) { return '#000'; } $hexCode = ltrim($hexCode, '#'); if (strlen($hexCode) == 3) { $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; } $hexCode = array_map('hexdec', str_split($hexCode, 2)); foreach ($hexCode as & $color) { $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; $adjustAmount = ceil($adjustableLimit * $adjustPercent); $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); } return '#' . implode($hexCode); } public static function sanitize($action, $variable_name, $filter, $default = "") { if ($filter === "FILTER_SANITIZE_STRING") { $glob = INPUT_POST === $action ? $_POST : $_GET; if (key_exists($variable_name, $glob)) { return sanitize_text_field($glob[$variable_name]); } else { return $default; } } $variable = filter_input($action, $variable_name, $filter); return $variable ? $variable : $default; } public function handleCommentSubmission($post, $comment_parent, $isNewComment = true) { if (!$post) { return new WP_Error("post_not_found", __("Current post doesn't found.", "wpdiscuz")); } $_post = get_post($post); if (!$_post) { return new WP_Error("post_not_found", __("Current post doesn't found.", "wpdiscuz")); } $comment_post_id = $_post->ID; if ($comment_parent) { $comment_parent = absint($comment_parent); $comment_parent_object = get_comment($comment_parent); if ( 0 !== $comment_parent && ( !$comment_parent_object instanceof WP_Comment || 0 === (int)$comment_parent_object->comment_approved ) ) { do_action("comment_reply_to_unapproved_comment", $comment_post_id, $comment_parent); return new WP_Error("comment_reply_to_unapproved_comment", __("Sorry, replies to unapproved comments are not allowed."), 403); } } if (empty($_post->comment_status)) { do_action("comment_id_not_found", $comment_post_id); return new WP_Error("comment_id_not_found", __("Current post doesn't found.", "wpdiscuz")); } $status = get_post_status($_post); if (("private" === $status) && !current_user_can("read_post", $comment_post_id)) { return new WP_Error("comment_id_not_found", __("Current post doesn't found.", "wpdiscuz")); } $status_obj = get_post_status_object($status); if (!comments_open($comment_post_id)) { do_action("comment_closed", $comment_post_id); return new WP_Error("comment_closed", __("Sorry, comments are closed for this item.", "wpdiscuz"), 403); } elseif ("trash" === $status) { do_action("comment_on_trash", $comment_post_id); return new WP_Error("comment_on_trash", __("Current post doesn't found.", "wpdiscuz")); } elseif (!$status_obj->public && !$status_obj->private) { do_action("comment_on_draft", $comment_post_id); if (current_user_can("read_post", $comment_post_id)) { return new WP_Error("comment_on_draft", __("Sorry, comments are not allowed for this item.", "wpdiscuz"), 403); } else { return new WP_Error('comment_on_draft', __("Current post doesn't found.", "wpdiscuz")); } } elseif (post_password_required($comment_post_id)) { do_action('comment_on_password_protected', $comment_post_id); return new WP_Error('comment_on_password_protected', __("Sorry, comments are not allowed for this item.", "wpdiscuz")); } if ($isNewComment) { do_action('pre_comment_on_post', $comment_post_id); } return true; } public function updatePostAuthorsTrs($post_id) { set_transient(self::TRS_POSTS_AUTHORS, null); $this->dbManager->getPostsAuthors(); } public static function getBPUserUrl($user_id) { return function_exists('bp_members_get_user_url') ? bp_members_get_user_url($user_id) : bp_core_get_user_domain($user_id); } }