options();
$userID = '';
if (get_the_author_meta('ID')) {
$userID = get_the_author_meta('ID');
} else {
$userID = get_current_user_id();
}
/**
* AUTHOR meta
* @see https://developer.wordpress.org/reference/functions/get_the_author_meta/
*/
$authorDisplayName = get_the_author_meta('display_name', $userID);
$authorEmail = get_the_author_meta('user_email', $userID);
$authorDescription = get_the_author_meta('user_description', $userID);
$authorUrl = get_the_author_meta('user_url', $userID);
$authorMemberSince = get_the_author_meta('user_registered', $userID);
$authorAdminColorSheme = get_the_author_meta('admin_color', $userID);
$phonenumber = get_the_author_meta('phonenumber', $userID);
/**
* USER meta
* @see https://codex.wordpress.org/Function_Reference/get_user_meta
*/
$userPic = get_user_meta($userID, 'user_thumb', true);
$userFirstName = get_user_meta($userID, 'first_name', true);
$userLastName = get_user_meta($userID, 'last_name', true);
$userNickName = get_user_meta($userID, 'nickname', true);
$userDescription = get_user_meta($userID, 'description', true);
$userAdminColor = get_user_meta($userID, 'admin_color', true);
$userClosedpostboxesPage = get_user_meta($userID, 'closedpostboxes_page', true);
$userPrimaryBlog = get_user_meta($userID, 'primary_blog', true);
$userRichEditing = get_user_meta($userID, 'rich_editing', true);
$userSourceDomain = get_user_meta($userID, 'source_domain', true);
/**
* USER plugin extra
* @see https://codex.wordpress.org/Function_Reference/get_user_meta
*/
$userMainDescription = get_user_meta($userID, 'user_main_description', true);
$isAuthorBoxActivated = false;
if ($post) {
$isAuthorBoxActivated = get_post_meta($post->ID, 'mb-author-box-pro-meta-activate', true);
}
/**
* USER data (Frontend)
* @see https://codex.wordpress.org/Function_Reference/get_userdata
*/
$userInfo = get_userdata($userID);
/**
* USER query
*/
$user = new WP_User($userID);
$userRoles = '';
foreach ($user->roles as $role) {
$role = get_role($role);
if ($role != null) {
$userRoles .= $role->name . ' '; // String all user roles
}
}
// AUTHOR posts
$userPostsCount = number_format_i18n(get_the_author_posts());
// USER avatar
if (isset($userPic) && !empty($userPic)) {
$image = wp_get_attachment_image_src($userPic, 'thumbnail'); // Get MB Author Box Avatar
} else {
$image = get_avatar_url(get_the_author_meta('ID'), 87); // Get avatar
}
// OPTIONS
$avatarImageUrl = !empty($userPic) ? 'style="background-image: url(' . $image[0] . ');"' : 'style="background-image: url(' . $image . ');"';
$avatarImageBorder = isset($mbPluginABoptions['avatar-border']) && !empty($mbPluginABoptions['avatar-border']) ? $mbPluginABoptions['avatar-border'] : 'no';
$avatarImageStyle = isset($mbPluginABoptions['avatar-style']) && !empty($mbPluginABoptions['avatar-style']) ? $mbPluginABoptions['avatar-style'] : 'square';
$avatarImageShadow = isset($mbPluginABoptions['avatar-shadow']) && !empty($mbPluginABoptions['avatar-shadow']) ? $mbPluginABoptions['avatar-shadow'] : '';
$mailSubject = isset($mbPluginABoptions['mail-subject']) && !empty($mbPluginABoptions['mail-subject']) ? $mbPluginABoptions['mail-subject'] : '';
$latestpostsNumber = isset($mbPluginABoptions['latestposts-number']) && !empty($mbPluginABoptions['latestposts-number']) ? $mbPluginABoptions['latestposts-number'] : '5';
$boxShadow = isset($mbPluginABoptions['box-shadow']) && $mbPluginABoptions['box-shadow'] == 'on' ? 'shadow' : '';
$boxRadius = isset($mbPluginABoptions['box-radius']) && !empty($mbPluginABoptions['box-radius']) ? $mbPluginABoptions['box-radius'] : '';
$tabChange = isset($mbPluginABoptions['tab-change']) && !empty($mbPluginABoptions['tab-change']) ? $mbPluginABoptions['tab-change'] : '';
$latestpostsDate = isset($mbPluginABoptions['latestposts-date']) && !empty($mbPluginABoptions['latestposts-date']) ? $mbPluginABoptions['latestposts-date'] : '';
$latestpostsTime = isset($mbPluginABoptions['latestposts-time']) && !empty($mbPluginABoptions['latestposts-time']) ? $mbPluginABoptions['latestposts-time'] : '';
$latestpostsComments = isset($mbPluginABoptions['latestposts-comments']) && !empty($mbPluginABoptions['latestposts-comments']) ? $mbPluginABoptions['latestposts-comments'] : '';
if ($isAuthorBoxActivated == 'on' || is_admin()) {
$backturn = '';
// ADMIN color preview
if (is_admin()) {
$colors = get_option('mb-author-admin-colors'); // Get admin colors from backend
$backturn .= '
';
$backturn .= '';
$backturn .= ' | ';
$backturn .= ' | ';
$backturn .= ' | ';
$backturn .= ' | ';
$backturn .= '
';
$backturn .= '
';
}
// Tabs start
$backturn .= '';
// ABOUT
if (isset($mbPluginABoptions['about']) && $mbPluginABoptions['about'] == 'on') {
$backturn .= '
';
$backturn .= '
';
// ABOUT Label
$backturn .= '
';
$backturn .= '
';
// ABOUT Heading
$backturn .= '';
// ABOUT Avatar
if (isset($mbPluginABoptions['avatar']) && $mbPluginABoptions['avatar'] == 'on') {
$backturn .= '
';
$backturn .= '
';
$backturn .= '
';
$backturn .= '
';
} else {
$backturn .= '
';
}
// ABOUT Description
$backturn .= $authorDisplayName . '
';
// $backturn .= $userInfo->description;
if (!empty($userMainDescription)) {
$backturn .= nl2br(html_entity_decode($userMainDescription, ENT_QUOTES, 'UTF-8'));
} else {
$backturn .= '
';
$backturn .= html_entity_decode($userDescription, ENT_QUOTES, 'UTF-8');
$backturn .= '
';
}
$backturn .= '
';
$backturn .= '
';
// OPTIONS
$checkArray = array(
isset($mbPluginABoptions['facebook']) ? $mbPluginABoptions['facebook'] : '',
isset($mbPluginABoptions['googleplus']) ? $mbPluginABoptions['googleplus'] : '',
isset($mbPluginABoptions['twitter']) ? $mbPluginABoptions['twitter'] : '',
isset($mbPluginABoptions['flickr']) ? $mbPluginABoptions['flickr'] : '',
isset($mbPluginABoptions['pinterest']) ? $mbPluginABoptions['pinterest'] : '',
isset($mbPluginABoptions['youtube']) ? $mbPluginABoptions['youtube'] : '',
isset($mbPluginABoptions['github']) ? $mbPluginABoptions['github'] : '',
isset($mbPluginABoptions['tumblr']) ? $mbPluginABoptions['tumblr'] : '',
isset($mbPluginABoptions['soundcloud']) ? $mbPluginABoptions['soundcloud'] : '',
isset($mbPluginABoptions['skype']) ? $mbPluginABoptions['skype'] : '',
isset($mbPluginABoptions['xing']) ? $mbPluginABoptions['xing'] : '',
isset($mbPluginABoptions['instagram']) ? $mbPluginABoptions['instagram'] : '',
isset($mbPluginABoptions['whatsapp']) ? $mbPluginABoptions['whatsapp'] : '',
isset($mbPluginABoptions['jsfiddle']) ? $mbPluginABoptions['jsfiddle'] : '',
isset($mbPluginABoptions['snapchat']) ? $mbPluginABoptions['snapchat'] : '',
isset($mbPluginABoptions['linkedin']) ? $mbPluginABoptions['linkedin'] : ''
);
$backturn .= '
';
$backturn .= '
';
}
// CONTACT
if (isset($mbPluginABoptions['contact']) && $mbPluginABoptions['contact'] == 'on') {
$backturn .= '
';
$backturn .= '
';
// CONTACT Label
$backturn .= '
';
$backturn .= '
';
$backturn .= '';
// $backturn .= 'Author ID: ' . $userInfo->ID . "
";
// $backturn .= 'Authorname: ' . $userInfo->user_login . "
";
$backturn .= $authorDisplayName . "
";
// $backturn .= $userFirstName . ' ' . $userLastName . '
';
// $backturn .= '(
' . $userRoles . ')
';
// $backturn .= 'Author Nickname: ' . $userInfo->nickname . "
";
// $backturn .= $userInfo->display_name . " (
" . implode(', ', $userInfo->roles) . ")
";
// EMAIL
if (isset($mbPluginABoptions['mail']) && $mbPluginABoptions['mail'] == 'on') {
$backturn .= '
';
}
// PHONENUMBER
if (isset($mbPluginABoptions['phonenumber']) && $mbPluginABoptions['phonenumber'] == 'on') {
$backturn .= '
';
}
// WEBSITE
if (isset($mbPluginABoptions['website']) && $mbPluginABoptions['website'] == 'on') {
$backturn .= '
';
$backturn .= '
';
// Website link open
if ($authorUrl && (isset($mbPluginABoptions['website-link']) && $mbPluginABoptions['website-link'] == 'on')) {
$websiteBlank = '';
if (isset($mbPluginABoptions['website-blank']) && $mbPluginABoptions['website-blank'] == 'on') {
$websiteBlank = 'target="_blank"';
}
$backturn .= '
';
}
if ($authorUrl) {
$backturn .= $authorUrl;
} else {
$backturn .= __('not specified', 'author-box-pro');
}
// Website link close
if ($authorUrl && (isset($mbPluginABoptions['website-link']) && $mbPluginABoptions['website-link'] == 'on')) {
$backturn .= '';
}
if ($authorUrl) {
$backturn .= '
';
}
$backturn .= '
';
}
$backturn .= '
';
// $backturn .= $authorMemberSince . '
';
$plugininfo = $MB_AUTHOR_BOX_HELPER->check_plugin('sharing-social-safe/sharing-social-safe.php');
if ($plugininfo['plugin-active'] == true) {
if (!empty($checkArray) && is_array($checkArray)) {
$atts = array('follow' => '');
foreach ($checkArray as $check) {
$atts['follow'] .= $check . ',';
}
if (isset($mbPluginABoptions['social']) && $mbPluginABoptions['social'] == 'on') {
$backturn .= $MELIBU_PLUGIN_SHARE->social($atts);
}
}
}
$backturn .= '
';
$backturn .= '
';
}
// LATESTPOSTS
if (isset($mbPluginABoptions['latestposts']) && $mbPluginABoptions['latestposts'] == 'on') {
$backturn .= '
';
$backturn .= '
';
$backturn .= '
';
$backturn .= '
';
$backturn .= '';
$backturn .= '
';
$backturn .= __('Blogged:', 'author-box-pro');
$backturn .= ' ' . $userPostsCount . ' ' . __('Posts', 'author-box-pro') . '
';
$backturn .= '
';
$backturn .= '
';
// LATESTPOSTS
$args = array(
'post_type' => 'post',
'numberposts' => $latestpostsNumber,
'author' => $userID
);
$recent_posts = wp_get_recent_posts($args);
foreach ($recent_posts as $recent) {
$imageurl = get_the_post_thumbnail_url($recent["ID"]);
$backturn .= '- ';
if ($imageurl) {
$backturn .= '';
}
$backturn .= '
';
$backturn .= '
' . $recent["post_title"] . ' (' . __('Latest post', 'author-box-pro') . ')';
$backturn .= '
';
if ($latestpostsDate == 'on') {
$backturn .= ' ' . date('d.m.Y', strtotime($recent['post_date']));
}
if ($latestpostsTime == 'on') {
$backturn .= ' | ' . date('H:i:s', strtotime($recent['post_date']));
}
if ($latestpostsComments == 'on') {
$backturn .= ' | Comments: ' . get_comments_number($recent['ID']);
}
$backturn .= '';
$backturn .= '
';
$backturn .= '';
$backturn .= ' ';
}
wp_reset_query();
$backturn .= '
';
$backturn .= '
';
$backturn .= '
';
}
// OTHER
if (isset($mbPluginABoptions['other']) && $mbPluginABoptions['other'] == 'on') {
$backturn .= '
';
$backturn .= '
';
$backturn .= '
';
$backturn .= '
';
$backturn .= '';
$backturn .= '
';
if (isset($mbPluginABoptions['other-text']) && !empty($mbPluginABoptions['other-text'])) {
$backturn .= html_entity_decode($mbPluginABoptions['other-text'], ENT_QUOTES, 'UTF-8');
}
$backturn .= '
';
$backturn .= '
';
$backturn .= '
';
}
$backturn .= '
'; // Tabs end
if ($echo === true) {
echo $backturn;
} else {
return $backturn;
}
}
}
/**
*
*/
public function author_short($echo = false) {
global $MB_AUTHOR_BOX_HELPER;
$mbPluginABoptions = $MB_AUTHOR_BOX_HELPER->options();
// AUTHOR
if (get_the_author_meta('ID')) {
$userID = get_the_author_meta('ID');
} else {
$userID = get_current_user_id();
}
$authorDisplayName = get_the_author_meta('display_name', $userID);
// USER
$userUserUrl = get_user_meta($userID, 'user_url', true);
$userDescription = get_user_meta($userID, 'description', true);
$userMainDescription = get_user_meta($userID, 'user_main_description', true);
// USER avatar
$userPic = get_user_meta($userID, 'user_thumb', true);
if (!empty($userPic)) {
$image = wp_get_attachment_image_src($userPic, 'thumbnail'); // Get MB Author Box Avatar
} else {
$image = get_avatar_url(get_the_author_meta('ID'), 87); // Get avatar
}
$output = '
';
if ($echo === true) {
echo $output;
} else {
return $output;
}
}
}
global $MB_AUTHOR_BOX;
$MB_AUTHOR_BOX = new MB_AUTHOR_BOX();
add_action('show_user_profile', array('MB_AUTHOR_BOX', 'show_user_profile'));
add_action('edit_user_profile', array('MB_AUTHOR_BOX', 'show_user_profile'));
add_action('user_new_form', array('MB_AUTHOR_BOX', 'show_user_profile'));
add_action('user_register', array('MB_AUTHOR_BOX', 'profile_update'));
add_action('profile_update', array('MB_AUTHOR_BOX', 'profile_update'));
}