Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'widgets_init','wdl_contact_widget');
- function wdl_contact_widget()
- {
- return register_widget( 'wdl_contact_widget' );
- }
- class wdl_contact_widget extends WP_Widget {
- function __construct() {
- parent::__construct(
- 'wdl_contact_widget', // Base ID
- __('WBR: Contact Widget', 'spasalon'), // Name
- array( 'description' => __('Contact Widget Section', 'spasalon' ), ) // Args
- );
- }
- public function widget( $args , $instance ) {
- echo $args['before_widget'];
- if($instance['title']){
- echo $args['before_title'] . $instance['title'] . $args['after_title'];
- }
- if($instance['phone']){
- echo '<em class="phone-info">'. $instance['phone'] .'</em>';
- }
- if($instance['email']){
- echo '<em class="mail-info">' . $instance['email'] . '</em>';
- }
- if($instance['address']){
- echo '<em class="address-info">' . $instance['address'] . '</em>';
- }
- echo '<ul class="social">';
- if($instance['facebook']){
- echo '<li class="facebook"><a title="Facebook" href="'.$instance['facebook'].'"><i class="fa fa-facebook"></i></a></li>';
- }
- if($instance['twitter']){
- echo '<li class="twitter"><a title="Twitter" href="'.$instance['twitter'].'"><i class="fa fa-twitter"></i></a></li>';
- }
- if($instance['linked']){
- echo '<li class="linkedin"><a title="Linked in" href="'.$instance['linked'].'"><i class="fa fa-linkedin"></i></a></li>';
- }
- if($instance['googleplus']){
- echo '<li class="googleplus"><a title="Google Plus" href="'.$instance['googleplus'].'"><i class="fa fa-google-plus"></i></a></li>';
- }
- if($instance['skype']){
- echo '<li class="skype"><a title="Skype" href="'.$instance['skype'].'"><i class="fa fa-skype"></i></a></li>';
- }
- if($instance['youtube']){
- echo '<li class="youtube"><a title="youtube" href="'.$instance['youtube'].'"><i class="fa fa-youtube"></i></a></li>';
- }
- echo '</ul>';
- echo $args['after_widget'];
- }
- public function form( $instance ) {
- $instance['title'] = ( isset($instance['title'] ) ? $instance['title'] : '' );
- $instance['phone'] = ( isset($instance['phone'] ) ? $instance['phone'] : '' );
- $instance['email'] = ( isset($instance['email'] ) ? $instance['email'] : '' );
- $instance['address'] = ( isset($instance['address'] ) ? $instance['address'] : '' );
- $instance['facebook'] = ( isset($instance['facebook'] ) ? $instance['facebook'] : '' );
- $instance['twitter'] = ( isset($instance['twitter'] ) ? $instance['twitter'] : '' );
- $instance['linked'] = ( isset($instance['linked'] ) ? $instance['linked'] : '' );
- $instance['googleplus'] = ( isset($instance['googleplus'] ) ? $instance['googleplus'] : '' );
- $instance['skype'] = ( isset($instance['skype'] ) ? $instance['skype'] : '' );
- $instance['youtube'] = ( isset($instance['youtube'] ) ? $instance['youtube'] : '' );
- ?>
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'phone' ); ?>"><?php _e( 'Phone','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'email' ); ?>"><?php _e( 'Email','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'address' ); ?>"><?php _e( 'Address','spasalon' ); ?></label>
- <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>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'facebook' ); ?>"><?php _e( 'Facebook URL','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'twitter' ); ?>"><?php _e( 'Twitter URL','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'linked' ); ?>"><?php _e( 'LinkedIn URL','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'googleplus' ); ?>"><?php _e( 'GooglePlus URL','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'skype' ); ?>"><?php _e( 'Skype URL','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'youtube' ); ?>"><?php _e( 'youtube URL','spasalon' ); ?></label>
- <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'] ); ?>" />
- </p>
- <?php
- }
- public function update( $new_instance, $old_instance ) {
- $instance = array();
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? $new_instance['title'] : '';
- $instance['phone'] = ( ! empty( $new_instance['phone'] ) ) ? $new_instance['phone'] : '';
- $instance['email'] = ( ! empty( $new_instance['email'] ) ) ? $new_instance['email'] : '';
- $instance['address'] = ( ! empty( $new_instance['address'] ) ) ? $new_instance['address'] : '';
- $instance['facebook'] = ( ! empty( $new_instance['facebook'] ) ) ? $new_instance['facebook'] : '';
- $instance['twitter'] = ( ! empty( $new_instance['twitter'] ) ) ? $new_instance['twitter'] : '';
- $instance['linked'] = ( ! empty( $new_instance['linked'] ) ) ? $new_instance['linked'] : '';
- $instance['googleplus'] = ( ! empty( $new_instance['googleplus'] ) ) ? $new_instance['googleplus'] : '';
- $instance['skype'] = ( ! empty( $new_instance['skype'] ) ) ? $new_instance['skype'] : '';
- $instance['youtube'] = ( ! empty( $new_instance['youtube'] ) ) ? $new_instance['youtube'] : '';
- return $instance;
- }
- } // class
Add Comment
Please, Sign In to add comment