Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // @Author Dawid Mocek
- // /wp-content/themes/nevia-child/inc/widgets.php
- function register_purepress_contact_cryptx() {
- register_widget( 'purepress_contact_cryptx' );
- }
- add_action( 'widgets_init', 'register_purepress_contact_cryptx' );
- class purepress_contact_cryptx extends WP_Widget {
- function purepress_contact_cryptx() {
- $widget_ops = array('classname' => 'purepress-contact-cryptx', 'description' => 'Nicely styled contact info widget with CryptX mail protection');
- $control_ops = array('width' => 300, 'height' => 350);
- $this->WP_Widget('purepress_contact_cryptx', 'Nevia Child CryptX Contact Info', $widget_ops, $control_ops);
- }
- function widget($args, $instance) {
- extract($args, EXTR_SKIP);
- $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
- $address = $instance['address'];
- $phone = $instance['phone'];
- $email = $instance['email'];
- echo $before_widget;
- echo $before_title . $title . $after_title;
- ?>
- <ul class="contact-details-alt">
- <?php
- if($address) { ?>
- <li><i class="halflings white map-marker"></i> <p><strong><?php _e('Address', 'purepress'); ?>:</strong> <?php echo $address; ?></p></li>
- <?php }
- if($phone) { ?>
- <li><i class="halflings white user"></i> <p><strong><?php _e('Phone', 'purepress'); ?>:</strong> <?php echo $phone; ?></p></li>
- <?php }
- if($email) { ?>
- <li><i class="halflings white envelope"></i> <p><strong><?php _e('Email', 'purepress'); ?>:</strong><p>
- <?php
- if(function_exists('encryptx'))
- encryptx($email, array('text' => '', array('text' => $email, 'css_class' => 'cryptx-email', 'css_id' => '', 'echo' => 1)));
- else
- echo '<a href="mailto:'.$email.'">'.$email.'</a>';
- ?>
- </p></li>
- <?php } ?>
- </ul>
- <?php
- echo $after_widget;
- }
- function update($new_instance, $old_instance) {
- $instance = $old_instance;
- $instance['title'] = strip_tags($new_instance['title']);
- $instance['address'] = $new_instance['address'];
- $instance['phone'] = $new_instance['phone'];
- $instance['email'] = $new_instance['email'];
- return $instance;
- }
- function form($instance) {
- $instance = wp_parse_args((array) $instance, array('title' => ''));
- $title = strip_tags($instance['title']);
- $address = strip_tags($instance['address']);
- $phone = strip_tags($instance['phone']);
- $email = strip_tags($instance['email']);
- ?>
- <p>
- <label for="<?php echo $this->get_field_id('title'); ?>">Title:
- <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); ?>" />
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id('address'); ?>"><?php _e('Address', 'purepress'); ?>:
- <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" />
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id('phone'); ?>"><?php _e('Phone', 'purepress'); ?>:
- <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" />
- </label>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id('email'); ?>"><?php _e('Email', 'purepress'); ?>:
- <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" />
- </label>
- </p>
- <?php
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement