RtThemesSupport

rt15 contact-info-widget-3phone

Nov 7th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.45 KB | None | 0 0
  1. <?php
  2. #
  3. # RT-Theme Contact Info
  4. #
  5.  
  6. class Contact_Info extends WP_Widget {
  7.  
  8.     function Contact_Info() {
  9.         $opts =array(
  10.                     'classname'     => 'widget_contact_info',
  11.                     'description'   => __( 'Use this widget to display your contact details with icons.', 'rt_theme_admin' )
  12.                 );
  13.  
  14.         $this-> WP_Widget('contact_info', '['. THEMENAME.']   '.__('Contact Info', 'rt_theme_admin'), $opts);
  15.     }
  16.    
  17.  
  18.     function widget( $args, $instance ) {
  19.         extract( $args );
  20.        
  21.         $title          =   apply_filters('widget_title', $instance['title']) ;      
  22.         $address            =   isset($instance['address'])  ? wpml_t( THEMESLUG , 'Address', $instance['address'] ) : "";
  23.         $phone_1            =   isset($instance['phone_1'])  ? wpml_t( THEMESLUG , 'Phone 1', $instance['phone_1'] ): "";  
  24.         $phone_2            =   isset($instance['phone_2'])  ?  wpml_t( THEMESLUG , 'Phone 2', $instance['phone_2'] ): "";
  25.         $phone_3            =   isset($instance['phone_2'])  ?  wpml_t( THEMESLUG , 'Phone 3', $instance['phone_3'] ): "";     
  26.         $fax_1          =   isset($instance['fax_1'])  ? wpml_t( THEMESLUG , 'Fax 1', $instance['fax_1'] ) : "";
  27.         $fax_2          =   isset($instance['fax_2'])  ? wpml_t( THEMESLUG , 'Fax 2', $instance['fax_2'] ) : "";
  28.         $mail_1         =   isset($instance['mail_1'])  ? wpml_t( THEMESLUG , 'Email 1', $instance['mail_1'] ): "";
  29.         $mail_2         =   isset($instance['mail_2'])  ? wpml_t( THEMESLUG , 'Email 2', $instance['mail_2'] ): "";
  30.         $support_mail_1 =   isset($instance['support_mail_1'])  ? wpml_t( THEMESLUG , 'Support Email 1', $instance['support_mail_1'] ): "";
  31.         $support_mail_2 =   isset($instance['support_mail_2'])  ? wpml_t( THEMESLUG , 'Support Email 2', $instance['support_mail_2'] ): "";
  32.         $map_link           =   isset($instance['map_link'])  ? wpml_t( THEMESLUG , 'Map Link', $instance['map_link'] ): "";
  33.         $contact_form_link  =   isset($instance['contact_form_link'])  ? wpml_t( THEMESLUG , 'Contact Form Link', $instance['contact_form_link'] ): "";
  34.         $map_link_text          =   isset($instance['map_link_text'])  ? wpml_t( THEMESLUG , 'Map Link Text', $instance['map_link_text'] ): "";
  35.         $contact_form_link_text =   isset($instance['contact_form_link_text'])  ? wpml_t( THEMESLUG , 'Contact Form Link Text', $instance['contact_form_link_text'] ): "";
  36.  
  37.  
  38.  
  39.         //Contact Info
  40.         $contactInfo = '<ul class="contact_list">';
  41.        
  42.         if(!empty($address))            $contactInfo .= '<li class="home">'.$address.'</li>';
  43.         if(!empty($phone_1))            $contactInfo .= '<li class="phone">'.$phone_1.'</li>';
  44.         if(!empty($phone_2))            $contactInfo .= '<li class="phone">'.$phone_2.'</li>';
  45.         if(!empty($phone_3))            $contactInfo .= '<li class="phone">'.$phone_3.'</li>';     
  46.         if(!empty($fax_1))              $contactInfo .= '<li class="fax">'.$fax_1.'</li>';
  47.         if(!empty($fax_2))              $contactInfo .= '<li class="fax">'.$fax_2.'</li>';     
  48.         if(!empty($mail_1))             $contactInfo .= '<li class="mail"><a href="mailto:'.$mail_1.'">'.$mail_1.'</a></li>';
  49.         if(!empty($mail_2))             $contactInfo .= '<li class="mail"><a href="mailto:'.$mail_2.'">'.$mail_2.'</a></li>';
  50.         if(!empty($support_mail_1))         $contactInfo .= '<li class="help"><a href="mailto:'.$support_mail_1.'">'.$support_mail_1.'</a></li>';
  51.         if(!empty($support_mail_2))         $contactInfo .= '<li class="help"><a href="mailto:'.$support_mail_2.'">'.$support_mail_2.'</a></li>';
  52.         if(!empty($map_link))           $contactInfo .= '<li class="map"><a href="'.$map_link.'" title="'.$map_link_text.'">'.$map_link_text.'</a></li>';
  53.         if(!empty($contact_form_link))  $contactInfo .= '<li class="contact_form_icon"><a href="'.$contact_form_link.'" title="'.$contact_form_link_text.'">'.$contact_form_link_text.'</a></li>';
  54.        
  55.         $contactInfo .= '</ul>';
  56.          
  57.  
  58.         echo $before_widget;
  59.         if ($title) echo $before_title . $title . $after_title;
  60.         echo $contactInfo;
  61.         echo $after_widget;
  62.     }
  63.  
  64.     function update( $new_instance, $old_instance ) {
  65.          
  66.         $instance = $old_instance;
  67.         $instance['title']                  = strip_tags($new_instance['title']);  
  68.         $instance['address']                = ($new_instance['address']);  
  69.         $instance['phone_1']                = strip_tags($new_instance['phone_1']);
  70.         $instance['phone_2']                = strip_tags($new_instance['phone_2']);
  71.         $instance['phone_3']                = strip_tags($new_instance['phone_3']);    
  72.         $instance['fax_1']                  = strip_tags($new_instance['fax_1']);
  73.         $instance['fax_2']                  = strip_tags($new_instance['fax_2']);      
  74.         $instance['mail_1']                 = strip_tags($new_instance['mail_1']);
  75.         $instance['mail_2']                 = strip_tags($new_instance['mail_2']);
  76.         $instance['support_mail_1']         = strip_tags($new_instance['support_mail_1']);
  77.         $instance['support_mail_2']         = strip_tags($new_instance['support_mail_2']);
  78.         $instance['contact_form_link']      = strip_tags($new_instance['contact_form_link']);
  79.         $instance['map_link']               = strip_tags($new_instance['map_link']);       
  80.         $instance['contact_form_link_text'] = strip_tags($new_instance['contact_form_link_text']);
  81.         $instance['map_link_text']          = strip_tags($new_instance['map_link_text']);
  82.        
  83.         wpml_register_string( THEMESLUG , 'Address', strip_tags($new_instance['address']) ) ;
  84.         wpml_register_string( THEMESLUG , 'Phone 1', strip_tags($new_instance['phone_1']) ) ;
  85.         wpml_register_string( THEMESLUG , 'Phone 2', strip_tags($new_instance['phone_2']) ) ;
  86.         wpml_register_string( THEMESLUG , 'Phone 3', strip_tags($new_instance['phone_3']) ) ;      
  87.         wpml_register_string( THEMESLUG , 'Fax 1', strip_tags($new_instance['fax_1']) ) ;
  88.         wpml_register_string( THEMESLUG , 'Fax 2', strip_tags($new_instance['fax_2']) ) ;      
  89.         wpml_register_string( THEMESLUG , 'Email 1', strip_tags($new_instance['mail_1']) ) ;
  90.         wpml_register_string( THEMESLUG , 'Email 2', strip_tags($new_instance['mail_2']) ) ;
  91.         wpml_register_string( THEMESLUG , 'Support Email 1', strip_tags($new_instance['support_mail_1']) ) ;
  92.         wpml_register_string( THEMESLUG , 'Support Email 2', strip_tags($new_instance['support_mail_2']) ) ;
  93.         wpml_register_string( THEMESLUG , 'Map Link', strip_tags($new_instance['map_link']) ) ;
  94.         wpml_register_string( THEMESLUG , 'Contact Form Link', strip_tags($new_instance['contact_form_link']) ) ;              
  95.         wpml_register_string( THEMESLUG , 'Map Link Text', strip_tags($new_instance['map_link_text']) ) ;
  96.         wpml_register_string( THEMESLUG , 'Contact Form Link Text', strip_tags($new_instance['contact_form_link_text']) ) ;
  97.        
  98.         return $instance;
  99.     }
  100.  
  101.     function form( $instance ) {
  102.         $title              =   isset($instance['title']) ? esc_attr($instance['title']) : '';
  103.         $address                =   isset($instance['address']) ? esc_attr($instance['address']) : '';
  104.         $phone_1                =   isset($instance['phone_1']) ? esc_attr($instance['phone_1']) : '';
  105.         $phone_2                =   isset($instance['phone_2']) ? esc_attr($instance['phone_2']) : '';
  106.         $phone_3                =   isset($instance['phone_2']) ? esc_attr($instance['phone_3']) : '';     
  107.         $fax_1              =   isset($instance['fax_1']) ? esc_attr($instance['fax_1']) : '';
  108.         $fax_2              =   isset($instance['fax_2']) ? esc_attr($instance['fax_2']) : '';     
  109.         $mail_1                 =   isset($instance['mail_1']) ? esc_attr($instance['mail_1']) : '';
  110.         $mail_2                 =   isset($instance['mail_2']) ? esc_attr($instance['mail_2']) : '';
  111.         $support_mail_1         =   isset($instance['support_mail_1']) ? esc_attr($instance['support_mail_1']) : '';
  112.         $support_mail_2         =   isset($instance['support_mail_2']) ? esc_attr($instance['support_mail_2']) : '';
  113.         $map_link               =   isset($instance['map_link']) ? esc_attr($instance['map_link']) : '';
  114.         $contact_form_link      =   isset($instance['contact_form_link']) ? esc_attr($instance['contact_form_link']) : '';
  115.         $map_link_text          =   isset($instance['map_link_text']) ? esc_attr($instance['map_link_text']) : '';
  116.         $contact_form_link_text     =   isset($instance['contact_form_link_text']) ? esc_attr($instance['contact_form_link_text']) : '';
  117.        
  118.         // Categories
  119.         $rt_getcat = RTTheme::rt_get_categories();
  120.        
  121.  
  122. ?>
  123.         <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'rt_theme_admin'); ?></label>
  124.         <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo empty($title) ? __('Contact Details','rt_theme_admin') : $title; ?>" /></p>
  125.  
  126.         <p><label for="<?php echo $this->get_field_id('address'); ?>"><?php _e('Address:', 'rt_theme_admin'); ?></label>
  127.         <input class="widefat" id="<?php echo $this->get_field_id('address'); ?>" name="<?php echo $this->get_field_name('address'); ?>" type="text" value="<?php echo $address; ?>" /></p>
  128.  
  129.         <p><label for="<?php echo $this->get_field_id('phone_1'); ?>"><?php _e('Phone 1:', 'rt_theme_admin'); ?></label>
  130.         <input class="widefat" id="<?php echo $this->get_field_id('phone_1'); ?>" name="<?php echo $this->get_field_name('phone_1'); ?>" type="text" value="<?php echo $phone_1; ?>" /></p>
  131.  
  132.         <p><label for="<?php echo $this->get_field_id('phone_2'); ?>"><?php _e('Phone 2:', 'rt_theme_admin'); ?></label>
  133.         <input class="widefat" id="<?php echo $this->get_field_id('phone_2'); ?>" name="<?php echo $this->get_field_name('phone_2'); ?>" type="text" value="<?php echo $phone_2; ?>" /></p>
  134.  
  135.         <p><label for="<?php echo $this->get_field_id('phone_3'); ?>"><?php _e('Phone 3:', 'rt_theme_admin'); ?></label>
  136.         <input class="widefat" id="<?php echo $this->get_field_id('phone_3'); ?>" name="<?php echo $this->get_field_name('phone_3'); ?>" type="text" value="<?php echo $phone_3; ?>" /></p>
  137.  
  138.         <p><label for="<?php echo $this->get_field_id('fax_1'); ?>"><?php _e('Fax 1:', 'rt_theme_admin'); ?></label>
  139.         <input class="widefat" id="<?php echo $this->get_field_id('fax_1'); ?>" name="<?php echo $this->get_field_name('fax_1'); ?>" type="text" value="<?php echo $fax_1; ?>" /></p>
  140.  
  141.         <p><label for="<?php echo $this->get_field_id('fax_2'); ?>"><?php _e('Fax 2:', 'rt_theme_admin'); ?></label>
  142.         <input class="widefat" id="<?php echo $this->get_field_id('fax_2'); ?>" name="<?php echo $this->get_field_name('fax_2'); ?>" type="text" value="<?php echo $fax_2; ?>" /></p>
  143.  
  144.         <p><label for="<?php echo $this->get_field_id('mail_1'); ?>"><?php _e('Email 1:', 'rt_theme_admin'); ?></label>
  145.         <input class="widefat" id="<?php echo $this->get_field_id('mail_1'); ?>" name="<?php echo $this->get_field_name('mail_1'); ?>" type="text" value="<?php echo $mail_1; ?>" /></p>       
  146.  
  147.         <p><label for="<?php echo $this->get_field_id('mail_2'); ?>"><?php _e('Email 2:', 'rt_theme_admin'); ?></label>
  148.         <input class="widefat" id="<?php echo $this->get_field_id('mail_2'); ?>" name="<?php echo $this->get_field_name('mail_2'); ?>" type="text" value="<?php echo $mail_2; ?>" /></p>       
  149.  
  150.         <p><label for="<?php echo $this->get_field_id('support_mail_1'); ?>"><?php _e('Support Email 1:', 'rt_theme_admin'); ?></label>
  151.         <input class="widefat" id="<?php echo $this->get_field_id('support_mail_1'); ?>" name="<?php echo $this->get_field_name('support_mail_1'); ?>" type="text" value="<?php echo $support_mail_1; ?>" /></p>       
  152.    
  153.         <p><label for="<?php echo $this->get_field_id('support_mail_2'); ?>"><?php _e('Support Email 2:', 'rt_theme_admin'); ?></label>
  154.         <input class="widefat" id="<?php echo $this->get_field_id('support_mail_2'); ?>" name="<?php echo $this->get_field_name('support_mail_2'); ?>" type="text" value="<?php echo $support_mail_2; ?>" /></p>
  155.    
  156.         <p><label for="<?php echo $this->get_field_id('contact_form_link'); ?>"><?php _e('Contact Form Link:', 'rt_theme_admin'); ?></label>
  157.         <input class="widefat" id="<?php echo $this->get_field_id('contact_form_link'); ?>" name="<?php echo $this->get_field_name('contact_form_link'); ?>" type="text" value="<?php echo $contact_form_link; ?>" /></p>              
  158.  
  159.         <p><label for="<?php echo $this->get_field_id('contact_form_link_text'); ?>"><?php _e('Contact Form Link Text:', 'rt_theme_admin'); ?></label>
  160.         <input class="widefat" id="<?php echo $this->get_field_id('contact_form_link_text'); ?>" name="<?php echo $this->get_field_name('contact_form_link_text'); ?>" type="text" value="<?php echo empty($contact_form_link_text) ? __('Contact Form','rt_theme_admin') : $contact_form_link_text; ?>" /></p>            
  161.        
  162.         <p><label for="<?php echo $this->get_field_id('map_link'); ?>"><?php _e('Map Link:', 'rt_theme_admin'); ?></label>
  163.         <input class="widefat" id="<?php echo $this->get_field_id('map_link'); ?>" name="<?php echo $this->get_field_name('map_link'); ?>" type="text" value="<?php echo $map_link; ?>" /></p>
  164.  
  165.         <p><label for="<?php echo $this->get_field_id('map_link_text'); ?>"><?php _e('Map Link Text:', 'rt_theme_admin'); ?></label>
  166.         <input class="widefat" id="<?php echo $this->get_field_id('map_link_text'); ?>" name="<?php echo $this->get_field_name('map_link_text'); ?>" type="text" value="<?php echo empty($map_link_text) ? __('Find us on map','rt_theme_admin') : $map_link_text; ?>" /></p>                              
  167. <?php } } ?>
Advertisement
Add Comment
Please, Sign In to add comment