template-sab.php
119 lines
| 1 | <?php |
| 2 | if ( '1' == $sabox_options['sab_colored'] ) { |
| 3 | $sabox_color = 'sabox-colored'; |
| 4 | } else { |
| 5 | $sabox_color = ''; |
| 6 | } |
| 7 | |
| 8 | if ( '0' != $sabox_options['sab_web_position'] ) { |
| 9 | $sab_web_align = 'sab-web-position'; |
| 10 | } else { |
| 11 | $sab_web_align = ''; |
| 12 | } |
| 13 | |
| 14 | if ( '1' == $sabox_options['sab_web_target'] ) { |
| 15 | $sab_web_target = '_blank'; |
| 16 | } else { |
| 17 | $sab_web_target = '_self'; |
| 18 | } |
| 19 | |
| 20 | if ( '1' == $sabox_options['sab_web_rel'] ) { |
| 21 | $sab_web_rel = 'rel="nofollow"'; |
| 22 | } else { |
| 23 | $sab_web_rel = ''; |
| 24 | } |
| 25 | |
| 26 | $sab_author_link = sprintf( '<a href="%s" class="vcard author"><span class="fn">%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 | if ( get_the_author_meta( 'description' ) != '' || '0' == $sabox_options['sab_no_description'] ) { // hide the author box if no description is provided |
| 29 | |
| 30 | |
| 31 | echo '<div class="saboxplugin-wrap">'; // start saboxplugin-wrap div |
| 32 | |
| 33 | // author box gravatar |
| 34 | echo '<div class="saboxplugin-gravatar">'; |
| 35 | $custom_profile_image = get_the_author_meta( 'sabox-profile-image', $sabox_author_id ); |
| 36 | if ( '' != $custom_profile_image ) { |
| 37 | $mediaid = attachment_url_to_postid( $custom_profile_image ); |
| 38 | $alt = $mediaid ? get_post_meta( $mediaid, '_wp_attachment_image_alt', true) : ''; |
| 39 | echo '<img src="' . esc_url( $custom_profile_image ) . '" alt="' . esc_attr( $alt ) . '">'; |
| 40 | } else { |
| 41 | echo get_avatar( get_the_author_meta( 'user_email', $sabox_author_id ), '100' ); |
| 42 | } |
| 43 | |
| 44 | echo '</div>'; |
| 45 | |
| 46 | // author box name |
| 47 | echo '<div class="saboxplugin-authorname">'; |
| 48 | echo apply_filters( 'sabox_author_html', $sab_author_link, $sabox_options, $sabox_author_id ); |
| 49 | if ( is_user_logged_in() && get_current_user_id() == $sabox_author_id ) { |
| 50 | echo '<a class="sab-profile-edit" target="_blank" href="' . get_edit_user_link() . '"> ' . __( 'Edit profile', 'saboxplugin' ) . '</a>'; |
| 51 | } |
| 52 | echo '</div>'; |
| 53 | |
| 54 | |
| 55 | // author box description |
| 56 | echo '<div class="saboxplugin-desc">'; |
| 57 | echo '<div>'; |
| 58 | $description = get_the_author_meta( 'description', $sabox_author_id ); |
| 59 | $description = wptexturize( $description ); |
| 60 | $description = wpautop( $description ); |
| 61 | echo wp_kses_post( $description ); |
| 62 | echo '</div>'; |
| 63 | echo '</div>'; |
| 64 | |
| 65 | if ( is_single() ) { |
| 66 | if ( get_the_author_meta( 'user_url' ) != '' && '1' == $sabox_options['sab_web'] ) { // author website on single |
| 67 | echo '<div class="saboxplugin-web ' . esc_attr( $sab_web_align ) . '">'; |
| 68 | echo '<a href="' . esc_url( get_the_author_meta( 'user_url', $sabox_author_id ) ) . '" target="' . esc_attr( $sab_web_target ) . '" ' . $sab_web_rel . '>' . esc_html( get_the_author_meta( 'user_url', $sabox_author_id ) ) . '</a>'; |
| 69 | echo '</div>'; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | |
| 74 | if ( is_author() or is_archive() ) { |
| 75 | if ( get_the_author_meta( 'user_url' ) != '' ) { // force show author website on author.php or archive.php |
| 76 | echo '<div class="saboxplugin-web ' . esc_attr( $sab_web_align ) . '">'; |
| 77 | echo '<a href="' . esc_url( get_the_author_meta( 'user_url', $sabox_author_id ) ) . '" target="' . esc_attr( $sab_web_target ) . '" ' . $sab_web_rel . '>' . esc_html( get_the_author_meta( 'user_url', $sabox_author_id ) ) . '</a>'; |
| 78 | echo '</div>'; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | // author box clearfix |
| 83 | echo '<div class="clearfix"></div>'; |
| 84 | |
| 85 | // author box social icons |
| 86 | $author = get_userdata( $sabox_author_id ); |
| 87 | $show_social_icons = apply_filters( 'sabox_hide_social_icons', true, $author ); |
| 88 | |
| 89 | |
| 90 | |
| 91 | if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) { |
| 92 | echo '<div class="sab-edit-settings">'; |
| 93 | echo '<a target="_blank" href="' . admin_url() . 'admin.php?page=simple-author-box-options">' . __( 'Settings', 'saboxplugin' ) . '<i class="dashicons dashicons-admin-settings"></i></a>'; |
| 94 | echo '</div>'; |
| 95 | } |
| 96 | |
| 97 | $show_email = '0' == $sabox_options['sab_email'] ? false : true; |
| 98 | $social_links = Simple_Author_Box_Helper::get_user_social_links( $sabox_author_id, $show_email ); |
| 99 | |
| 100 | if ( '0' == $sabox_options['sab_hide_socials'] && $show_social_icons && ! empty( $social_links ) ) { // hide social icons div option |
| 101 | echo '<div class="saboxplugin-socials ' . esc_attr( $sabox_color ) . '">'; |
| 102 | |
| 103 | foreach ( $social_links as $social_platform => $social_link ) { |
| 104 | |
| 105 | if ( 'user_email' == $social_platform ) { |
| 106 | $social_link = 'mailto:' . antispambot( $social_link ); |
| 107 | } |
| 108 | |
| 109 | if ( ! empty( $social_link ) ) { |
| 110 | echo Simple_Author_Box_Helper::get_sabox_social_icon( $social_link, $social_platform ); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | |
| 115 | echo '</div>'; |
| 116 | } // end of social icons |
| 117 | echo '</div>'; // end of saboxplugin-wrap div |
| 118 | } |
| 119 |