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"> </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"> </div> </div> </div> <?php die; }
public static function admin_screen_add_edit() { global $people_contact_location_map_settings; global $people_contact_admin_init; add_filter($people_contact_admin_init->plugin_name . '_' . 'a3_people_groupes_box' . '_pro_version_name', array('People_Category_Manager_Panel', 'get_ultimate_version_name')); add_filter($people_contact_admin_init->plugin_name . '_' . 'a3_people_groupes_box' . '_pro_plugin_page_url', array('People_Category_Manager_Panel', 'get_ultimate_page_url')); global $people_contact_admin_interface; $address_error_class = ''; $message = ''; if (get_option('a3_people_profile_save_failure', 0) == 1) { $address_error_class = 'input_error'; $message = '<div class="message error"><p>' . __('ERROR: A location address must be entered. Please enter a Location Address for this profile.', 'cup_cp') . '</p></div>'; delete_option('a3_people_profile_save_failure'); } $bt_type = 'add_new_contact'; $bt_value = __('Create', 'cup_cp'); $title = __('Add New Profile', 'cup_cp'); $center_address = 'Australia'; $center_lat = -25.155123773636443; $center_lng = 133.77513599999997; $latlng_center = $latlng = $center_lat . ',' . $center_lng; $bt_cancel = '<input type="button" class="button" onclick="window.location=\'admin.php?page=people-contact-manager\'" value="' . __('Cancel', 'cup_cp') . '" />'; $data = array('c_title' => '', 'c_name' => '', 'c_email' => '', 'c_phone' => '', 'c_fax' => '', 'c_mobile' => '', 'c_website' => '', 'c_address' => '', 'c_latitude' => '', 'c_longitude' => '', 'c_shortcode' => '', 'c_avatar' => '', 'c_attachment_id' => 0, 'c_about' => ''); if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id']) && $_GET['id'] >= 0) { $bt_type = 'update_contact'; $data = People_Contact_Profile_Data::get_row($_GET['id'], '', 'ARRAY_A'); $title = __('Edit Profile', 'cup_cp'); if ((trim($data['c_latitude']) == '' || trim($data['c_longitude']) == '') && trim($data['c_address']) != '') { $googleapis_url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($data['c_address']) . '&sensor=false'; $geodata = file_get_contents($googleapis_url); $geodata = json_decode($geodata); $data['c_latitude'] = $geodata->results[0]->geometry->location->lat; $data['c_longitude'] = $geodata->results[0]->geometry->location->lng; } if (trim($data['c_latitude']) != '' && trim($data['c_longitude']) != '') { $latlng_center = $latlng = $data['c_latitude'] . ',' . $data['c_longitude']; } $bt_value = __('Update', 'cup_cp'); } if (isset($_POST['update_contact']) || isset($_POST['add_new_contact'])) { $data = array_merge($data, $_REQUEST['contact_arr']); } ?> <div id="htmlForm"> <div style="clear:both"></div> <div class="wrap"> <style> .input_error { border-color: #cc0000 !important; } </style> <?php echo $message; ?> <div class="icon32 icon32-a3rev-ui-settings icon32-a3revpeople-contact-settings" id="icon32-a3revpeople-contact-addnew"><br></div><h1><?php echo $title; ?> </h1> <div style="clear:both;"></div> <div class="contact_manager a3rev_panel_container a3rev_custom_panel_container"> <form action="" name="add_conact" id="add_contact" method="post"> <input type="hidden" value="<?php if (isset($_GET['id'])) { echo $_GET['id']; } ?> " id="profile_id" name="contact_arr[profile_id]"> <div class="col-left"> <?php ob_start(); ?> <table class="form-table" style="margin-bottom:0;"> <tbody> <tr valign="top"> <th scope="row"><label for="c_title"><?php _e('Title / Position', 'cup_cp'); ?> </label></th> <td><input type="text" class="regular-text" value="<?php if (isset($data['c_title'])) { esc_attr_e(stripslashes($data['c_title'])); } ?> " id="c_title" name="contact_arr[c_title]"></td> </tr> <tr valign="top"> <th scope="row"><label for="c_name"><?php _e('Name', 'cup_cp'); ?> </label></th> <td><input type="text" class="regular-text" value="<?php if (isset($data['c_name'])) { esc_attr_e(stripslashes($data['c_name'])); } ?> " id="c_name" name="contact_arr[c_name]"></td> </tr> <tr valign="top"> <th scope="row"><label for="c_avatar"><?php _e('Profile Image', 'cup_cp'); ?> </label></th> <td class="profileavatar"> <?php global $people_contact_uploader; ?> <?php echo $people_contact_uploader->upload_input('c_avatar', 'c_avatar', $data['c_avatar'], $data['c_attachment_id'], '', __('Profile Image', 'cup_cp'), '', 'width:100%;', '<div class="description">' . __("Image format .jpg, .png", 'cup_cp') . '</div>'); ?> </td> </tr> </tbody> </table> <?php $settings_html = ob_get_clean(); $people_contact_admin_interface->panel_box($settings_html, array('name' => __('Profile Details', 'cup_cp'), 'desc' => __("Fields left empty will not show on the front end.", 'cup_cp'), 'css' => 'margin-top: 5px', 'id' => 'a3_people_profile_details_box', 'is_box' => true)); ?> <?php ob_start(); ?> <table class="form-table" style="margin-bottom:0;" width="100%"> <tbody> <tr valign="top"> <th scope="row"><label for="c_email"><?php _e('Email', 'cup_cp'); ?> </label></th> <td><input type="text" class="regular-text" value="<?php if (isset($data['c_email'])) { esc_attr_e(stripslashes($data['c_email'])); } ?> " id="c_email" name="contact_arr[c_email]"></td> </tr> <tr valign="top"> <th scope="row"><label for="c_phone"><?php _e('Phone', 'cup_cp'); ?> </label></th> <td><input type="text" class="regular-text" value="<?php if (isset($data['c_phone'])) { esc_attr_e(stripslashes($data['c_phone'])); } ?> " id="c_phone" name="contact_arr[c_phone]"></td> </tr> <tr valign="top"> <th scope="row"><label for="c_fax"><?php _e('Fax', 'cup_cp'); ?> </label></th> <td><input type="text" class="regular-text" value="<?php if (isset($data['c_fax'])) { esc_attr_e(stripslashes($data['c_fax'])); } ?> " id="c_fax" name="contact_arr[c_fax]"></td> </tr> <tr valign="top"> <th scope="row"><label for="c_mobile"><?php _e('Mobile', 'cup_cp'); ?> </label></th> <td><input type="text" class="regular-text" value="<?php if (isset($data['c_mobile'])) { esc_attr_e(stripslashes($data['c_mobile'])); } ?> " id="c_mobile" name="contact_arr[c_mobile]"></td> </tr> <tr valign="top"> <th scope="row"><label for="c_website"><?php _e('Website', 'cup_cp'); ?> </label></th> <td><input type="text" class="regular-text" value="<?php if (isset($data['c_website']) && trim($data['c_website']) != '') { echo esc_url(stripslashes($data['c_website'])); } else { echo 'http://'; } ?> " id="c_website" name="contact_arr[c_website]" onfocus="if (this.value == 'http://') {this.value = '';}" onblur="if (this.value == '') {this.value = 'http://';}" /></td> </tr> <tr valign="top"> <td class="forminp" colspan="2" style="padding-left:0;"> <div class="row_mod" ><label for="c_website"><?php _e('About', 'cup_cp'); ?> </label></div> <?php wp_editor(stripslashes($data['c_about']), 'c_about', array('textarea_name' => 'contact_arr[c_about]', 'wpautop' => true, 'textarea_rows' => 8)); ?> </td> </tr> </tbody> </table> <?php $settings_html = ob_get_clean(); $people_contact_admin_interface->panel_box($settings_html, array('name' => __('Contact Details', 'cup_cp'), 'desc' => __("Fields left empty will not show on the front end.", 'cup_cp'), 'id' => 'a3_people_contact_details_box', 'is_box' => true)); ?> <?php ob_start(); ?> <table class="form-table" style="margin-bottom:0;"> <tbody> <tr valign="top"> <th scope="row"><label for="show_on_main_page"><?php _e('Contact Page Display', 'cup_cp'); ?> </label></th> <td> <?php if (!isset($data['show_on_main_page'])) { $data['show_on_main_page'] = 1; } ?> <input id="show_on_main_page" name="contact_arr[show_on_main_page]" class="a3rev-ui-onoff_checkbox show_on_main_page" checked_label="<?php _e('ON', 'cup_cp'); ?> " unchecked_label="<?php _e('OFF', 'cup_cp'); ?> " type="checkbox" value="1" <?php checked(1, $data['show_on_main_page'], true); ?> /> </td> </tr> </tbody> </table> <div class="show_marker_on_main_map_container" style="<?php if (1 != $data['show_on_main_page']) { echo 'visibility:hidden; height: 0px; overflow: hidden; margin-bottom: 0px;'; } ?> " > <table class="form-table" style="margin-bottom:0;"> <tbody> <tr valign="top"> <th scope="row"><label for="enable_map_marker"><?php _e('Show on Contact Page map', 'cup_cp'); ?> </label></th> <td> <?php if (!isset($data['enable_map_marker'])) { $data['enable_map_marker'] = 1; } ?> <input id="enable_map_marker" name="contact_arr[enable_map_marker]" class="a3rev-ui-onoff_checkbox enable_map_marker" checked_label="<?php _e('ON', 'cup_cp'); ?> " unchecked_label="<?php _e('OFF', 'cup_cp'); ?> " type="checkbox" value="1" <?php checked(1, $data['enable_map_marker'], true); ?> /> <span class="description"><?php echo __('ON to show this Profile on the Contact Page map', 'cup_cp'); ?> </span> </td> </tr> </tbody> </table> </div> <?php $settings_html = ob_get_clean(); $people_contact_admin_interface->panel_box($settings_html, array('name' => __('Contact Page Profile', 'cup_cp'), 'desc' => __('Switch OFF and this profile will not show on the main Contact Us Page but still can be inserted by shortcode (Pro and Ultimate Versions) and assigned to groups (Ultimate Version) that are inserted by shortcode.', 'cup_cp'), 'id' => 'a3_people_contact_page_profile_box', 'is_box' => true)); ?> <div> <?php ob_start(); ?> <table class="form-table" style="margin-bottom:0;"> <tr valign="top"> <th scope="row"><label for="c_shortcode"><?php _e('Enter Form Shortcode', 'cup_cp'); ?> </label></th> <td> <input type="text" class="regular-text" value="" id="c_shortcode" name="contact_arr[c_shortcode]"></td> </tr> </tbody> </table> <?php $settings_html = ob_get_clean(); $people_contact_admin_interface->panel_box($settings_html, array('name' => __('Contact Form by Shortcode', 'cup_cp'), 'desc' => sprintf(__('Add a unique Contact Form for this profile. Supports Contact Form 7 or Gravity Forms plugin shortcodes. Feature must be switched <a href="%s" target="_blank">ON here</a> + Contact Form Type > Create Form by Shortcode switch.', 'cup_cp'), admin_url('admin.php?page=people-contact-settings&tab=email-inquiry')), 'class' => 'pro_feature_fields', 'id' => 'a3_people_contact_form_shortcode_box', 'is_box' => true)); ?> </div> <div class="categories_selection_container"> <?php ob_start(); ?> <div class="categories_selection"> <?php $all_categories = array(array('id' => 1, 'category_name' => __('Profile Group', 'cup_cp'))); if (is_array($all_categories) && count($all_categories) > 0) { foreach ($all_categories as $category_data) { ?> <div style="float:left; width:100%; margin-bottom:10px;"> <input name="categories_assign[]" class="a3rev-ui-onoff_checkbox" checked_label="<?php _e('YES', 'cup_cp'); ?> " unchecked_label="<?php _e('NO', 'cup_cp'); ?> " type="checkbox" value="<?php echo $category_data['id']; ?> " /> <?php esc_attr_e(stripslashes($category_data['category_name'])); ?> </div> <div style="clear:both"></div> <?php } } else { _e('No Groups', 'cup_cp'); } ?> </div> <?php $settings_html = ob_get_clean(); $people_contact_admin_interface->panel_box($settings_html, array('name' => __('Assign Profile to Groups', 'cup_cp'), 'desc' => __('Use the ON | OFF switches to assign this profile to any number of Groups', 'cup_cp'), 'class' => 'pro_feature_fields', 'id' => 'a3_people_groupes_box', 'is_box' => true)); ?> </div> </div> <div class="col-right"> <?php ob_start(); ?> <table class="form-table" style="margin-bottom:0;"> <tbody> <tr valign="top"> <th scope="row"><label for="c_address"><?php _e('Address', 'cup_cp'); ?> </label></th> <td><input type="text" class="regular-text <?php echo $address_error_class; ?> " value="<?php if (isset($data['c_address'])) { esc_attr_e(stripslashes($data['c_address'])); } ?> " id="c_address" name="contact_arr[c_address]"></td> </tr> <tr valign="top"> <th scope="row"><label for="c_latitude"><?php _e('Latitude', 'cup_cp'); ?> </label></th> <td><input type="text" readonly="readonly" class="regular-text" value="<?php if (isset($data['c_latitude'])) { echo $data['c_latitude']; } ?> " id="c_latitude" name="contact_arr[c_latitude]"></td> </tr> <tr valign="top"> <th scope="row"><label for="c_longitude"><?php _e('Longitude', 'cup_cp'); ?> </label></th> <td><input type="text" readonly="readonly" class="regular-text" value="<?php if (isset($data['c_longitude'])) { echo $data['c_longitude']; } ?> " id="c_longitude" name="contact_arr[c_longitude]"></td> </tr> <tr> <th></th> <td> <div style="font-size: 13px;"><?php echo __('* <strong>Tip</strong> - drag and drop the map marker to the required location', 'cup_cp'); ?> </div> <div class="maps_content" style="padding:10px 0px;"> <div id="map_canvas"></div> </div> </td> </tr> </tbody> </table> <?php $settings_html = ob_get_clean(); $people_contact_admin_interface->panel_box($settings_html, array('name' => __('Profile Location Address', 'cup_cp'), 'desc' => __('<strong>REQUIRED</strong>: All profiles must have a map location set. The location set here is used for this profile on the Contact Us Page map (optional) and any Group map (optional) that the profile has been assigned to.', 'cup_cp'), 'id' => 'a3_people_location_address_box', 'is_box' => true, 'alway_open' => true)); ?> <div style="clear:both"></div> </div> <div style="clear:both"></div> <script type="text/javascript" > <?php $map_type = $people_contact_location_map_settings['map_type']; if ($map_type == '') { $map_type = 'ROADMAP'; } $zoom_level = 1; if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id']) && $_GET['id'] >= 0) { $zoom_level = $people_contact_location_map_settings['zoom_level']; if ($zoom_level <= 0) { $zoom_level = 1; } } ?> var geocoder; var map; var marker; function initialize(){ //MAP var latlng = new google.maps.LatLng(<?php echo $latlng; ?> ); var latlng_center = new google.maps.LatLng(<?php echo $latlng_center; ?> ); var options = { zoom: <?php echo $zoom_level; ?> , center: latlng_center, mapTypeId: google.maps.MapTypeId.<?php echo $map_type; ?> }; map = new google.maps.Map(document.getElementById("map_canvas"), options); //GEOCODER geocoder = new google.maps.Geocoder(); marker = new google.maps.Marker({ map: map, draggable: true, position: latlng }); } jQuery(document).ready(function ($) { initialize(); function a3_people_reload_map() { var current_lat = $("#c_latitude").val(); var current_lng = $("#c_longitude").val(); if ( current_lat != '' && current_lng != '' ) { var current_center = new google.maps.LatLng(current_lat, current_lng); } else { var current_center = new google.maps.LatLng(<?php echo $latlng_center; ?> ); } google.maps.event.trigger(map, "resize"); //this fix the problem with not completely map map.setCenter(current_center); } $(document).on( "a3rev-ui-onoff_checkbox-switch", '.show_on_main_page', function( event, value, status ) { $(".show_marker_on_main_map_container").attr('style','display:none;'); if ( status == 'true' ) { $(".show_marker_on_main_map_container").slideDown(); } else { $(".show_marker_on_main_map_container").slideUp(); } }); $(document).on('click', '.a3-plugin-ui-panel-box', function(){ //if ( $(this).hasClass('google_map_canvas_resized') || $(this).hasClass('box_open') ) return; //we have to set center for map after resize, but we need to know center BEFORE we resize it setTimeout( function() { a3_people_reload_map(); }, 600 ); $(this).addClass('google_map_canvas_resized'); }); $("#c_address").focus(function() { $(this).removeClass('input_error'); }); $(function() { $("#c_address").autocomplete({ //This bit uses the geocoder to fetch address values source: function(request, response) { geocoder.geocode( {'address': request.term }, function(results, status) { response($.map(results, function(item) { return { label: item.formatted_address, value: item.formatted_address, latitude: item.geometry.location.lat(), longitude: item.geometry.location.lng() } })); }) }, //This bit is executed upon selection of an address select: function(event, ui) { $("#c_latitude").val(ui.item.latitude); $("#c_longitude").val(ui.item.longitude); var location = new google.maps.LatLng(ui.item.latitude, ui.item.longitude); marker.setPosition(location); map.setCenter(location); } }); }); //Add listener to marker for reverse geocoding google.maps.event.addListener(marker, 'drag', function() { geocoder.geocode({'latLng': marker.getPosition()}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[0]) { $('#c_address').removeClass('input_error').val(results[0].formatted_address); $('#c_latitude').val(marker.getPosition().lat()); $('#c_longitude').val(marker.getPosition().lng()); } } }); }); google.maps.event.addListener(marker, 'dragend', function() { map.setCenter(marker.getPosition()); }); }); </script> <div style="clear:both"></div> <p class="submit" style="margin-bottom:0;padding-bottom:0;"> <input type="hidden" value="<?php echo $bt_type; ?> " name="<?php echo $bt_type; ?> " /> <input type="submit" value="<?php echo $bt_value; ?> " class="button button-primary" id="add_edit_buttom" name="add_edit_buttom"> <?php echo $bt_cancel; ?> </p> </form> </div> <div style="clear:both"></div> </div> <div style="clear:both"></div> </div> <?php }