Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'after_setup_theme', 'child_theme_setup', 20 );
- function child_theme_setup() {
- remove_shortcode( 'contacts_form' );
- add_shortcode( 'contacts_form', 'my_contacts_form' );
- }
- /* i have added a menu option for <select> element to contact form */
- function my_contacts_form($attributes, $content = null) {
- global $smof_data;
- $attributes = shortcode_atts(
- array(
- ), $attributes);
- $output = '<div class="w-form contacts_form">
- <div class="w-form-h">
- <form class="g-form" action="#" method="post" id="contact_form">
- <div class="g-form-group">
- <div class="g-form-group-rows">';
- if (in_array(@$smof_data['contact_form_name_field'], array('Shown, required', 'Shown, not required')))
- {
- $name_required = (@$smof_data['contact_form_name_field'] == 'Shown, required')?1:0;
- $output .= '<div class="g-form-row" id="name_row">
- <div class="g-form-row-label">
- <label class="g-form-row-label-h">'.__('Your name', 'us').'</label>
- </div>
- <div class="g-form-row-field">
- <i class="fa fa-user"></i>
- <input type="text" name="name" data-required="'.$name_required.'">
- </div>
- <div class="g-form-row-state" id="name_state"></div>
- </div>';
- }
- if (in_array(@$smof_data['contact_form_name_field'], array('Shown, required', 'Shown, not required')))
- {
- $name_required = (@$smof_data['contact_form_name_field'] == 'Shown, required')?1:0;
- $output .= '<div class="g-form-row" id="name_row">
- <div class="g-form-row-label">
- <label class="g-form-row-label-h">'.__('Business Name', 'us').'</label>
- </div>
- <div class="g-form-row-field">
- <i class="fa fa-user"></i>
- <input type="text" name="name" data-required="'.$name_required.'">
- </div>
- <div class="g-form-row-state" id="name_state"></div>
- </div>';
- }
- if (in_array(@$smof_data['contact_form_email_field'], array('Shown, required', 'Shown, not required')))
- {
- $email_required = (@$smof_data['contact_form_email_field'] == 'Shown, required')?1:0;
- $output .= '<div class="g-form-row" id="email_row">
- <div class="g-form-row-label">
- <label class="g-form-row-label-h">'.__('Email', 'us').'</label>
- </div>
- <div class="g-form-row-field">
- <i class="fa fa-envelope"></i>
- <input type="email" name="email" data-required="'.$email_required.'">
- </div>
- <div class="g-form-row-state" id="email_state"></div>
- </div>';
- }
- if (in_array(@$smof_data['contact_form_phone_field'], array('Shown, required', 'Shown, not required')))
- {
- $phone_required = (@$smof_data['contact_form_phone_field'] == 'Shown, required')?1:0;
- $output .= '<div class="g-form-row" id="phone_row">
- <div class="g-form-row-label">
- <label class="g-form-row-label-h">'.__('Phone Number', 'us').'</label>
- </div>
- <div class="g-form-row-field">
- <i class="fa fa-phone"></i>
- <input type="text" name="phone" data-required="'.$phone_required.'">
- </div>
- <div class="g-form-row-state" id="phone_state"></div>
- </div>';
- }
- $output .= '<div class="g-form-row" id="message_row">
- <div class="g-form-row-label">
- <label class="g-form-row-label-h">'.__('Number Of Emails Sent Per Month', 'us').'</label>
- </div>
- <div class="g-form-row-field">
- <select>
- <option value="0-9999">Up to 9,999</option>
- <option value="10000-30000">10000-30000</option>
- <option value="30001+">30001+</option>
- </select>
- </div>
- <div class="g-form-row-state" id="message_state"></div>
- </div>
- <div class="g-form-row">
- <div class="g-form-row-label"></div>
- <div class="g-form-row-field">
- <button class="g-btn type_primary" id="message_send"><span>'.__('Send Message', 'us').'</span></button>
- </div>
- </div>
- </div>
- </div>
- </form>
- </div>
- </div>';
- return $output;
- }
- class MY_Widget_Contact extends WP_Widget {
- function __construct()
- {
- $widget_ops = array('classname' => 'widget_contact', 'description' => 'Contact Information');
- $control_ops = array();
- $this->WP_Widget('contact', 'Contacts', $widget_ops, $control_ops);
- }
- function form($instance)
- {
- $defaults = array('title' => 'Contacts', 'address' => '', 'phone' => '', 'email' => '', 'web' => '', );
- $instance = wp_parse_args((array) $instance, $defaults);
- ?>
- <p>
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php echo 'Title' ?>:</label>
- <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($instance['title']); ?>" /></p>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id('address'); ?>"><?php echo 'Address' ?>:</label>
- <textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('address'); ?>" name="<?php echo $this->get_field_name('address'); ?>"><?php echo esc_textarea($instance['address']); ?></textarea>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id('phone'); ?>"><?php echo 'Phone(s)' ?>:</label>
- <textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('phone'); ?>" name="<?php echo $this->get_field_name('phone'); ?>" style="height: 47px;"><?php echo esc_textarea($instance['phone']); ?></textarea>
- </p>
- <label for="<?php echo $this->get_field_id('web'); ?>"><?php echo 'Web' ?>:</label>
- <textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('web'); ?>" name="<?php echo $this->get_field_name('web'); ?>" style="height: 47px;"><?php echo esc_textarea($instance['web']); ?></textarea>
- </p>
- <label for="<?php echo $this->get_field_id('email'); ?>"><?php echo 'Email' ?>:</label>
- <input class="widefat" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" type="text" value="<?php echo esc_attr($instance['email']); ?>" />
- </p>
- <?php
- }
- function widget($args, $instance)
- {
- $title = apply_filters('widget_title', empty($instance['title']) ? __('Contacts', 'us') : $instance['title'], $instance, $this->id_base);
- echo $args['before_widget'];
- if ($title){
- echo '<h5>'.$title.'</h5>';
- }
- ?><div class="w-contacts"><div class="w-contacts-h"><?php
- ?><div class="w-contacts-list"><?php
- if ($instance['address']){
- echo '<div class="w-contacts-item">
- <i class="fa fa-map-marker"></i>
- <span class="w-contacts-item-value">'.$instance['address'].'</span>
- </div>';
- }
- if ($instance['phone']){
- echo '<div class="w-contacts-item">
- <i class="fa fa-phone"></i>
- <span class="w-contacts-item-value">'.$instance['phone'].'</span>
- </div>';
- }
- if ($instance['email']){
- echo '<div class="w-contacts-item">
- <i class="fa fa-envelope-o"></i>
- <span class="w-contacts-item-value"><a href="mailto:'.$instance['email'].'">'.$instance['email'].'</a></span>
- </div>';
- }
- if ($instance['web']){
- echo '<div class="w-contacts-item">
- <i class="fa fa-laptop"></i>
- <span class="w-contacts-item-value"><a href="http://'.$instance['web'].'">'.$instance['web'].'</a></span>
- </div>';
- }
- ?></div></div></div><?php
- echo $args['after_widget'];
- }
- }
- add_action('widgets_init', 'my_register_contact_widget', 20);
- function my_register_contact_widget()
- {
- unregister_widget('US_Widget_Contact');
- register_widget('MY_Widget_Contact');
- }
Advertisement
Add Comment
Please, Sign In to add comment