Advertisement
Guest User

contact_info.php

a guest
Oct 30th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.68 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. $fax_1 = isset($instance['fax_1']) ? wpml_t( THEMESLUG , 'Fax 1', $instance['fax_1'] ) : "";
  26. $fax_2 = isset($instance['fax_2']) ? wpml_t( THEMESLUG , 'Fax 2', $instance['fax_2'] ) : "";
  27. $mail_1 = isset($instance['mail_1']) ? wpml_t( THEMESLUG , 'Email 1', $instance['mail_1'] ): "";
  28. $mail_2 = isset($instance['mail_2']) ? wpml_t( THEMESLUG , 'Email 2', $instance['mail_2'] ): "";
  29. $support_mail_1 = isset($instance['support_mail_1']) ? wpml_t( THEMESLUG , 'Support Email 1', $instance['support_mail_1'] ): "";
  30. $support_mail_2 = isset($instance['support_mail_2']) ? wpml_t( THEMESLUG , 'Support Email 2', $instance['support_mail_2'] ): "";
  31. $map_link = isset($instance['map_link']) ? wpml_t( THEMESLUG , 'Map Link', $instance['map_link'] ): "";
  32. $contact_form_link = isset($instance['contact_form_link']) ? wpml_t( THEMESLUG , 'Contact Form Link', $instance['contact_form_link'] ): "";
  33. $map_link_text = isset($instance['map_link_text']) ? wpml_t( THEMESLUG , 'Map Link Text', $instance['map_link_text'] ): "";
  34. $contact_form_link_text = isset($instance['contact_form_link_text']) ? wpml_t( THEMESLUG , 'Contact Form Link Text', $instance['contact_form_link_text'] ): "";
  35.  
  36.  
  37.  
  38. //Contact Info
  39. $contactInfo = '<ul class="contact_list">';
  40.  
  41. if(!empty($address)) $contactInfo .= '<li class="home">'.$address.'</li>';
  42. if(!empty($phone_1)) $contactInfo .= '<li class="phone">'.$phone_1.'</li>';
  43. if(!empty($phone_2)) $contactInfo .= '<li class="phone">'.$phone_2.'</li>';
  44. if(!empty($fax_1)) $contactInfo .= '<li class="fax">'.$fax_1.'</li>';
  45. if(!empty($fax_2)) $contactInfo .= '<li class="fax">'.$fax_2.'</li>';
  46. if(!empty($mail_1)) $contactInfo .= '<li class="mail"><a href="mailto:'.$mail_1.'">'.$mail_1.'</a></li>';
  47. if(!empty($mail_2)) $contactInfo .= '<li class="mail"><a href="mailto:'.$mail_2.'">'.$mail_2.'</a></li>';
  48. if(!empty($support_mail_1)) $contactInfo .= '<li class="help"><a href="mailto:'.$support_mail_1.'">'.$support_mail_1.'</a></li>';
  49. if(!empty($support_mail_2)) $contactInfo .= '<li class="help"><a href="mailto:'.$support_mail_2.'">'.$support_mail_2.'</a></li>';
  50. if(!empty($map_link)) $contactInfo .= '<li class="map"><a href="'.$map_link.'" title="'.$map_link_text.'">'.$map_link_text.'</a></li>';
  51. 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>';
  52.  
  53. $contactInfo .= '</ul>';
  54.  
  55.  
  56. echo $before_widget;
  57. if ($title) echo $before_title . $title . $after_title;
  58. echo $contactInfo;
  59. echo $after_widget;
  60. }
  61.  
  62. function update( $new_instance, $old_instance ) {
  63.  
  64. $instance = $old_instance;
  65. $instance['title'] = strip_tags($new_instance['title']);
  66. $instance['address'] = ($new_instance['address']);
  67. $instance['phone_1'] = ($new_instance['phone_1']);
  68. $instance['phone_2'] = ($new_instance['phone_2']);
  69. $instance['fax_1'] = strip_tags($new_instance['fax_1']);
  70. $instance['fax_2'] = strip_tags($new_instance['fax_2']);
  71. $instance['mail_1'] = strip_tags($new_instance['mail_1']);
  72. $instance['mail_2'] = strip_tags($new_instance['mail_2']);
  73. $instance['support_mail_1'] = strip_tags($new_instance['support_mail_1']);
  74. $instance['support_mail_2'] = strip_tags($new_instance['support_mail_2']);
  75. $instance['contact_form_link'] = strip_tags($new_instance['contact_form_link']);
  76. $instance['map_link'] = strip_tags($new_instance['map_link']);
  77. $instance['contact_form_link_text'] = strip_tags($new_instance['contact_form_link_text']);
  78. $instance['map_link_text'] = strip_tags($new_instance['map_link_text']);
  79.  
  80. wpml_register_string( THEMESLUG , 'Address', strip_tags($new_instance['address']) ) ;
  81. wpml_register_string( THEMESLUG , 'Phone 1', ($new_instance['phone_1']) ) ;
  82. wpml_register_string( THEMESLUG , 'Phone 2', ($new_instance['phone_2']) ) ;
  83. wpml_register_string( THEMESLUG , 'Fax 1', strip_tags($new_instance['fax_1']) ) ;
  84. wpml_register_string( THEMESLUG , 'Fax 2', strip_tags($new_instance['fax_2']) ) ;
  85. wpml_register_string( THEMESLUG , 'Email 1', strip_tags($new_instance['mail_1']) ) ;
  86. wpml_register_string( THEMESLUG , 'Email 2', strip_tags($new_instance['mail_2']) ) ;
  87. wpml_register_string( THEMESLUG , 'Support Email 1', strip_tags($new_instance['support_mail_1']) ) ;
  88. wpml_register_string( THEMESLUG , 'Support Email 2', strip_tags($new_instance['support_mail_2']) ) ;
  89. wpml_register_string( THEMESLUG , 'Map Link', strip_tags($new_instance['map_link']) ) ;
  90. wpml_register_string( THEMESLUG , 'Contact Form Link', strip_tags($new_instance['contact_form_link']) ) ;
  91. wpml_register_string( THEMESLUG , 'Map Link Text', strip_tags($new_instance['map_link_text']) ) ;
  92. wpml_register_string( THEMESLUG , 'Contact Form Link Text', strip_tags($new_instance['contact_form_link_text']) ) ;
  93.  
  94. return $instance;
  95. }
  96.  
  97. function form( $instance ) {
  98. $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
  99. $address = isset($instance['address']) ? esc_attr($instance['address']) : '';
  100. $phone_1 = isset($instance['phone_1']) ? esc_attr($instance['phone_1']) : '';
  101. $phone_2 = isset($instance['phone_2']) ? esc_attr($instance['phone_2']) : '';
  102. $fax_1 = isset($instance['fax_1']) ? esc_attr($instance['fax_1']) : '';
  103. $fax_2 = isset($instance['fax_2']) ? esc_attr($instance['fax_2']) : '';
  104. $mail_1 = isset($instance['mail_1']) ? esc_attr($instance['mail_1']) : '';
  105. $mail_2 = isset($instance['mail_2']) ? esc_attr($instance['mail_2']) : '';
  106. $support_mail_1 = isset($instance['support_mail_1']) ? esc_attr($instance['support_mail_1']) : '';
  107. $support_mail_2 = isset($instance['support_mail_2']) ? esc_attr($instance['support_mail_2']) : '';
  108. $map_link = isset($instance['map_link']) ? esc_attr($instance['map_link']) : '';
  109. $contact_form_link = isset($instance['contact_form_link']) ? esc_attr($instance['contact_form_link']) : '';
  110. $map_link_text = isset($instance['map_link_text']) ? esc_attr($instance['map_link_text']) : '';
  111. $contact_form_link_text = isset($instance['contact_form_link_text']) ? esc_attr($instance['contact_form_link_text']) : '';
  112.  
  113. // Categories
  114. $rt_getcat = RTTheme::rt_get_categories();
  115.  
  116.  
  117. ?>
  118. <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'rt_theme_admin'); ?></label>
  119. <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>
  120.  
  121. <p><label for="<?php echo $this->get_field_id('address'); ?>"><?php _e('Address:', 'rt_theme_admin'); ?></label>
  122. <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>
  123.  
  124. <p><label for="<?php echo $this->get_field_id('phone_1'); ?>"><?php _e('Phone 1:', 'rt_theme_admin'); ?></label>
  125. <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>
  126.  
  127. <p><label for="<?php echo $this->get_field_id('phone_2'); ?>"><?php _e('Phone 2:', 'rt_theme_admin'); ?></label>
  128. <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>
  129.  
  130. <p><label for="<?php echo $this->get_field_id('fax_1'); ?>"><?php _e('Fax 1:', 'rt_theme_admin'); ?></label>
  131. <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>
  132.  
  133. <p><label for="<?php echo $this->get_field_id('fax_2'); ?>"><?php _e('Fax 2:', 'rt_theme_admin'); ?></label>
  134. <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>
  135.  
  136. <p><label for="<?php echo $this->get_field_id('mail_1'); ?>"><?php _e('Email 1:', 'rt_theme_admin'); ?></label>
  137. <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>
  138.  
  139. <p><label for="<?php echo $this->get_field_id('mail_2'); ?>"><?php _e('Email 2:', 'rt_theme_admin'); ?></label>
  140. <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>
  141.  
  142. <p><label for="<?php echo $this->get_field_id('support_mail_1'); ?>"><?php _e('Support Email 1:', 'rt_theme_admin'); ?></label>
  143. <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>
  144.  
  145. <p><label for="<?php echo $this->get_field_id('support_mail_2'); ?>"><?php _e('Support Email 2:', 'rt_theme_admin'); ?></label>
  146. <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>
  147.  
  148. <p><label for="<?php echo $this->get_field_id('contact_form_link'); ?>"><?php _e('Contact Form Link:', 'rt_theme_admin'); ?></label>
  149. <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>
  150.  
  151. <p><label for="<?php echo $this->get_field_id('contact_form_link_text'); ?>"><?php _e('Contact Form Link Text:', 'rt_theme_admin'); ?></label>
  152. <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>
  153.  
  154. <p><label for="<?php echo $this->get_field_id('map_link'); ?>"><?php _e('Map Link:', 'rt_theme_admin'); ?></label>
  155. <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>
  156.  
  157. <p><label for="<?php echo $this->get_field_id('map_link_text'); ?>"><?php _e('Map Link Text:', 'rt_theme_admin'); ?></label>
  158. <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>
  159. <?php } } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement