Пример #1
0
    public static function frontend_footer_scripts()
    {
        global $people_contact_loaded_footer_scripts;
        if ($people_contact_loaded_footer_scripts) {
            return;
        }
        $people_contact_loaded_footer_scripts = true;
        global $people_email_inquiry_global_settings;
        if ($people_email_inquiry_global_settings['contact_form_type_other'] == 1) {
            return;
        }
        ?>
    	<script type="text/javascript">
			jQuery(document).ready(function ($) {
				$(document).on("click", ".people_email_inquiry_form_button", function(){
					var contact_id = $(this).attr("contact_id");
					var people_email_inquiry_error = "";
					var people_email_inquiry_have_error = false;

					var filter = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					var profile_email = $("#profile_email_" + contact_id).val();
					var profile_name = $("#profile_name_" + contact_id).val();
					var c_name = $("#c_name_" + contact_id).val();
					var c_subject = $("#c_subject_" + contact_id).val();
					var c_email = $("#c_email_" + contact_id).val();
					var c_phone = $("#c_phone_" + contact_id).val();
					var c_message = $("#c_message_" + contact_id).val();
					var send_copy = 0;
					if ( $("#send_copy_" + contact_id).is(':checked') )
						send_copy = 1;

					if (c_name.replace(/^\s+|\s+$/g, '') == "") {
						people_email_inquiry_error += "<?php 
        people_ict_t_e('Default Form - Contact Name Error', __('Please enter your Name', 'cup_cp'));
        ?>
\n";
						people_email_inquiry_have_error = true;
					}
					if (c_email == "" || !filter.test(c_email)) {
						people_email_inquiry_error += "<?php 
        people_ict_t_e('Default Form - Contact Email Error', __('Please enter valid Email address', 'cup_cp'));
        ?>
\n";
						people_email_inquiry_have_error = true;
					}
					if (c_phone.replace(/^\s+|\s+$/g, '') == "") {
						people_email_inquiry_error += "<?php 
        people_ict_t_e('Default Form - Contact Phone Error', __('Please enter your Phone', 'cup_cp'));
        ?>
\n";
						people_email_inquiry_have_error = true;
					}
					if (c_message.replace(/^\s+|\s+$/g, '') == "") {
						people_email_inquiry_error += "<?php 
        people_ict_t_e('Default Form - Contact Message Error', __('Please enter your Message', 'cup_cp'));
        ?>
\n";
						people_email_inquiry_have_error = true;
					}

					if (people_email_inquiry_have_error) {
						alert(people_email_inquiry_error);
						return false;
					}

					$(this).attr("disabled", "disabled");

					var wait = $('.ajax-wait');
					wait.css('display','block');

					var data = {
						action: 		"send_a_contact",
						contact_id: 	contact_id,
						profile_email:	profile_email,
						profile_name:	profile_name,
						c_name: 		c_name,
						c_email: 		c_email,
						c_phone: 		c_phone,
						c_subject:		c_subject,
						c_message: 		c_message,
						send_copy:		send_copy,
						security: 		"<?php 
        echo wp_create_nonce("send-a-contact");
        ?>
"
					};

					$.post( '<?php 
        echo admin_url('admin-ajax.php', 'relative');
        ?>
', data, function(response) {
						$('#people_email_inquiry_content_' + contact_id ).html(response);
						wait.css('display','none');
					});
					return false;
				});
			});
		</script>
    <?php 
    }
