Skip to content

Instantly share code, notes, and snippets.

@sylwit
Forked from Manoz/functions.php
Last active August 29, 2015 13:57
Show Gist options
  • Save sylwit/9731109 to your computer and use it in GitHub Desktop.
Save sylwit/9731109 to your computer and use it in GitHub Desktop.
<?php
// Add social networks fields to aithor profil and author info box
add_filter('user_contactmethods', 'manoz_profile_fields');
function manoz_profile_fields( $profile_fields ) {
$profile_fields['twitter'] = __( 'Twitter URL', 'textdomain' );
$profile_fields['facebook'] = __( 'Facebook URL', 'textdomain' );
$profile_fields['gplus'] = __( 'Google+ URL', 'textdomain' );
$profile_fields['linkedin'] = __( 'LinkedIn URL', 'textdomain' );
$profile_fields['dribbble'] = __( 'Dribbble URL', 'textdomain' );
$profile_fields['pinterest'] = __( 'Pinterest URL', 'textdomain' );
$profile_fields['instagram'] = __( 'Instagram URL', 'textdomain' );
return $profile_fields;
}
?>
<?php
/**
* Place this after your </article> tag (for exemple)
* I use a custom fontello pack for the icons.
* My icon classes are: <i class="icon-name"></i>
*/
// Author info box
$social_names = array( 'link', 'twitter', 'facebook', 'gplus', 'linkedin', 'dribbble', 'pinterest', 'instagram' );
$social_urls = array();
foreach( $social_names as $social_name ) {
$link = get_the_author_meta( $social_name );
if( !empty($link) ) {
if(strpos($link, "http") === 0) {
$new_url = 'http://' . $link;
}
$social_urls[$social_name] = $link;
}
}
?>
<div class="author-infobox">
<?php echo get_avatar( get_the_author_meta( 'ID' ), 60 ); // 60 is the avatar size ?>
<div class="author-description clearfix">
<h3><?php echo __( 'About', 'textdomain' );?> <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author(); ?></a></h3>
<?php if ( !empty( $social_urls ) ) { ?>
<div class="author-social">
<?php echo '<ul>'; ?>
<?php
foreach ( $social_urls as $social_name => $social_url ) {
echo '<li><a href="'.$social_url.'"><i class="icon-'.$social_name.'"></i></a></li>';
}
?>
<?php echo '</ul>'; ?>
</div>
<?php } ?>
<p><?php the_author_meta( 'user_description' ); ?></p>
</div>
</div>
/* Some style for the author box */
/* Author info box
------------------------------- */
.author-infobox {
padding: 20px;
border: 1px solid;
border-color: #e5e6e9 #dfe0e4 #d0d1d5;
border-radius: 0 0 3px 3px;
background-color: #fff;
}
.author-infobox img {
float: left;
margin: 0 10px 5px 0;
border-radius: 2px;
box-shadow: 0 1px 2px #999; /* Callback for old browsers */
box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.author-description {position: relative};
.author-description h3 {
margin-top: 0;
font-size: 18px;
font-style: italic;
color: #aaa;
}
.author-social {
position: absolute;
top: 0;
right: 0;
font-size: 14px;
}
.author-social ul li {
display: inline-block;
vertical-align: top;
zoom: 1; /* IE fix */
*display: inline; /* IE fix */
}
.author-social a {
opacity: 1;
-webkit-transition: opacity .2s;
transition: opacity .2s;
}
.author-social a:hover {
opacity: .4;
-webkit-transition: opacity .2s;
transition: opacity .2s;
}
.author-social a .icon-link {color: #333333;}
.author-social a .icon-twitter {color: #4B9CDB;}
.author-social a .icon-facebook {color: #3b5998;}
.author-social a .icon-gplus {color: #dd4c39;}
.author-social a .icon-linkedin {color: #1b86be;}
.author-social a .icon-dribbble {color: #ea4c89;}
.author-social a .icon-pinterest {color: #c42329;}
.author-social a .icon-instagram {color: #3f729b;}
@sylwit
Copy link
Author

sylwit commented Mar 23, 2014

C'est codé à l'aveugle donc pas testé mais c'est une piste d'optimisation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment