Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Nevia Contact Info Cryptx

By: m4ly on Sep 20th, 2013  |  syntax: PHP  |  size: 4.52 KB  |  views: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. // @Author Dawid Mocek
  4. // /wp-content/themes/nevia-child/inc/widgets.php
  5.  
  6. function register_purepress_contact_cryptx() {
  7.         register_widget( 'purepress_contact_cryptx' );
  8. }
  9.  
  10. add_action( 'widgets_init', 'register_purepress_contact_cryptx' );
  11.  
  12. class purepress_contact_cryptx extends WP_Widget {
  13.  
  14.         function purepress_contact_cryptx() {
  15.             $widget_ops = array('classname' => 'purepress-contact-cryptx', 'description' => 'Nicely styled contact info widget with CryptX mail protection');
  16.             $control_ops = array('width' => 300, 'height' => 350);
  17.             $this->WP_Widget('purepress_contact_cryptx', 'Nevia Child CryptX Contact Info', $widget_ops, $control_ops);
  18.         }
  19.  
  20.         function widget($args, $instance) {
  21.             extract($args, EXTR_SKIP);
  22.             $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
  23.             $address = $instance['address'];
  24.             $phone = $instance['phone'];
  25.             $email = $instance['email'];
  26.             echo $before_widget;
  27.             echo $before_title . $title . $after_title;
  28.                 ?>
  29.             <ul class="contact-details-alt">
  30.                 <?php
  31.                 if($address) { ?>
  32.                 <li><i class="halflings white map-marker"></i> <p><strong><?php _e('Address', 'purepress'); ?>:</strong> <?php echo $address; ?></p></li>
  33.                 <?php }
  34.                 if($phone) { ?>
  35.                 <li><i class="halflings white user"></i> <p><strong><?php _e('Phone', 'purepress'); ?>:</strong> <?php echo $phone; ?></p></li>
  36.                 <?php }
  37.                 if($email) { ?>
  38.                 <li><i class="halflings white envelope"></i> <p><strong><?php _e('Email', 'purepress'); ?>:</strong><p>
  39.                                 <?php
  40.                                 if(function_exists('encryptx'))
  41.                                         encryptx($email, array('text' => '', array('text' => $email, 'css_class' => 'cryptx-email', 'css_id' => '', 'echo' => 1)));
  42.                                 else
  43.                                         echo '<a href="mailto:'.$email.'">'.$email.'</a>';
  44.                                 ?>
  45.                                 </p></li>
  46.                 <?php } ?>
  47.             </ul>
  48.             <?php
  49.             echo $after_widget;
  50.         }
  51.  
  52.  
  53.         function update($new_instance, $old_instance) {
  54.             $instance = $old_instance;
  55.             $instance['title'] = strip_tags($new_instance['title']);
  56.             $instance['address'] = $new_instance['address'];
  57.             $instance['phone'] = $new_instance['phone'];
  58.             $instance['email'] = $new_instance['email'];
  59.  
  60.             return $instance;
  61. }
  62.   function form($instance) {
  63.             $instance = wp_parse_args((array) $instance, array('title' => ''));
  64.             $title = strip_tags($instance['title']);
  65.             $address = strip_tags($instance['address']);
  66.             $phone = strip_tags($instance['phone']);
  67.             $email = strip_tags($instance['email']);
  68.             ?>
  69.             <p>
  70.                 <label for="<?php echo $this->get_field_id('title'); ?>">Title:
  71.                     <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($title); ?>" />
  72.                 </label>
  73.             </p>
  74.             <p>
  75.                 <label for="<?php echo $this->get_field_id('address'); ?>"><?php _e('Address', 'purepress'); ?>:
  76.                     <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; ?>" size="20" />
  77.                 </label>
  78.             </p>
  79.             <p>
  80.                 <label for="<?php echo $this->get_field_id('phone'); ?>"><?php _e('Phone', 'purepress'); ?>:
  81.                     <input class="widefat" id="<?php echo $this->get_field_id('phone'); ?>" name="<?php echo $this->get_field_name('phone'); ?>" type="text" value="<?php echo $phone; ?>" size="20" />
  82.                 </label>
  83.             </p>
  84.             <p>
  85.                 <label for="<?php echo $this->get_field_id('email'); ?>"><?php _e('Email', 'purepress'); ?>:
  86.                     <input class="widefat" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" type="text" value="<?php echo $email; ?>" size="20" />
  87.                 </label>
  88.             </p>
  89.             <?php
  90.         }
  91.     }
  92. ?>