template-sab.php
175 lines
| 1 | <?php |
| 2 | |
| 3 | if (isset($sabox_options['sab_colored']) && '1' == $sabox_options['sab_colored']) { |
| 4 | $sabox_color = 'sabox-colored'; |
| 5 | } else { |
| 6 | $sabox_color = ''; |
| 7 | } |
| 8 | |
| 9 | if (isset($sabox_options['sab_web_position']) && '0' != $sabox_options['sab_web_position']) { |
| 10 | $sab_web_align = 'sab-web-position'; |
| 11 | } else { |
| 12 | $sab_web_align = ''; |
| 13 | } |
| 14 | |
| 15 | if (isset($sabox_options['sab_web_target']) && '1' == $sabox_options['sab_web_target']) { |
| 16 | $sab_web_target = '_blank'; |
| 17 | } else { |
| 18 | $sab_web_target = '_self'; |
| 19 | } |
| 20 | |
| 21 | $sab_web_rel = false; |
| 22 | if (isset($sabox_options['sab_web_rel']) && '1' == $sabox_options['sab_web_rel']) { |
| 23 | $sab_web_rel = true; |
| 24 | } |
| 25 | |
| 26 | $sab_author_link = sprintf('<a href="%s" class="vcard author" rel="author" itemprop="url"><span class="fn" itemprop="name">%s</span></a>', esc_url(get_author_posts_url($sabox_author_id)), esc_html(get_the_author_meta('display_name', $sabox_author_id))); |
| 27 | |
| 28 | $author_description = apply_filters('sab_user_description', get_the_author_meta('description', $sabox_author_id), $sabox_author_id); |
| 29 | |
| 30 | if ('' != $author_description || isset($sabox_options['sab_no_description']) && '0' == $sabox_options['sab_no_description']) { // hide the author box if no description is provided |
| 31 | |
| 32 | $show_guest_only = (get_post_meta(get_the_ID(), '_disable_sab_author_here', true)) ? get_post_meta(get_the_ID(), '_disable_sab_author_here', true) : "false"; |
| 33 | |
| 34 | if ($show_guest_only != "on") { |
| 35 | |
| 36 | echo '<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author">'; // start saboxplugin-wrap div |
| 37 | |
| 38 | echo '<div class="saboxplugin-tab">'; |
| 39 | |
| 40 | // author box gravatar |
| 41 | echo '<div class="saboxplugin-gravatar">'; |
| 42 | $custom_profile_image = get_the_author_meta('sabox-profile-image', $sabox_author_id); |
| 43 | if ('' != $custom_profile_image) { |
| 44 | $mediaid = attachment_url_to_postid($custom_profile_image); |
| 45 | $alt = $mediaid ? get_post_meta($mediaid, '_wp_attachment_image_alt', true) : get_the_author_meta('display_name', $sabox_author_id); |
| 46 | |
| 47 | $link = null; |
| 48 | $nofollow = false; |
| 49 | if (isset($sabox_options['sab_author_link'])) { |
| 50 | if ('author-page' == $sabox_options['sab_author_link']) { |
| 51 | |
| 52 | $link = get_user_meta($sabox_author_id, 'sab_box_link', true); |
| 53 | if (empty($link)) |
| 54 | $link = get_author_posts_url($sabox_author_id); |
| 55 | } elseif ('author-website' == $sabox_options['sab_author_link']) { |
| 56 | if (isset($sabox_options['sab_author_link_noffolow']) && '1' == $sabox_options['sab_author_link_noffolow']) { |
| 57 | $nofollow = true; |
| 58 | } |
| 59 | |
| 60 | $link = get_the_author_meta('user_url', $sabox_author_id); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | if ($link != null) |
| 65 | echo "<a " . ($nofollow?' rel="nofollow"':'') . " href='" . esc_url($link) . "'>"; |
| 66 | |
| 67 | echo '<img src="' . esc_url($custom_profile_image) . '" width="' . esc_attr($sabox_options['sab_avatar_size']) . '" height="' . esc_attr($sabox_options['sab_avatar_size']) . '" alt="' . esc_attr($alt) . '" itemprop="image">'; |
| 68 | |
| 69 | if ($link != null) |
| 70 | echo "</a>"; |
| 71 | } else { |
| 72 | echo get_avatar(get_the_author_meta('user_email', $sabox_author_id), $sabox_options['sab_avatar_size'], '', get_the_author_meta('display_name', $sabox_author_id), array('extra_attr' => 'itemprop="image"')); |
| 73 | } |
| 74 | |
| 75 | echo '</div>'; |
| 76 | |
| 77 | // author box name |
| 78 | echo '<div class="saboxplugin-authorname">'; |
| 79 | wpsabox_wp_kses_wf(apply_filters('sabox_author_html', $sab_author_link, $sabox_options, $sabox_author_id)); |
| 80 | if (is_user_logged_in() && get_current_user_id() == $sabox_author_id) { |
| 81 | echo '<a class="sab-profile-edit" target="_blank" href="' . esc_url(get_edit_user_link()) . '"> ' . esc_html__('Edit profile', 'simple-author-box') . '</a>'; |
| 82 | } |
| 83 | echo '</div>'; |
| 84 | |
| 85 | // author box description |
| 86 | echo '<div class="saboxplugin-desc">'; |
| 87 | echo '<div itemprop="description">'; |
| 88 | |
| 89 | $author_description = wptexturize($author_description); |
| 90 | $author_description = wpautop($author_description); |
| 91 | wpsabox_wp_kses_wf($author_description); |
| 92 | if ('' == $author_description && is_user_logged_in() && $sabox_author_id == get_current_user_id()) { |
| 93 | echo '<a target="_blank" href="' . admin_url() . 'profile.php?#wp-description-wrap">' . esc_html__('Add Biographical Info', 'simple-author-box') . '</a>'; |
| 94 | } |
| 95 | echo '</div>'; |
| 96 | echo '</div>'; |
| 97 | |
| 98 | if (is_single() || is_page()) { |
| 99 | if (get_the_author_meta('user_url') != '' && '1' == $sabox_options['sab_web']) { // author website on single |
| 100 | echo '<div class="saboxplugin-web ' . esc_attr($sab_web_align) . '">'; |
| 101 | echo '<a href="' . esc_url(get_the_author_meta('user_url', $sabox_author_id)) . '" target="' . esc_attr($sab_web_target) . '" ' . ($sab_web_rel?'rel="nofollow"':'') . '>' . esc_html(Simple_Author_Box_Helper::strip_prot(get_the_author_meta('user_url', $sabox_author_id))) . '</a>'; |
| 102 | echo '</div>'; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | |
| 107 | if (is_author() || is_archive()) { |
| 108 | if (get_the_author_meta('user_url') != '') { // force show author website on author.php or archive.php |
| 109 | echo '<div class="saboxplugin-web ' . esc_attr($sab_web_align) . '">'; |
| 110 | echo '<a href="' . esc_url(get_the_author_meta('user_url', $sabox_author_id)) . '" target="' . esc_attr($sab_web_target) . '" ' . ($sab_web_rel?'rel="nofollow"':'') . '>' . esc_html(Simple_Author_Box_Helper::strip_prot(get_the_author_meta('user_url', $sabox_author_id))) . '</a>'; |
| 111 | echo '</div>'; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | // author box clearfix |
| 116 | echo '<div class="clearfix"></div>'; |
| 117 | |
| 118 | // author box social icons |
| 119 | $author = get_userdata($sabox_author_id); |
| 120 | $show_social_icons = apply_filters('sabox_hide_social_icons', true, $author); |
| 121 | |
| 122 | |
| 123 | if (is_user_logged_in() && current_user_can('manage_options')) { |
| 124 | echo '<div class="sab-edit-settings">'; |
| 125 | echo '<a target="_blank" href="' . admin_url() . 'themes.php?page=simple-author-box">' . esc_html__('Settings', 'simple-author-box') . '<i class="dashicons dashicons-admin-settings"></i></a>'; |
| 126 | echo '</div>'; |
| 127 | } |
| 128 | |
| 129 | $show_email = isset($sabox_options['sab_email']) && '0' == $sabox_options['sab_email'] ? false : true; |
| 130 | $social_links = Simple_Author_Box_Helper::get_user_social_links($sabox_author_id, $show_email); |
| 131 | |
| 132 | if (empty($social_links) && is_user_logged_in() && $sabox_author_id == get_current_user_id()) { |
| 133 | echo '<a target="_blank" href="' . admin_url() . 'profile.php?#sabox-social-table">' . esc_html__('Add Social Links', 'simple-author-box') . '</a>'; |
| 134 | } |
| 135 | |
| 136 | if (isset($sabox_options['sab_hide_socials']) && '0' == $sabox_options['sab_hide_socials'] && $show_social_icons && !empty($social_links)) { // hide social icons div option |
| 137 | echo '<div class="saboxplugin-socials ' . esc_attr($sabox_color) . '">'; |
| 138 | |
| 139 | foreach ($social_links as $social_platform => $social_link) { |
| 140 | |
| 141 | if ('user_email' == $social_platform) { |
| 142 | $social_link = 'mailto:' . antispambot($social_link); |
| 143 | } |
| 144 | |
| 145 | if ('whatsapp' == $social_platform) { |
| 146 | $social_link = 'https://wa.me/' . $social_link; |
| 147 | } |
| 148 | |
| 149 | if ('phone' == $social_platform) { |
| 150 | $social_link = 'tel:' . $social_link; |
| 151 | } |
| 152 | |
| 153 | if ('telegram' == $social_platform) { |
| 154 | $social_link = 'https://t.me/' . $social_link; |
| 155 | } |
| 156 | |
| 157 | if ('skype' == $social_platform) { |
| 158 | $social_link = 'skype:' . $social_link . '?call'; |
| 159 | } |
| 160 | |
| 161 | if (!empty($social_link)) { |
| 162 | wpsabox_wp_kses_wf(Simple_Author_Box_Helper::get_sabox_social_icon($social_link, $social_platform)); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | echo '</div>'; |
| 167 | } // sab_socials |
| 168 | |
| 169 | echo '</div>'; // sabox-tab |
| 170 | |
| 171 | } // show guest only |
| 172 | echo '</div>'; // end of saboxplugin-wrap div |
| 173 | |
| 174 | } |
| 175 |