Guest User

Untitled

a guest
Oct 8th, 2019
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.22 KB | None | 0 0
  1. <?php
  2. add_action( 'widgets_init','wdl_contact_widget');
  3. function wdl_contact_widget()
  4. {
  5. return register_widget( 'wdl_contact_widget' );
  6. }
  7.  
  8. class wdl_contact_widget extends WP_Widget {
  9.  
  10. function __construct() {
  11. parent::__construct(
  12. 'wdl_contact_widget', // Base ID
  13. __('WBR: Contact Widget', 'spasalon'), // Name
  14. array( 'description' => __('Contact Widget Section', 'spasalon' ), ) // Args
  15. );
  16. }
  17.  
  18. public function widget( $args , $instance ) {
  19.  
  20. echo $args['before_widget'];
  21.  
  22. if($instance['title']){
  23. echo $args['before_title'] . $instance['title'] . $args['after_title'];
  24. }
  25.  
  26. if($instance['phone']){
  27. echo '<em class="phone-info">'. $instance['phone'] .'</em>';
  28. }
  29.  
  30. if($instance['email']){
  31. echo '<em class="mail-info">' . $instance['email'] . '</em>';
  32. }
  33.  
  34. if($instance['address']){
  35. echo '<em class="address-info">' . $instance['address'] . '</em>';
  36. }
  37.  
  38. echo '<ul class="social">';
  39. if($instance['facebook']){
  40. echo '<li class="facebook"><a title="Facebook" href="'.$instance['facebook'].'"><i class="fa fa-facebook"></i></a></li>';
  41. }
  42. if($instance['twitter']){
  43. echo '<li class="twitter"><a title="Twitter" href="'.$instance['twitter'].'"><i class="fa fa-twitter"></i></a></li>';
  44. }
  45. if($instance['linked']){
  46. echo '<li class="linkedin"><a title="Linked in" href="'.$instance['linked'].'"><i class="fa fa-linkedin"></i></a></li>';
  47. }
  48. if($instance['googleplus']){
  49. echo '<li class="googleplus"><a title="Google Plus" href="'.$instance['googleplus'].'"><i class="fa fa-google-plus"></i></a></li>';
  50. }
  51. if($instance['skype']){
  52. echo '<li class="skype"><a title="Skype" href="'.$instance['skype'].'"><i class="fa fa-skype"></i></a></li>';
  53. }
  54. if($instance['youtube']){
  55. echo '<li class="youtube"><a title="youtube" href="'.$instance['youtube'].'"><i class="fa fa-youtube"></i></a></li>';
  56. }
  57. echo '</ul>';
  58.  
  59. echo $args['after_widget'];
  60. }
  61.  
  62. public function form( $instance ) {
  63.  
  64. $instance['title'] = ( isset($instance['title'] ) ? $instance['title'] : '' );
  65. $instance['phone'] = ( isset($instance['phone'] ) ? $instance['phone'] : '' );
  66. $instance['email'] = ( isset($instance['email'] ) ? $instance['email'] : '' );
  67. $instance['address'] = ( isset($instance['address'] ) ? $instance['address'] : '' );
  68.  
  69. $instance['facebook'] = ( isset($instance['facebook'] ) ? $instance['facebook'] : '' );
  70. $instance['twitter'] = ( isset($instance['twitter'] ) ? $instance['twitter'] : '' );
  71. $instance['linked'] = ( isset($instance['linked'] ) ? $instance['linked'] : '' );
  72. $instance['googleplus'] = ( isset($instance['googleplus'] ) ? $instance['googleplus'] : '' );
  73. $instance['skype'] = ( isset($instance['skype'] ) ? $instance['skype'] : '' );
  74. $instance['youtube'] = ( isset($instance['youtube'] ) ? $instance['youtube'] : '' );
  75. ?>
  76.  
  77. <p>
  78. <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title','spasalon' ); ?></label>
  79. <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
  80. </p>
  81.  
  82. <p>
  83. <label for="<?php echo $this->get_field_id( 'phone' ); ?>"><?php _e( 'Phone','spasalon' ); ?></label>
  84. <input class="widefat" id="<?php echo $this->get_field_id( 'phone' ); ?>" name="<?php echo $this->get_field_name( 'phone' ); ?>" type="text" value="<?php echo esc_attr( $instance['phone'] ); ?>" />
  85. </p>
  86.  
  87. <p>
  88. <label for="<?php echo $this->get_field_id( 'email' ); ?>"><?php _e( 'Email','spasalon' ); ?></label>
  89. <input class="widefat" id="<?php echo $this->get_field_id( 'email' ); ?>" name="<?php echo $this->get_field_name( 'email' ); ?>" type="text" value="<?php echo esc_attr( $instance['email'] ); ?>" />
  90. </p>
  91.  
  92. <p>
  93. <label for="<?php echo $this->get_field_id( 'address' ); ?>"><?php _e( 'Address','spasalon' ); ?></label>
  94. <textarea class="widefat" id="<?php echo $this->get_field_id( 'address' ); ?>" name="<?php echo $this->get_field_name( 'address' ); ?>" ><?php echo esc_attr( $instance['address'] ); ?></textarea>
  95. </p>
  96.  
  97. <p>
  98. <label for="<?php echo $this->get_field_id( 'facebook' ); ?>"><?php _e( 'Facebook URL','spasalon' ); ?></label>
  99. <input class="widefat" id="<?php echo $this->get_field_id( 'facebook' ); ?>" name="<?php echo $this->get_field_name( 'facebook' ); ?>" type="text" value="<?php echo esc_attr( $instance['facebook'] ); ?>" />
  100. </p>
  101.  
  102. <p>
  103. <label for="<?php echo $this->get_field_id( 'twitter' ); ?>"><?php _e( 'Twitter URL','spasalon' ); ?></label>
  104. <input class="widefat" id="<?php echo $this->get_field_id( 'twitter' ); ?>" name="<?php echo $this->get_field_name( 'twitter' ); ?>" type="text" value="<?php echo esc_attr( $instance['twitter'] ); ?>" />
  105. </p>
  106.  
  107. <p>
  108. <label for="<?php echo $this->get_field_id( 'linked' ); ?>"><?php _e( 'LinkedIn URL','spasalon' ); ?></label>
  109. <input class="widefat" id="<?php echo $this->get_field_id( 'linked' ); ?>" name="<?php echo $this->get_field_name( 'linked' ); ?>" type="text" value="<?php echo esc_attr( $instance['linked'] ); ?>" />
  110. </p>
  111.  
  112. <p>
  113. <label for="<?php echo $this->get_field_id( 'googleplus' ); ?>"><?php _e( 'GooglePlus URL','spasalon' ); ?></label>
  114. <input class="widefat" id="<?php echo $this->get_field_id( 'googleplus' ); ?>" name="<?php echo $this->get_field_name( 'googleplus' ); ?>" type="text" value="<?php echo esc_attr( $instance['googleplus'] ); ?>" />
  115. </p>
  116.  
  117. <p>
  118. <label for="<?php echo $this->get_field_id( 'skype' ); ?>"><?php _e( 'Skype URL','spasalon' ); ?></label>
  119. <input class="widefat" id="<?php echo $this->get_field_id( 'skype' ); ?>" name="<?php echo $this->get_field_name( 'skype' ); ?>" type="text" value="<?php echo esc_attr( $instance['skype'] ); ?>" />
  120. </p>
  121.  
  122. <p>
  123. <label for="<?php echo $this->get_field_id( 'youtube' ); ?>"><?php _e( 'youtube URL','spasalon' ); ?></label>
  124. <input class="widefat" id="<?php echo $this->get_field_id( 'youtube' ); ?>" name="<?php echo $this->get_field_name( 'youtube' ); ?>" type="text" value="<?php echo esc_attr( $instance['youtube'] ); ?>" />
  125. </p>
  126.  
  127. <?php
  128. }
  129.  
  130. public function update( $new_instance, $old_instance ) {
  131.  
  132. $instance = array();
  133. $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? $new_instance['title'] : '';
  134. $instance['phone'] = ( ! empty( $new_instance['phone'] ) ) ? $new_instance['phone'] : '';
  135. $instance['email'] = ( ! empty( $new_instance['email'] ) ) ? $new_instance['email'] : '';
  136. $instance['address'] = ( ! empty( $new_instance['address'] ) ) ? $new_instance['address'] : '';
  137.  
  138. $instance['facebook'] = ( ! empty( $new_instance['facebook'] ) ) ? $new_instance['facebook'] : '';
  139. $instance['twitter'] = ( ! empty( $new_instance['twitter'] ) ) ? $new_instance['twitter'] : '';
  140. $instance['linked'] = ( ! empty( $new_instance['linked'] ) ) ? $new_instance['linked'] : '';
  141. $instance['googleplus'] = ( ! empty( $new_instance['googleplus'] ) ) ? $new_instance['googleplus'] : '';
  142. $instance['skype'] = ( ! empty( $new_instance['skype'] ) ) ? $new_instance['skype'] : '';
  143. $instance['youtube'] = ( ! empty( $new_instance['youtube'] ) ) ? $new_instance['youtube'] : '';
  144.  
  145. return $instance;
  146. }
  147.  
  148. } // class
Add Comment
Please, Sign In to add comment