Advertisement
m4ly

HT InCreate Contact Details CryptX

Apr 6th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.74 KB | None | 0 0
  1. Install cryptx
  2. In wp-admin: cryptx->settings->check 'Text scrambled by AntiSpamBot'
  3. Create files in HT child theme dir and paste below content. New widget should apear in apperance->widgets.
  4.  
  5. [user@domain /homepage/wp-content/themes/ht-increate-child/cst_includes/widgets]# cat ../../functions.php
  6. <?php
  7. require_once(get_stylesheet_directory() . '/cst_includes/widgets/widgets.php');
  8. ?>
  9. [user@domain /homepage/wp-content/themes/ht-increate-child/cst_includes/widgets]# cat widgets.php
  10. <?php
  11.  
  12. function register_ht_contact_details_cryptx() {
  13.     register_widget('ht_contact_details_cryptx');
  14. }
  15.  
  16. add_action('widgets_init', 'register_ht_contact_details_cryptx');
  17. /**
  18.  * Highthemes Contact Details CryptX
  19.  */
  20.  
  21. class ht_contact_details_cryptx extends WP_Widget {
  22.  
  23.         public function __construct() {
  24.                 global  $theme_name;
  25.                 $widget_ops = array('classname' => 'ht_contact_details_cryptx',
  26.                                                         'description' => __( 'Contact Details CryptX for Sidebar','highthemes') );
  27.  
  28.                 parent::__construct(
  29.                         'ht_contact_details_cryptx',
  30.                         'Highthemes - ' . __('Contact Details CryptX','highthemes'),
  31.                          $widget_ops // Args
  32.                 );
  33.         }
  34.  
  35.         // display the widget in the theme
  36.         function widget( $args, $instance ) {
  37.                 extract($args);
  38.  
  39.                 if(isset($instance['contact_text'])) $instance['contact_text'] = stripslashes($instance['contact_text']);
  40.                 if(isset($instance['contact_details'])) $instance['contact_details'] = stripslashes($instance['contact_details']);
  41.                 if(isset($instance['contact_email'])) $instance['contact_email'] = stripslashes($instance['contact_email']);
  42.                 if(isset($instance['contact_www'])) $instance['contact_www'] = stripslashes($instance['contact_www']);
  43.  
  44.                 $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
  45.  
  46.                 echo $before_widget;
  47.  
  48.  
  49.  
  50. ?>
  51. <div class="contact-details">
  52.             <?php if ( $title ) echo $before_title . $title . $after_title; ?>
  53.             <p><?php echo stripslashes($instance['contact_text']); ?> </p>
  54.             <ul>
  55.               <?php echo stripslashes($instance['contact_details']);?>
  56.               <li><i class="fa-globe"></i><a href="http://<?php echo stripslashes($instance['contact_www']);?> "><?php echo stripslashes($instance['contact_www']); ?></a></li>
  57.               <?php
  58.  
  59.             $email = trim(stripslashes($instance['contact_email']));
  60.  
  61.             if(!empty($email)) {
  62.             echo '<li><i class="fa-envelope"></i>';
  63.                 if(function_exists('encryptx')) {
  64.                         encryptx($email, array('text'=>'', array('text' => $email, 'css_class' => 'cryptx-email', 'css_id' => '', 'echo' => 1)));
  65.                 }
  66.                 else {
  67.             ?>
  68.                <a href="mailto:<?=$email?> "><?=$email?></a>
  69.             <?php
  70.             echo '</li>';
  71.                     }
  72.             }
  73.             ?>
  74.  
  75.             </ul>
  76.           </div>
  77.  
  78. <?php
  79.                 echo $after_widget;
  80.  
  81.                 //end
  82.         }
  83.  
  84.         // update the widget when new options have been entered
  85.         function update( $new_instance, $old_instance ) {
  86.  
  87.                 $instance = $old_instance;
  88.                 $instance['title'] = strip_tags( $new_instance['title'] );
  89.  
  90.                 $instance['contact_text'] = $new_instance['contact_text'];
  91.                 $instance['contact_details'] = $new_instance['contact_details'];
  92.                 $instance['contact_email'] = $new_instance['contact_email'];
  93.                 $instance['contact_www'] = $new_instance['contact_www'];
  94.  
  95.                 return $instance;
  96.         }
  97.  
  98.         // print the widget option form on the widget management screen
  99.         function form( $instance ) {
  100.  
  101.         // combine provided fields with defaults
  102.         $instance = wp_parse_args( (array) $instance, array('title'=>'Contact Details','contact_email' => 'email@example.com', 'contact_text'=>'lorem ipsum dolor sit amet', 'contact_details'=>'<li><i class="fa-home"></i>1736 Nutters Barn Lane Clarion, LA 50525</li><li><i class="fa-phone"></i> 111-5252-8568</li><li><i class="fa-print"></i> 111-9858-858</li><li><i class="fa-envelope"></i>email@gmail.com</li><li><i class="fa-globe"></i>www.site.com</li>' ) );
  103.         $contact_text = $instance['contact_text'];
  104.         $contact_details = $instance['contact_details'];
  105.         $title =  strip_tags($instance['title']);
  106.         $contact_email = $instance['contact_email'];
  107.         $contact_www = $instance['contact_www'];
  108.  
  109.  
  110.  
  111.         // print the form fields
  112. ?>
  113.  
  114.     <div class="contact-details">
  115.                 <p>
  116.                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:','highthemes') ?></label>
  117.                         <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo
  118.                 esc_attr($title); ?>" />
  119.                 </p>
  120.  
  121.                 <p>
  122.                 <label for="<?php echo $this->get_field_id('contact_email'); ?>"><?php _e('Email:','highthemes') ?></label>
  123.                         <input type="text" class="widefat" id="<?php echo $this->get_field_id('contact_email'); ?>" name="<?php echo $this->get_field_name('contact_email'); ?>" value="<?php echo
  124.                 esc_attr($contact_email); ?>" />
  125.                 </p>
  126.  
  127.  
  128.  
  129.                 <p>
  130.                 <label for="<?php echo $this->get_field_id('contact_www'); ?>"><?php _e('WWW:','highthemes') ?></label>
  131.                         <input type="text" class="widefat" id="<?php echo $this->get_field_id('contact_www'); ?>" name="<?php echo $this->get_field_name('contact_www'); ?>" value="<?php echo
  132.                 esc_attr($contact_www); ?>" />
  133.                 </p>
  134.  
  135.  
  136.         <p><label for="<?php echo $this->get_field_id('contact_text'); ?>">
  137.         <?php _e('Text:','highthemes'); ?></label>
  138.             <textarea cols="36" rows="5" name="<?php echo $this->get_field_name('contact_text'); ?>" id="<?php echo $this->get_field_id('contact_text'); ?>"><?php echo
  139.             esc_attr($contact_text); ?></textarea>
  140.         </p>
  141.         <p><label for="<?php echo $this->get_field_id('contact_details'); ?>">
  142.         <?php _e('Contact Details:','highthemes'); ?></label>
  143.             <textarea cols="36" rows="15" name="<?php echo $this->get_field_name('contact_details'); ?>" id="<?php echo $this->get_field_id('contact_details'); ?>"><?php echo
  144.             esc_attr($contact_details); ?></textarea>
  145.             </p>
  146.  
  147.     </div>
  148.         <?php
  149.         }
  150.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement