Example #1
0
/**
 * Call this function when plugin is deactivated
 */
function people_contact_install()
{
    update_option('a3rev_wp_people_contact_lite_version', '2.1.0');
    update_option('a3rev_wp_people_contact_version', '2.1.0');
    update_option('a3rev_wp_people_contact_ultimate_version', '2.1.0');
    $contact_us_page_id = People_Contact_Functions::create_page(esc_sql('contact-us-page'), 'contact_us_page_id', __('Contact Us Page', 'cup_cp'), '[people_contacts]');
    People_Contact_Functions::auto_create_page_for_wpml($contact_us_page_id, _x('contact-us-page', 'page_slug', 'cup_cp'), __('Contact Us Page', 'cup_cp'), '[people_contacts]');
    People_Contact_Profile_Data::install_database();
    // Set Settings Default from Admin Init
    global $people_contact_admin_init;
    $people_contact_admin_init->set_default_settings();
    delete_metadata('user', 0, $people_contact_admin_init->plugin_name . '-' . 'plugin_framework_global_box' . '-' . 'opened', '', true);
    // Build sass
    global $a3_people_contact_less;
    $a3_people_contact_less->plugin_build_sass();
    update_option('a3rev_wp_people_contact_just_installed', true);
}
Example #2
0
 public function send_a_contact()
 {
     $profile_email = trim($_REQUEST['profile_email']);
     $profile_name = trim($_REQUEST['profile_name']);
     $c_name = trim($_REQUEST['c_name']);
     $c_email = trim($_REQUEST['c_email']);
     $c_phone = trim($_REQUEST['c_phone']);
     $c_message = trim($_REQUEST['c_message']);
     $send_copy = $_REQUEST['send_copy'];
     if (trim($_REQUEST['c_subject']) != '') {
         $subject = trim($_REQUEST['c_subject']) . ' ' . people_ict_t__('Email Inquiry - from', __('from', 'cup_cp')) . ' ' . (function_exists('icl_t') ? icl_t('WP', __('Blog Title', 'wpml-string-translation'), get_option('blogname')) : get_option('blogname'));
     } else {
         $subject = people_ict_t__('Email Inquiry - Contact from', __('Contact from', 'cup_cp')) . ' ' . (function_exists('icl_t') ? icl_t('WP', __('Blog Title', 'wpml-string-translation'), get_option('blogname')) : get_option('blogname'));
     }
     $profile_data = array('subject' => $subject, 'to_email' => $profile_email, 'profile_name' => $profile_name, 'profile_email' => $profile_email, 'contact_name' => $c_name, 'contact_email' => $c_email, 'contact_phone' => $c_phone, 'message' => $c_message);
     $email_result = People_Contact_Functions::contact_to_people($profile_data, $send_copy);
     echo $email_result;
     die;
 }
    public static function widget_contact_form($widget_id = 0)
    {
        global $people_contact_widget_information, $people_contact_widget_maps, $people_contact_grid_view_icon, $people_contact_widget_email_contact_form, $people_contact_widget_content_before_maps, $people_contact_widget_content_after_maps;
        $enable_widget_send_copy = true;
        if ($people_contact_widget_email_contact_form['widget_send_copy'] == 'no') {
            $enable_widget_send_copy = false;
        }
        $nameError = '';
        $emailError = '';
        $contactError = '';
        //If the form is submitted
        if (isset($_POST['submitted'])) {
            //Check to make sure that the name field is not empty
            if (trim($_POST['contactName']) === '') {
                $nameError = __('You forgot to enter your name.', 'cup_cp');
                $hasError = true;
            } else {
                $name = trim($_POST['contactName']);
            }
            //Check to make sure sure that a valid email address is submitted
            if (trim($_POST['email']) === '') {
                $emailError = __('You forgot to enter your email address.', 'cup_cp');
                $hasError = true;
            } else {
                if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\$", trim($_POST['email']))) {
                    $emailError = __('You entered an invalid email address.', 'cup_cp');
                    $hasError = true;
                } else {
                    $email = trim($_POST['email']);
                }
            }
            //Check to make sure comments were entered
            if (trim($_POST['comments']) === '') {
                $contactError = __('You forgot to enter your comments.', 'cup_cp');
                $hasError = true;
            } else {
                $comments = stripslashes(trim($_POST['comments']));
            }
            //If there is no error, send the email
            if (!isset($hasError)) {
                $emailTo = $people_contact_widget_information['widget_info_email'];
                $subject = __('Contact Form Submission from', 'cup_cp') . ' ' . $name;
                $contact_data = array('subject' => $subject, 'to_email' => $emailTo, 'contact_name' => $name, 'contact_email' => $email, 'message' => $comments);
                $send_copy_yourself = 0;
                if (isset($_POST['sendCopy'])) {
                    $send_copy_yourself = 1;
                }
                $email_result = People_Contact_Functions::contact_to_site($contact_data, $send_copy_yourself);
                $emailSent = true;
            }
        }
        ?>
		<script type="text/javascript">
			<!--//--><![CDATA[//><!--
			jQuery(document).ready(function() {
				jQuery( 'form#contactForm').submit(function() {
					jQuery( 'form#contactForm .error').remove();
					jQuery( 'form#contactForm input.submit').attr('disabled', 'disabled');
					var hasError = false;
					jQuery( '.requiredField').each(function() {
						if(jQuery.trim(jQuery(this).val()) == '') {
							var labelText = jQuery(this).prev( 'label').text();
							jQuery(this).parent().append( '<span class="error"><?php 
        _e('You forgot to enter your', 'cup_cp');
        ?>
 '+labelText+'.</span>' );
							jQuery(this).addClass( 'inputError' );
							hasError = true;
						} else if(jQuery(this).hasClass( 'email')) {
							var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
							if(!emailReg.test(jQuery.trim(jQuery(this).val()))) {
								var labelText = jQuery(this).prev( 'label').text();
								jQuery(this).parent().append( '<span class="error"><?php 
        _e('You entered an invalid', 'cup_cp');
        ?>
 '+labelText+'.</span>' );
								jQuery(this).addClass( 'inputError' );
								hasError = true;
							}
						}
					});
					if(!hasError) {
						jQuery(this).find('.contact-site-ajax-wait').show();
						var formInput = jQuery(this).serialize();
						jQuery.post(jQuery(this).attr( 'action'),formInput, function(data){
							jQuery( 'form#contactForm').slideUp( "fast", function() {
								jQuery(this).before( '<p class="tick"><?php 
        _e('<strong>Thanks!</strong> Your email was successfully sent.', 'cup_cp');
        ?>
</p>' );
							});
						});
					} else {
						jQuery( 'form#contactForm input.submit').removeAttr('disabled');
					}

					return false;

				});
			});
			//-->!]]>
			</script>
            <div class="people_contact_widget_container">
	            <?php 
        if ($people_contact_widget_content_before_maps != '') {
            ?>
	            <div class="content_before_maps"><?php 
            echo wpautop(wptexturize(stripslashes($people_contact_widget_content_before_maps)));
            ?>
</div>
	            <?php 
        }
        ?>
				<?php 
        $geocoords = $people_contact_widget_maps['widget_location'];
        ?>
				<?php 
        if ($geocoords != '') {
            ?>
				<div style="clear:both;"></div>
				<?php 
            People_Contact_Widget::widget_maps_contact_output("geocoords={$geocoords}");
            ?>
				<?php 
        }
        ?>
	            <?php 
        if ($people_contact_widget_content_after_maps != '') {
            ?>
	            <div style="clear:both;"></div>
	            <div class="content_after_maps"><?php 
            echo wpautop(wptexturize(stripslashes($people_contact_widget_content_after_maps)));
            ?>
</div>
	            <?php 
        }
        ?>
				<?php 
        $phone_icon = PEOPLE_CONTACT_IMAGE_URL . '/p_icon_phone.png';
        $fax_icon = PEOPLE_CONTACT_IMAGE_URL . '/p_icon_fax.png';
        $mobile_icon = PEOPLE_CONTACT_IMAGE_URL . '/p_icon_mobile.png';
        $email_icon = PEOPLE_CONTACT_IMAGE_URL . '/p_icon_email.png';
        if (isset($emailSent) && $emailSent == true) {
            ?>
					<p class="info">
					  <?php 
            _e('Your email was successfully sent.', 'cup_cp');
            ?>
					</p>
				<?php 
        } else {
            ?>
					<div style="clear:both;"></div>
					<div class="location-twitter">
					  <section id="office-location">
						<ul>
						  <?php 
            if (isset($people_contact_widget_information['widget_info_address']) && $people_contact_widget_information['widget_info_address'] != '') {
                ?>
						  <li><h4 style="margin-bottom:10px;"><?php 
                echo $people_contact_widget_information['widget_info_address'];
                ?>
</h4></li>
						  <?php 
            }
            ?>
						  <?php 
            if (isset($people_contact_widget_information['widget_info_phone']) && $people_contact_widget_information['widget_info_phone'] != '') {
                ?>
						  <li>
							<span><img src="<?php 
                echo $phone_icon;
                ?>
" /></span><?php 
                _e('Phone:', 'cup_cp');
                ?>
							<?php 
                echo $people_contact_widget_information['widget_info_phone'];
                ?>
</li>
						  <?php 
            }
            ?>
						  <?php 
            if (isset($people_contact_widget_information['widget_info_fax']) && $people_contact_widget_information['widget_info_fax'] != '') {
                ?>
						  <li>
							<span><img src="<?php 
                echo $fax_icon;
                ?>
" /></span><?php 
                _e('Fax:', 'cup_cp');
                ?>
							<?php 
                echo $people_contact_widget_information['widget_info_fax'];
                ?>
</li>
						  <?php 
            }
            ?>
	                      <?php 
            if (isset($people_contact_widget_information['widget_info_mobile']) && $people_contact_widget_information['widget_info_mobile'] != '') {
                ?>
						  <li>
							<span><img src="<?php 
                echo $mobile_icon;
                ?>
" /></span><?php 
                _e('Mobile:', 'cup_cp');
                ?>
							<?php 
                echo $people_contact_widget_information['widget_info_mobile'];
                ?>
</li>
						  <?php 
            }
            ?>
						  <?php 
            if (isset($people_contact_widget_information['widget_info_email']) && $people_contact_widget_information['widget_info_email'] != '') {
                ?>
						  <li>
							<span><img src="<?php 
                echo $email_icon;
                ?>
" /></span><?php 
                _e('Email:', 'cup_cp');
                ?>
							<a href="mailto:<?php 
                echo $people_contact_widget_information['widget_info_email'];
                ?>
"><?php 
                echo $people_contact_widget_information['widget_info_email'];
                ?>
</a></li>
						  <?php 
            }
            ?>
						</ul>
					  </section>
					  <div class="clear"></div>
					</div>
					<!-- /.location-twitter -->
					<?php 
            if ($people_contact_widget_email_contact_form['widget_show_contact_form'] != 1 && trim($people_contact_widget_email_contact_form['widget_input_shortcode']) != '') {
                echo '<div class="clear" style="clear:both;"></div><div class="people_widget_shortcode">';
                $widget_input_shortcode = htmlspecialchars_decode($people_contact_widget_email_contact_form['widget_input_shortcode']);
                echo do_shortcode($widget_input_shortcode);
                echo '</div><div class="clear" style="clear:both;"></div>';
            }
            if ($people_contact_widget_email_contact_form['widget_show_contact_form'] == 1) {
                ?>
					<?php 
                if (isset($hasError)) {
                    ?>
					<p class="alert">
					  <?php 
                    _e('There was an error submitting the form.', 'cup_cp');
                    ?>
					</p>
					<?php 
                }
                ?>
					<form action="<?php 
                the_permalink();
                ?>
" id="contactForm" method="post">
					  <ol class="forms">
						<li>
						  <label for="contactName">
							<?php 
                _e('Name', 'cup_cp');
                ?>
 <span class="require">*</span>
						  </label>
						  <input type="text" name="contactName" id="contactName" value="<?php 
                if (isset($_POST['contactName'])) {
                    echo esc_attr($_POST['contactName']);
                }
                ?>
" class="txt requiredField" />
						  <?php 
                if ($nameError != '') {
                    ?>
						  <span class="error"><?php 
                    echo $nameError;
                    ?>
</span>
						  <?php 
                }
                ?>
						</li>
						<li>
						  <label for="email">
							<?php 
                _e('Email', 'cup_cp');
                ?>
 <span class="require">*</span>
						  </label>
						  <input type="text" name="email" id="email" value="<?php 
                if (isset($_POST['email'])) {
                    echo esc_attr($_POST['email']);
                }
                ?>
" class="txt requiredField email" />
						  <?php 
                if ($emailError != '') {
                    ?>
						  <span class="error"><?php 
                    echo $emailError;
                    ?>
</span>
						  <?php 
                }
                ?>
						</li>
						<li class="textarea">
						  <label for="commentsText">
							<?php 
                _e('Message', 'cup_cp');
                ?>
 <span class="require">*</span>
						  </label>
						  <textarea name="comments" id="commentsText" rows="5" class="requiredField"><?php 
                if (isset($_POST['comments'])) {
                    echo esc_textarea($_POST['comments']);
                }
                ?>
</textarea>
						  <?php 
                if ($contactError != '') {
                    ?>
						  <span class="error"><?php 
                    echo $contactError;
                    ?>
</span>
						  <?php 
                }
                ?>
						</li>
						<?php 
                if ($enable_widget_send_copy) {
                    ?>
						<li class="inline">
	                     <label>
						  <span for="sendCopy">
	                      	<input type="checkbox" name="sendCopy" id="sendCopy" value="true"<?php 
                    if (isset($_POST['sendCopy']) && $_POST['sendCopy'] == true) {
                        echo ' checked="checked"';
                    }
                    ?>
 />
							<?php 
                    _e('Send a copy of this email to yourself', 'cup_cp');
                    ?>
						  </span>
						 </label>
	                    </li>
	                    <?php 
                }
                ?>
						<li class="buttons">
						  <input type="hidden" name="submitted" id="submitted" value="true" />
						  <input class="submit button" type="submit" value="<?php 
                esc_attr_e('Send', 'cup_cp');
                ?>
" /> <img class="contact-site-ajax-wait" src="<?php 
                echo PEOPLE_CONTACT_IMAGE_URL;
                ?>
/ajax-loader2.gif" border="0" style="display:none; padding:0; margin:0; vertical-align: middle;" />
						</li>
					  </ol>
					</form>
			<?php 
            }
        }
        ?>
		</div>
		<?php 
    }
 public static function auto_create_page_for_wpml($original_id, $slug, $page_title = '', $page_content = '')
 {
     if (class_exists('SitePress')) {
         global $sitepress;
         $active_languages = $sitepress->get_active_languages();
         if (is_array($active_languages) && count($active_languages) > 0) {
             $source_lang_code = $sitepress->get_default_language();
             $trid = $sitepress->get_element_trid($original_id, 'post_page');
             foreach ($active_languages as $language) {
                 if ($language['code'] == $source_lang_code) {
                     continue;
                 }
                 People_Contact_Functions::create_page_wpml($trid, $language['code'], $source_lang_code, $slug . '-' . $language['code'], $page_title . ' ' . $language['display_name'], $page_content);
             }
         }
     }
 }
    public function people_contact_generator_popup()
    {
        global $people_contact_location_map_settings;
        $contacts = People_Contact_Profile_Data::get_results('show_on_main_page=1', 'c_order ASC', '', 'ARRAY_A');
        $all_categories = array(array('id' => 1, 'category_name' => __('Profile Group', 'cup_cp')));
        ?>
		<div id="people-contact-wrap" style="display:none">
        <div class="people-shortcode-popup-container">
        <div id="a3_plugin_shortcode_upgrade_area"><div class="a3-people-contact-logo-extensions"></div><?php 
        echo People_Contact_Functions::extension_shortcode();
        ?>
            <fieldset style="border:1px solid #DFDFDF; padding:0 20px; background: #FFF;  margin:10px;"><legend style="font-weight:bold; font-size:14px;"><?php 
        _e('Insert Single Profile', 'cup_cp');
        ?>
</legend>
            <div id="people-contact-content" class="people-contact-content people-contact-shortcode-container" style="text-align:left;">
            <p><label for="people_contact_item"><?php 
        _e('Select people', 'cup_cp');
        ?>
:</label> 
                <select style="width:250px" id="people_contact_item" name="people_contact_item">
                <?php 
        echo '<option value="">' . __('Please select...', 'cup_cp') . '</option>';
        if (is_array($contacts) && count($contacts) > 0) {
            foreach ($contacts as $key => $value) {
                $profile_name = trim(esc_attr(stripslashes($value['c_name'])));
                if ($profile_name == '') {
                    $profile_name = trim(esc_attr(stripslashes($value['c_title'])));
                }
                echo '<option value="' . $value['id'] . '">' . $profile_name . '</option>';
            }
        }
        ?>
                </select> <img class="people_contact_item_loader" style="display:none;" src="<?php 
        echo PEOPLE_CONTACT_IMAGE_URL;
        ?>
/ajax-loader.gif" border=0 />
            </p>
            
            <p><label for="people_contact_align"><?php 
        _e('Card Alignment', 'cup_cp');
        ?>
:</label> <select style="width:120px" id="people_contact_align" name="people_contact_align"><option value="none" selected="selected"><?php 
        _e('None', 'cup_cp');
        ?>
</option><option value="left-wrap"><?php 
        _e('Left - wrap', 'cup_cp');
        ?>
</option><option value="left"><?php 
        _e('Left - no wrap', 'cup_cp');
        ?>
</option><option value="center"><?php 
        _e('Center', 'cup_cp');
        ?>
</option><option value="right-wrap"><?php 
        _e('Right - wrap', 'cup_cp');
        ?>
</option><option value="right"><?php 
        _e('Right - no wrap', 'cup_cp');
        ?>
</option></select> <span class="description"><?php 
        _e('Wrap is text wrap like images', 'cup_cp');
        ?>
</span></p>
				<p><label for="people_contact_item_width"><?php 
        _e('Card Width', 'cup_cp');
        ?>
:</label> <input disabled="disabled" style="width:50px;" size="10" id="people_contact_item_width" name="people_contact_item_width" type="text" value="300" />px</p>
				<p><label for=""><strong><?php 
        _e('Card External Padding', 'cup_cp');
        ?>
</strong>:</label><br /> 
					<label for="people_contact_padding_top" style="width:auto; float:none"><?php 
        _e('Above', 'cup_cp');
        ?>
:</label><input  disabled="disabled" style="width:50px;" size="10" id="people_contact_padding_top" name="people_contact_padding_top" type="text" value="10" />px &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                	<label for="people_contact_padding_bottom" style="width:auto; float:none"><?php 
        _e('Below', 'cup_cp');
        ?>
:</label> <input disabled="disabled" style="width:50px;" size="10" id="people_contact_padding_bottom" name="people_contact_padding_bottom" type="text" value="10" />px &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                	<label for="people_contact_padding_left" style="width:auto; float:none"><?php 
        _e('Left', 'cup_cp');
        ?>
:</label> <input disabled="disabled" style="width:50px;" size="10" id="people_contact_padding_left" name="people_contact_padding_left" type="text" value="0" />px &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                	<label for="people_contact_padding_right" style="width:auto; float:none"><?php 
        _e('Right', 'cup_cp');
        ?>
:</label> <input disabled="disabled" style="width:50px;" size="10" id="people_contact_padding_right" name="people_contact_padding_right" type="text" value="0" />px
                </p>
           
            
			</div>
            <div style="clear:both;height:0px"></div>
            <p><input disabled="disabled" type="button" class="button button-primary" value="<?php 
        _e('Insert Shortcode', 'cup_cp');
        ?>
" /> 
            <input type="button" class="button" onclick="tb_remove(); return false;" value="<?php 
        _e('Cancel', 'cup_cp');
        ?>
" />
			</p>
            </fieldset>
            </div>
            
            <div id="a3_plugin_shortcode_upgrade_area"><div class="a3-people-contact-logo-extensions"></div><?php 
        echo People_Contact_Functions::ultimate_extension_shortcode();
        ?>
            <fieldset style="border:1px solid #DFDFDF; padding:0 20px; background: #FFF; margin:10px;"><legend style="font-weight:bold; font-size:14px;"><?php 
        _e('Insert Group', 'cup_cp');
        ?>
</legend>
            <div id="people-category-content" class="people-category-content people-contact-shortcode-container" style="text-align:left;">
                <p><label for="profile_category_id"><?php 
        _e('Select Group', 'cup_cp');
        ?>
:</label> 
                    <select style="width:250px" id="profile_category_id" name="profile_category_id">
                    <?php 
        echo '<option value="">' . __('Please select...', 'cup_cp') . '</option>';
        if (is_array($all_categories) && count($all_categories) > 0) {
            foreach ($all_categories as $category_data) {
                echo '<option value="' . $category_data['id'] . '">' . trim(esc_attr(stripslashes($category_data['category_name']))) . '</option>';
            }
        }
        ?>
                    </select>
                </p>
            
                <p><label for="profile_category_column"><?php 
        _e('Profile Cards / Row', 'cup_cp');
        ?>
:</label> 
                	<select style="width:120px" id="profile_category_column" name="profile_category_column">
                    <?php 
        echo '<option value="">' . __('Please select...', 'cup_cp') . '</option>';
        echo '<option value="1">1 ' . __('Card', 'cup_cp') . ' </option>';
        for ($column = 2; $column <= 5; $column++) {
            echo '<option value="' . $column . '">' . $column . ' ' . __('Cards', 'cup_cp') . ' </option>';
        }
        ?>
                    </select> <span class="description"><?php 
        _e('Empty to use global settings.', 'cup_cp');
        ?>
</span>
				</p>
                <p><label for="enable_google_map"><?php 
        _e('Google Map', 'cup_cp');
        ?>
:</label> <input disabled="disabled" type="checkbox" id="enable_google_map" name="enable_google_map" value="1" <?php 
        if ($people_contact_location_map_settings['hide_maps_frontend'] != 1) {
            echo 'checked="checked"';
        }
        ?>
 /> <span><?php 
        _e('Check to enable google location map for this group.', 'cup_cp');
        ?>
</span>
                </p>
                <p><label for="people_show_group_title"><?php 
        _e('Group Title', 'cup_cp');
        ?>
:</label> <input disabled="disabled" type="checkbox" id="people_show_group_title" name="people_show_group_title" value="1" checked="checked" /> <span><?php 
        _e('Check to show group title above Profiles.', 'cup_cp');
        ?>
</span>
                </p>
				
			</div>
            <div style="clear:both;height:0px"></div>
            <p><input disabled="disabled" type="button" class="button button-primary" value="<?php 
        _e('Insert Shortcode', 'cup_cp');
        ?>
" /> 
            <input type="button" class="button" onclick="tb_remove(); return false;" value="<?php 
        _e('Cancel', 'cup_cp');
        ?>
" />
			</p>
            </fieldset>
            </div>
        </div>
        </div>
        <style type="text/css">
		.people_value{position:relative;top:-2px;}
        .people_item {margin-right:5%;}
        </style>
		<?php 
    }