asgarosforum = $object;
add_action('asgarosforum_breadcrumbs_profile', array($this, 'add_breadcrumbs_profile'));
add_action('asgarosforum_breadcrumbs_history', array($this, 'add_breadcrumbs_history'));
}
// Checks if the profile functionality is enabled.
public function functionalityEnabled() {
return $this->asgarosforum->options['enable_profiles'];
}
// Checks if profile links should be hidden for the current user.
public function hideProfileLink() {
if (!is_user_logged_in() && $this->asgarosforum->options['hide_profiles_from_guests']) {
return true;
} else {
return false;
}
}
public function get_user_data($user_id) {
return get_user_by('id', $user_id);
}
// Gets the current title.
public function get_profile_title() {
$currentTitle = __('Profile', 'asgaros-forum').$this->get_title_suffix();
return $currentTitle;
}
public function get_history_title() {
$currentTitle = __('Post History', 'asgaros-forum').$this->get_title_suffix();
return $currentTitle;
}
private function get_title_suffix() {
$suffix = '';
$userData = $this->get_user_data($this->asgarosforum->current_element);
if ($userData) {
$user_name = apply_filters('asgarosforum_filter_username', $userData->display_name, $userData);
$suffix = ': '.$user_name;
}
return $suffix;
}
// Sets the breadcrumbs.
public function add_breadcrumbs_profile() {
$elementLink = $this->asgarosforum->get_link('current');
$elementTitle = __('Profile', 'asgaros-forum').$this->get_title_suffix();
$this->asgarosforum->breadcrumbs->add_breadcrumb($elementLink, $elementTitle);
}
public function add_breadcrumbs_history() {
$elementLink = $this->asgarosforum->get_link('current');
$elementTitle = __('Post History', 'asgaros-forum').$this->get_title_suffix();
$this->asgarosforum->breadcrumbs->add_breadcrumb($elementLink, $elementTitle);
}
public function show_profile_header($user_data) {
$userOnline = ($this->asgarosforum->online->is_user_online($user_data->ID)) ? 'user-online' : 'user-offline';
$background_style = '';
$user_id = $user_data->ID;
echo '
';
}
public function show_profile_navigation($user_data) {
echo '';
// Defines an array for profile rows.
$profileRows = array();
// Show first name.
if (!empty($userData->first_name)) {
$profileRows['first_name'] = array(
'title' => __('First Name:', 'asgaros-forum'),
'value' => $userData->first_name
);
}
// Show usergroups.
$userGroups = AsgarosForumUserGroups::getUserGroupsOfUser($userData->ID, 'all', true);
if (!empty($userGroups)) {
$profileRows['usergroup'] = array(
'title' => __('Usergroups:', 'asgaros-forum'),
'value' => $userGroups,
'type' => 'usergroups'
);
}
// Show website.
if (!empty($userData->user_url)) {
$profileRows['website'] = array(
'title' => __('Website:', 'asgaros-forum'),
'value' => '
'.$userData->user_url.'',
);
}
// Show last seen.
if ($this->asgarosforum->online->functionality_enabled && $this->asgarosforum->options['show_last_seen']) {
$profileRows['last_seen'] = array(
'title' => __('Last seen:', 'asgaros-forum'),
'value' => $this->asgarosforum->online->last_seen($userData->ID),
);
}
// Show member since.
$profileRows['member_since'] = array(
'title' => __('Member Since:', 'asgaros-forum'),
'value' => $this->asgarosforum->format_date($userData->user_registered, false),
);
// Show biographical info.
if (!empty($userData->description)) {
$profileRows['bio'] = array(
'title' => __('Biographical Info:', 'asgaros-forum'),
'value' => trim(wpautop(esc_html($userData->description))),
);
}
// Show signature.
$signature = $this->asgarosforum->get_signature($userData->ID);
if ($signature !== false) {
$profileRows['signature'] = array(
'title' => __('Signature:', 'asgaros-forum'),
'value' => $signature,
);
}
$profileRows = apply_filters('asgarosforum_filter_profile_row', $profileRows, $userData);
foreach ($profileRows as $profileRow) {
if (!empty($profileRow['type'])) {
$this->renderProfileRow($profileRow['title'], $profileRow['value'], $profileRow['type']);
} else {
$this->renderProfileRow($profileRow['title'], $profileRow['value']);
}
}
do_action('asgarosforum_profile_row', $userData);
echo '';
echo '
';
// Topics started.
$count_topics = $this->asgarosforum->countTopicsByUser($userData->ID);
AsgarosForumStatistics::renderStatisticsElement(__('Topics Started', 'asgaros-forum'), $count_topics, 'far fa-comments');
// Replies created.
$count_posts = $this->asgarosforum->countPostsByUser($userData->ID);
$count_posts = $count_posts - $count_topics;
AsgarosForumStatistics::renderStatisticsElement(__('Replies Created', 'asgaros-forum'), $count_posts, 'far fa-comment');
// Likes Received.
if ($this->asgarosforum->options['enable_reactions']) {
$count_likes = $this->asgarosforum->reactions->get_reactions_received($userData->ID, 'up');
AsgarosForumStatistics::renderStatisticsElement(__('Likes Received', 'asgaros-forum'), $count_likes, 'fas fa-thumbs-up');
}
echo '
';
do_action('asgarosforum_custom_profile_content', $userData);
$current_user_id = get_current_user_id();
if ($userData->ID == $current_user_id) {
echo '
';
echo '';
echo esc_html__('Edit Profile', 'asgaros-forum');
echo '';
}
// Check if the current user can ban this user.
if ($this->asgarosforum->permissions->can_ban_user($current_user_id, $userData->ID)) {
if ($this->asgarosforum->permissions->isBanned($userData->ID)) {
$url = $this->getProfileLink($userData, array('unban_user' => $userData->ID));
$nonce_url = wp_nonce_url($url, 'unban_user_'.$userData->ID);
echo '
'.esc_html__('Unban User', 'asgaros-forum').'';
} else {
$url = $this->getProfileLink($userData, array('ban_user' => $userData->ID));
$nonce_url = wp_nonce_url($url, 'ban_user_'.$userData->ID);
echo '
'.esc_html__('Ban User', 'asgaros-forum').'';
}
}
echo '
';
}
} else {
esc_html_e('This user does not exist.', 'asgaros-forum');
}
}
public function renderProfileRow($cellTitle, $cellValue, $type = 'default') {
echo '