template-sab.php 4.2 KB

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