Gglplsn_Badge_Widget

The Google +1 by BestWebSoft Gglplsn Badge Widget class.

Defined (1)

The class is defined in the following location(s).

/google-plus-one.php  
  1. class Gglplsn_Badge_Widget extends WP_Widget { 
  2. function __construct() { 
  3. parent::__construct( 'gglplsn_badge', __( 'Google+ Badge Widget', 'google-one' ), array( 'description' => __( 'Show Google Badge on your site', 'google-one' ) ) ); 
  4.  
  5. function widget( $args, $instance ) { 
  6. global $gglplsn_options, $gglplsn_is_button_shown; 
  7.  
  8. if ( ! isset( $instance['badge_layout'] ) ) { 
  9. $instance['badge_layout'] = $gglplsn_options['badge_layout']; 
  10.  
  11. if ( ! isset( $instance['badge_show_cover'] ) ) { 
  12. $instance['badge_show_cover'] = $gglplsn_options['badge_show_cover']; 
  13. $instance['badge_id'] = ! empty( $instance['badge_id'] ) ? esc_html( $instance['badge_id'] ) : esc_html( $gglplsn_options['badge_id'] ); 
  14. $instance['badge_type'] = ! empty( $instance['badge_type'] ) ? esc_html( $instance['badge_type'] ) : esc_html( $gglplsn_options['badge_type'] ); 
  15. $instance['badge_show_tagline'] = ! empty( $instance['badge_show_tagline'] ) ? true : false; 
  16. $instance['badge_show_owners'] = ! empty( $instance['badge_show_owners'] ) ? true : false; 
  17. $instance['badge_theme'] = ! empty( $instance['badge_theme'] ) ? esc_html( $instance['badge_theme'] ) : esc_html( $gglplsn_options['badge_theme'] ); 
  18. $instance['badge_width'] = ! empty( $instance['badge_width'] ) ? intval( $instance['badge_width'] ) : intval( $gglplsn_options['badge_width'] ); 
  19. $title = ( ! empty( $instance['title'] ) ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : ''; 
  20. echo $args['before_widget']; 
  21. if ( ! empty( $title ) ) { 
  22. echo $args['before_title'] . $title . $args['after_title']; 
  23. $badge = gglplsn_return_button( 'badge', $instance ); 
  24. echo $badge; 
  25. echo $args['after_widget']; 
  26. $gglplsn_is_button_shown = true; 
  27.  
  28. function update( $new_instance, $old_instance ) { 
  29. $instance = $old_instance; 
  30. $instance['title'] = strip_tags( $new_instance['title'] ); 
  31. $instance['badge_id'] = esc_html( $new_instance['badge_id'] ); 
  32. $instance['badge_type'] = $new_instance['badge_type']; 
  33. $instance['badge_layout'] = $new_instance['badge_layout']; 
  34. $instance['badge_show_cover'] = isset( $new_instance['badge_show_cover'] ) ? true : false; 
  35. $instance['badge_show_tagline'] = isset( $new_instance['badge_show_tagline'] ) ? true : false; 
  36. $instance['badge_show_owners'] = isset( $new_instance['badge_show_owners'] ) ? true : false; 
  37. $instance['badge_width'] = isset( $new_instance['badge_width'] ) ? intval( $new_instance['badge_width'] ) : 270; 
  38. return $instance; 
  39.  
  40. function form( $instance ) { 
  41. global $gglplsn_options; 
  42. if ( empty( $gglplsn_options ) ) { 
  43. $gglplsn_options = get_option( 'gglplsn_options' ); 
  44.  
  45. if ( ! empty( $instance ) ) { 
  46. $title = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; 
  47. $badge_id = ! empty( $instance['badge_id'] ) ? esc_html( $instance['badge_id'] ) : ''; 
  48. $badge_type = ! empty( $instance['badge_type'] ) ? esc_html( $instance['badge_type'] ) : ''; 
  49. $badge_layout = ! empty( $instance['badge_layout'] ) ? $instance['badge_layout'] : 'portrait'; 
  50. $badge_show_cover = ! empty( $instance['badge_show_cover'] ) ? true : false; 
  51. $badge_show_tagline = ! empty( $instance['badge_show_tagline'] ) ? true : false; 
  52. $badge_show_owners = ( ! empty( $instance['badge_show_owners'] ) && 'community' == $badge_type ) ? true : false; 
  53. $badge_width = ! empty( $instance['badge_width'] ) ? intval( $instance['badge_width'] ) : 180; 
  54. } else { 
  55. $title = ''; 
  56. $badge_id = ! empty( $gglplsn_options['badge_id'] ) ? esc_html( $gglplsn_options['badge_id'] ) : ''; 
  57. $badge_type = ! empty( $gglplsn_options['badge_type'] ) ? esc_html( $gglplsn_options['badge_type'] ) : ''; 
  58. $badge_layout = ! empty( $gglplsn_options['badge_layout'] ) ? $gglplsn_options['badge_layout'] : 'portrait'; 
  59. $badge_show_cover = ! empty( $gglplsn_options['badge_show_cover'] ) ? true : false; 
  60. $badge_show_tagline = ! empty( $gglplsn_options['badge_show_tagline'] ) ? true : false; 
  61. $badge_show_owners = ( ! empty( $gglplsn_options['badge_show_owners'] ) && 'community' == $badge_type ) ? true : false; 
  62. $badge_width = ! empty( $gglplsn_options['badge_width'] ) ? intval( $gglplsn_options['badge_width'] ) : 180; 
  63. } ?> 
  64.  
  65. <p> 
  66. <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'google-one' ); ?>:</label> 
  67. <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /> 
  68. </p> 
  69. <p> 
  70. <label for="<?php echo $this->get_field_id( 'badge_id' ); ?>"><?php _e( 'Google+ ID', 'google-one' ); ?>:</label> 
  71. <input type="text" class="widefat" name="<?php echo $this->get_field_name( 'badge_id' ); ?>" <?php echo 'required="required"'; ?> value="<?php echo $badge_id; ?>" /> 
  72. <span class="bws_info gglplsn-badge-id-info">(<?php echo __( 'Enter the Google+ ID, e.g.', 'google-one' ) . ' "12345678912345678912" '; ?>)</span> 
  73. </p> 
  74. <p> 
  75. <label for="<?php echo $this->get_field_id( 'badge_type' ); ?>"><?php _e( 'Type', 'google-one' ); ?></label> 
  76. <select id="<?php echo $this->get_field_id( 'badge_type' ); ?>" class="gglplsn-badge-type" name="<?php echo $this->get_field_name( 'badge_type' ); ?>"> 
  77. <option value="person" <?php if ( 'person' == $badge_type ) echo 'selected="selected"'; ?>><?php _e( 'Person', 'google-one' ); ?></option> 
  78. <option value="page" <?php if ('page' == $badge_type ) echo 'selected="selected"'; ?>><?php _e( 'Page', 'google-one' ); ?></option> 
  79. <option value="community" <?php if ( 'community' == $badge_type ) echo 'selected="selected"'; ?>><?php _e( 'Community', 'google-one' ); ?></option> 
  80. </select> 
  81. </p> 
  82. <p> 
  83. <label for="<?php echo $this->get_field_id( 'badge_layout' ); ?>"><?php _e( 'Layout', 'google-one' ); ?></label> 
  84. <select id="<?php echo $this->get_field_id( 'badge_layout' ); ?>" name="<?php echo $this->get_field_name( 'badge_layout' ); ?>"> 
  85. <option value="portrait" <?php if ( 'portrait' == $badge_layout ) echo 'selected="selected"';?>><?php _e( 'Portrait', 'google-one' ); ?></option> 
  86. <option value="landscape" <?php if ( 'landscape' == $badge_layout ) echo 'selected="selected"';?>><?php _e( 'Landscape', 'google-one' ); ?></option> 
  87. </select> 
  88. </p> 
  89. <p> 
  90. <input class="widefat" id="<?php echo $this->get_field_id( 'badge_show_cover' ); ?>" name="<?php echo $this->get_field_name( 'badge_show_cover' ); ?>" type="checkbox" <?php if ( true == $badge_show_cover ) echo 'checked="checked"'; ?> value="1" /> 
  91. <label for="<?php echo $this->get_field_id( 'badge_show_cover' ); ?>"><?php _e( 'Show Cover Photo', 'google-one' ); ?></label> 
  92. </p> 
  93. <p> 
  94. <input class="widefat" id="<?php echo $this->get_field_id( 'badge_show_tagline' ); ?>" name="<?php echo $this->get_field_name( 'badge_show_tagline' ); ?>" type="checkbox" <?php if ( true == $badge_show_tagline ) echo 'checked="checked"'; ?> value="1" /> 
  95. <label for="<?php echo $this->get_field_id( 'badge_show_tagline' ); ?>"><?php _e( 'Show Tag Line', 'google-one' ); ?></label> 
  96. </p> 
  97.  
  98. <p <?php echo ( 'community' != $badge_type ) ? 'class="gglplsn-show-owners hidden"' : 'class="gglplsn-show-owners"'; ?>> 
  99. <input class="widefat" id="<?php echo $this->get_field_id( 'badge_show_owners' ); ?>" name="<?php echo $this->get_field_name( 'badge_show_owners' ); ?>" type="checkbox"<?php if ( true == $badge_show_owners ) echo ' checked="checked"'; echo ( 'community' != $badge_type ) ? ' disabled="disabled"': ''; ?> value="1" /> 
  100. <label for="<?php echo $this->get_field_id( 'badge_show_owners' ); ?>"><?php _e( 'Show Owners', 'google-one' ); ?></label> 
  101. </p> 
  102. <p> 
  103. <label for="<?php echo $this->get_field_id( 'badge_width' ); ?>"><?php _e( 'Width', 'google-one' ); ?></label> 
  104. <input type="number" id="<?php echo $this->get_field_id( 'badge_width' ); ?>" name="<?php echo $this->get_field_name( 'badge_width' ); ?>" max="450" <?php echo ( 'portrait' == $badge_layout ) ? 'min="180"' : 'min="273"'; ?> value="<?php echo $badge_width; ?>" /> 
  105. <?php _e( 'px', 'google-one' ); ?> 
  106. </p> 
  107. <?php }