<?php 
__('Lateset News','lioit');
/*-----------------------------------------------------------------------------------*/
#Author Box
/*-----------------------------------------------------------------------------------*/
function lioit_author_box($avatar = true , $social = true ){
	
	if( $avatar ) : ?>

<div class="author-wrap">
  <div class="author-avatar"> <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'MFW_author_bio_avatar_size', 60 ) ); ?> </div>
  <!-- #author-avatar -->
  <?php endif; ?>
  <div class="author-description">
    <?php the_author_meta( 'description' ); ?>
  </div>
  <!-- #author-description -->
  <?php  if( $social ) :	?>
  <div class="author-social">
    <?php if ( get_the_author_meta( 'url' ) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'url' ); ?>" title="<?php the_author_meta( 'display_name' ); ?><?php _e( " 's site", 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_site.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'twitter' ) ) : ?>
    <a class="ttip" href="http://twitter.com/<?php the_author_meta( 'twitter' ); ?>" title="<?php the_author_meta( 'display_name' ); ?><?php _e( '  on Twitter', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_twitter.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'facebook' ) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'facebook' ); ?>" title="<?php the_author_meta( 'display_name' ); ?> <?php _e( '  on Facebook', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_facebook.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'google' ) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'google' ); ?>" title="<?php the_author_meta( 'display_name' ); ?> <?php _e( '  on Google+', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_google.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'linkedin' ) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'linkedin' ); ?>" title="<?php the_author_meta( 'display_name' ); ?> <?php _e( '  on Linkedin', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_linkedin.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'flickr' ) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'flickr' ); ?>" title="<?php the_author_meta( 'display_name' ); ?><?php _e( '  on Flickr', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_flickr.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'youtube' ) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'youtube' ); ?>" title="<?php the_author_meta( 'display_name' ); ?><?php _e( '  on YouTube', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_youtube.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'pinterest' ) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'pinterest' ); ?>" title="<?php the_author_meta( 'display_name' ); ?><?php _e( '  on Pinterest', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_pinterest.png" alt="" /></a>
    <?php endif ?>
  </div>
  <?php endif; ?>
  <div class="clear"></div>
</div>
<?php
}



