extensions.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. class foto_author_bio extends WP_Widget
  3. {
  4. function foto_author_bio()
  5. {
  6. $widget_ops = array('classname' => 'foto_author_bio', 'description' => 'Display your biographical info' );
  7. $this->WP_Widget('foto_author_bio', '&raquo; Foto Author Bio', $widget_ops);
  8. }
  9. function form($instance)
  10. {
  11. $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
  12. $title = $instance['title'];
  13. ?>
  14. <p><?php printf( __('Please complete your bio information on the <a href="%s">Profile Page</a> <em>(fill the nickname, twitter and Biographical Info)</em>', 'foto'), admin_url('profile.php') ); ?></p>
  15. <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'foto' ); ?></label>
  16. <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
  17. <?php
  18. }
  19. function update($new_instance, $old_instance)
  20. {
  21. $instance = $old_instance;
  22. $instance['title'] = $new_instance['title'];
  23. return $instance;
  24. }
  25. function widget($args, $instance)
  26. {
  27. extract($args, EXTR_SKIP);
  28. $title = apply_filters('widget_title', empty($instance['title']) ? __('Social', 'foto') : $instance['title'], $instance, $this->id_base);
  29. echo $before_widget;
  30. if (!empty($title))
  31. echo $before_title . $title . $after_title;
  32. ?>
  33. <div class="widget-author-info">
  34. <p class="author-desc"><?php the_author_meta( 'description' ); ?></p>
  35. <div class="author-detail">
  36. <span>
  37. <p class="author-name"><?php echo get_the_author(); ?></p>
  38. <p class="author-twitter">
  39. <a href="<?php echo the_author_meta( 'twitter' ) ?>" class="twitter-follow-button" data-show-count="false">Follow me</a>
  40. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  41. </p>
  42. </span>
  43. <figure class="author-img"><?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'foto_author_bio_avatar_size', 60 ) ); ?></figure>
  44. </div>
  45. </div>
  46. <?php
  47. echo $after_widget;
  48. }
  49. }
  50. ?>