Guest User

Untitled

a guest
Jan 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. <?php function sh_sb_widget_register_widgets() {
  2. register_widget( 'sh_sb_widget' );
  3. }
  4.  
  5. class sh_sb_widget extends WP_Widget {
  6.  
  7. function sh_sb_widget() {
  8. $widget_ops = array(
  9. 'classname' => 'sh_sb_widget_class',
  10. 'description' => 'Display your Social Bartender links.'
  11. );
  12. $this->WP_Widget( 'sh_sb_widget', 'Social Bartender', $widget_ops );
  13. }
  14.  
  15. function form($instance) {
  16. $defaults = array( 'title' => '', 'disable_styles' => 'false' );
  17. $instance = wp_parse_args( (array) $instance, $defaults );
  18. $title = $instance['title'];
  19. $disable_styles = $instance['disable_styles'];
  20.  
  21.  
  22. ?>
  23. <p><strong><?php _e( 'Set up Social Bartender', 'shaken' ); ?> <a href="/wp-admin/options-general.php?page=sh_sb_settings_page"><?php _e( 'here.', 'shaken' ); ?></a></strong></p>
  24.  
  25. <p>
  26. <?php _e( 'Title (optional):', 'shaken' ); ?>
  27. <input class="widefat" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
  28. </p>
  29.  
  30. <p>
  31. <input class="checkbox" type="checkbox" <?php checked( $instance['disable_styles'], 'on' ); ?> id="<?php echo $this->get_field_id( 'disable_styles' ); ?>" name="<?php echo $this->get_field_name( 'disable_styles' ); ?>" />
  32. <label for="<?php echo $this->get_field_id( 'disable_styles' ); ?>"><?php _e( 'Disable default styles', 'shaken' ); ?></label>
  33. </p>
  34. <?php
  35. }
  36.  
  37. function update($new_instance, $old_instance) {
  38. $instance = $old_instance;
  39. $instance['title'] = strip_tags( $new_instance['title'] );
  40. $instance['disable_styles'] = $new_instance['disable_styles'];
  41.  
  42. return $new_instance;
  43. }
  44.  
  45. function widget($args, $instance) {
  46. extract($args);
  47.  
  48. echo $before_widget;
  49.  
  50. $title = apply_filters( 'widget_title', $instance['title'] );
  51. $disable_styles = $instance['disable_styles'];
  52.  
  53. if ( !empty( $title ) ) {
  54. echo $before_title . $title . $after_title;
  55. };
  56.  
  57. if( !$disable_styles ) { ?>
  58.  
  59. <style>
  60. .sh-sb-link {
  61. padding: 0 5px;
  62. }
  63. </style>
  64.  
  65. <?php }
  66.  
  67. social_bartender();
  68.  
  69. echo $after_widget;
  70. }
  71. }
  72.  
  73. function sh_sb_widget_styles(){
  74. wp_enqueue_style( 'sh-sb-widget', SH_SB_DIR.'css/widget.css' );
  75. }
  76.  
  77. add_action( 'widgets_init', 'sh_sb_widget_register_widgets' ); ?>
Add Comment
Please, Sign In to add comment