/*-----------------------------------------------------------------------------------*/
# Add user's social accounts
/*-----------------------------------------------------------------------------------*/
add_action( 'show_user_profile', 'lioit_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'lioit_show_extra_profile_fields' );
function lioit_show_extra_profile_fields( $user ) { ?>
<h3>
  <?php _e( 'Social Networking', 'lioit' ) ?>
</h3>
<table class="form-table">
  <tr>
    <th><label for="google">Google + URL</label></th>
    <td><input type="text" name="google" id="google" value="<?php echo esc_attr( get_the_author_meta( 'google', $user->ID ) ); ?>" class="regular-text" />
      <br /></td>
  </tr>
  <tr>
    <th><label for="twitter">Twitter Username</label></th>
    <td><input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" />
      <br /></td>
  </tr>
  <tr>
    <th><label for="facebook">FaceBook URL</label></th>
    <td><input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" class="regular-text" />
      <br /></td>
  </tr>
  <tr>
    <th><label for="linkedin">linkedIn URL</label></th>
    <td><input type="text" name="linkedin" id="linkedin" value="<?php echo esc_attr( get_the_author_meta( 'linkedin', $user->ID ) ); ?>" class="regular-text" />
      <br /></td>
  </tr>
  <tr>
    <th><label for="flickr">Flickr URL</label></th>
    <td><input type="text" name="flickr" id="flickr" value="<?php echo esc_attr( get_the_author_meta( 'flickr', $user->ID ) ); ?>" class="regular-text" />
      <br /></td>
  </tr>
  <tr>
    <th><label for="youtube">YouTube URL</label></th>
    <td><input type="text" name="youtube" id="youtube" value="<?php echo esc_attr( get_the_author_meta( 'youtube', $user->ID ) ); ?>" class="regular-text" />
      <br /></td>
  </tr>
  <tr>
    <th><label for="pinterest">Pinterest URL</label></th>
    <td><input type="text" name="pinterest" id="pinterest" value="<?php echo esc_attr( get_the_author_meta( 'pinterest', $user->ID ) ); ?>" class="regular-text" />
      <br /></td>
  </tr>
</table>
<?php }

## Save user's social accounts
add_action( 'personal_options_update', 'lioit_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'lioit_save_extra_profile_fields' );
function lioit_save_extra_profile_fields( $user_id ) {
	if ( !current_user_can( 'edit_user', $user_id ) ) return false;
	update_user_meta( $user_id, 'google', $_POST['google'] );
	update_user_meta( $user_id, 'pinterest', $_POST['pinterest'] );
	update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
	update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
	update_user_meta( $user_id, 'linkedin', $_POST['linkedin'] );
	update_user_meta( $user_id, 'flickr', $_POST['flickr'] );
	update_user_meta( $user_id, 'youtube', $_POST['youtube'] );
}
/*-----------------------------------------------------------------------------------*/
# Login Form
/*-----------------------------------------------------------------------------------*/
function lioit_login_form( $login_only  = 0 ) {
	global $user_ID, $user_identity, $user_level;
	
	if ( $user_ID ) : ?>
<?php if( empty( $login_only ) ): ?>
<div class="widgetContent">
<div id="user-login">
  <p class="welcome-text">
    <?php _e( 'Welcome' , 'lioit' ) ?>
    <strong><?php echo $user_identity ?></strong> .</p>
  <span class="author-avatar"><?php echo get_avatar( $user_ID, $size = '100'); ?></span>
  <ul>
    <li class="userWpAdmin"><a href="<?php echo home_url() ?>/wp-admin/">
      <?php _e( 'Dashboard' , 'lioit' ) ?>
      </a></li>
    <li class="userprofile"><a href="<?php echo home_url() ?>/wp-admin/profile.php">
      <?php _e( 'Your Profile' , 'lioit' ) ?>
      </a></li>
    <li class="userlogout"><a href="<?php echo wp_logout_url(); ?>">
      <?php _e( 'Logout' , 'lioit' ) ?>
      </a></li>
  </ul>
  <div class="author-social">
    <?php if ( get_the_author_meta( 'url' , $user_ID) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'url' , $user_ID); ?>" title="<?php echo $user_identity ?> <?php _e( " 's site", 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_site.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'twitter' , $user_ID) ) : ?>
    <a class="ttip" href="http://twitter.com/<?php the_author_meta( 'twitter' ); ?>" title="<?php echo $user_identity ?><?php _e( '  on Twitter', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_twitter.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'facebook' , $user_ID) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'facebook' ); ?>" title="<?php echo $user_identity ?><?php _e( '  on Facebook', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_facebook.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'google' , $user_ID) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'google' ); ?>" title="<?php echo $user_identity ?><?php _e( '  on Google+', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_google.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'linkedin' , $user_ID) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'linkedin' , $user_ID); ?>" title="<?php echo $user_identity ?><?php _e( '  on Linkedin', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_linkedin.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'flickr' , $user_ID) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'flickr' , $user_ID); ?>" title="<?php echo $user_identity ?><?php _e( '  on Flickr', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_flickr.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'youtube' , $user_ID) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'youtube' , $user_ID); ?>" title="<?php echo $user_identity ?><?php _e( '  on YouTube', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_youtube.png" alt="" /></a>
    <?php endif ?>
    <?php if ( get_the_author_meta( 'pinterest' , $user_ID) ) : ?>
    <a class="ttip" href="<?php the_author_meta( 'pinterest' , $user_ID); ?>" title="<?php echo $user_identity ?><?php _e( '  on Pinterest', 'lioit' ); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icon_pinterest.png" alt="" /></a>
    <?php endif ?>
  </div>
  <div class="clear"></div>
</div>
<?php endif; ?>
<?php else: ?>
<div class="widgetContent">
<div id="login-form">
  <form action="<?php echo home_url() ?>/wp-login.php" method="post">
    <span id="log-username">
    <input type="text" name="log" id="log" value="" placeholder="<?php _e( 'Username' , 'lioit' ) ?>"  size="33" />
    </span> <span id="log-pass">
    <input type="password" name="pwd" id="pwd" value="" placeholder="<?php _e( 'Password' , 'lioit' ) ?>"  size="33" />
    </span>
    <button  type="submit" name="submit" class="login-button btnMainColor" />
    <?php _e( 'Log in' , 'lioit' ) ?>
    </button>
    <label for="rememberme">
      <input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" />
      <?php _e( 'Remember Me' , 'lioit' ) ?>
    </label>
    <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
  </form>
  <ul class="login-links">
    <li><a href="<?php echo home_url() ?>/wp-login.php?action=lostpassword">
      <?php _e( 'Lost your password?' , 'lioit' ) ?>
      </a></li>
    <?php if ( get_option('users_can_register') ) : ?>
    <li><a href="<?php echo home_url() ?>/wp-register.php">
      <?php _e( 'Register' , 'lioit' ) ?>
      </a></li>
    <?php endif; ?>
  </ul>
</div>
<?php endif;
}


?>