Пример #2
0
    public function load_ajax_contact_form()
    {
        global $people_contact_grid_view_icon;
        global $people_email_inquiry_global_settings;
        if (trim($people_email_inquiry_global_settings['inquiry_contact_text_button']) != '') {
            $inquiry_contact_text_button = $people_email_inquiry_global_settings['inquiry_contact_text_button'];
        } else {
            $inquiry_contact_text_button = __('SEND', 'cup_cp');
        }
        $inquiry_contact_button_class = apply_filters('people_inquiry_contact_button_class', '');
        $inquiry_contact_form_class = apply_filters('people_inquiry_contact_form_class', '');
        $contact_id = $_REQUEST['contact_id'];
        $data = People_Contact_Profile_Data::get_row($contact_id, '', 'ARRAY_A');
        if ($data['c_avatar'] != '') {
            $src = $data['c_avatar'];
            $c_attachment_id = $data['c_attachment_id'];
        } else {
            $src = PEOPLE_CONTACT_IMAGE_URL . '/no-avatar.png';
            $c_attachment_id = 0;
        }
        $img_output = '<img width="80" class="wp-image-' . $c_attachment_id . '" src="' . $src . '" />';
        if (function_exists('wp_make_content_images_responsive')) {
            $img_output = wp_make_content_images_responsive($img_output);
        }
        ?>
		<div class="custom_contact_popup <?php 
        echo $inquiry_contact_form_class;
        ?>
">
        <div style="padding:10px;">
		<div style="clear:both"></div>
		<div class="people_email_inquiry_contact_heading" ><?php 
        echo $people_email_inquiry_global_settings['inquiry_contact_heading'];
        ?>
</div>
		<div style="clear:both; margin-top:10px"></div>
        <div class="people_email_inquiry_site_name"><?php 
        echo $people_email_inquiry_global_settings['inquiry_form_site_name'];
        ?>
</div>
        <div style="clear:both; margin-top:5px"></div>
		<div style="float:left; margin-right:20px;" class="people_email_inquiry_default_image_container"><?php 
        echo $img_output;
        ?>
</div>
        <div style="display:block; margin-bottom:10px; padding-left:22%;" class="people_email_inquiry_product_heading_container">
			<div class="people_email_inquiry_profile_position"><?php 
        esc_attr_e(stripslashes($data['c_title']));
        ?>
</div>
            <div class="people_email_inquiry_profile_name"><?php 
        esc_attr_e(stripslashes($data['c_name']));
        ?>
</div>
        </div>
		<div style="clear:both;height:1em;"></div>
        <div class="people_email_inquiry_content" id="people_email_inquiry_content_<?php 
        echo $contact_id;
        ?>
">
        	<input type="hidden" value="<?php 
        esc_attr_e(stripslashes($data['c_email']));
        ?>
" id="profile_email_<?php 
        echo $contact_id;
        ?>
" name="profile_email" />
        	<input type="hidden" value="<?php 
        esc_attr_e(stripslashes($data['c_title']));
        ?>
 <?php 
        esc_attr_e(stripslashes($data['c_name']));
        ?>
" id="profile_name_<?php 
        echo $contact_id;
        ?>
" name="profile_name" />
            <div class="people_email_inquiry_field">
                <label class="people_email_inquiry_label" for="c_name_<?php 
        echo $contact_id;
        ?>
"><?php 
        people_ict_t_e('Default Form - Contact Name', __('Name', 'cup_cp'));
        ?>
 <span class="gfield_required">*</span></label>
                <input type="text" name="c_name" id="c_name_<?php 
        echo $contact_id;
        ?>
" value="" /></div>
            <div class="people_email_inquiry_field">
                <label class="people_email_inquiry_label" for="c_email_<?php 
        echo $contact_id;
        ?>
"><?php 
        people_ict_t_e('Default Form - Contact Email', __('Email', 'cup_cp'));
        ?>
 <span class="gfield_required">*</span></label>
                <input type="text" name="c_email" id="c_email_<?php 
        echo $contact_id;
        ?>
" value="" /></div>
            <div class="people_email_inquiry_field">
                <label class="people_email_inquiry_label" for="c_phone_<?php 
        echo $contact_id;
        ?>
"><?php 
        people_ict_t_e('Default Form - Contact Phone', __('Phone', 'cup_cp'));
        ?>
 <span class="gfield_required">*</span></label>
                <input type="text" name="c_phone" id="c_phone_<?php 
        echo $contact_id;
        ?>
" value="" /></div>
            <div class="people_email_inquiry_field">
                <label class="people_email_inquiry_label" for="c_subject_<?php 
        echo $contact_id;
        ?>
"><?php 
        people_ict_t_e('Default Form - Contact Subject', __('Subject', 'cup_cp'));
        ?>
 </label>
                <input type="text" name="c_subject" id="c_subject_<?php 
        echo $contact_id;
        ?>
" value="" /></div>
            <div class="people_email_inquiry_field">
                <label class="people_email_inquiry_label" for="c_message_<?php 
        echo $contact_id;
        ?>
"><?php 
        people_ict_t_e('Default Form - Contact Message', __('Message', 'cup_cp'));
        ?>
 <span class="gfield_required">*</span></label>
                <textarea rows="3" name="c_message" id="c_message_<?php 
        echo $contact_id;
        ?>
"></textarea></div>
            <div class="people_email_inquiry_field">
                <?php 
        if ($people_email_inquiry_global_settings['send_copy'] != 'no') {
            ?>
                <label class="people_email_inquiry_label">&nbsp;</label>
                <label class="people_email_inquiry_send_copy"><input type="checkbox" name="send_copy" id="send_copy_<?php 
            echo $contact_id;
            ?>
" value="1" checked="checked" /> <?php 
            people_ict_t_e('Default Form - Send Copy', __('Send a copy of this email to myself.', 'cup_cp'));
            ?>
</label>
                <?php 
        }
        ?>
                <a class="people_email_inquiry_form_button <?php 
        echo $inquiry_contact_button_class;
        ?>
" id="people_email_inquiry_bt_<?php 
        echo $contact_id;
        ?>
" contact_id="<?php 
        echo $contact_id;
        ?>
"><?php 
        echo $inquiry_contact_text_button;
        ?>
</a>
            </div>
            <div style="clear:both"></div>
        </div>
		<div style="clear:both"></div>
		<div class="ajax-wait">&nbsp;</div>
        </div>
        </div>
		<?php 
        die;
    }