function cntctfrm_admin_init() { global $bws_plugin_info, $cntctfrm_plugin_info; /* Add variable for bws_menu */ $cntctfrm_plugin_info = get_plugin_data(__FILE__); if (!isset($bws_plugin_info) || empty($bws_plugin_info)) { $bws_plugin_info = array('id' => '77', 'version' => $cntctfrm_plugin_info["Version"]); } /* Call register settings function */ cntctfrm_settings(); /* Function check if plugin is compatible with current WP version */ cntctfrm_version_check(); }
function cntctfrm_activation($networkwide) { global $wpdb; if (function_exists('is_multisite') && is_multisite() && $networkwide) { $cntctfrm_blog_id = $wpdb->blogid; $cntctfrm_get_blogids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}"); foreach ($cntctfrm_get_blogids as $blog_id) { switch_to_blog($blog_id); cntctfrm_settings(); cntctfrm_db_create(); } switch_to_blog($cntctfrm_blog_id); return; } else { cntctfrm_settings(); cntctfrm_db_create(); } }
function cntctfrm_display_form($atts = array('lang' => 'en')) { global $error_message, $cntctfrm_options, $cntctfrm_result, $cntctfrmmlt_ide, $cntctfrmmlt_active_plugin, $cntctfrm_form_count; $cntctfrm_form_count = empty($cntctfrm_form_count) ? 1 : ++$cntctfrm_form_count; $cntctfrm_form_countid = $cntctfrm_form_count == 1 ? '' : '_' . $cntctfrm_form_count; $content = ""; /* Get options for the form with a definite identifier */ require_once ABSPATH . 'wp-admin/includes/plugin.php'; if (is_plugin_active('contact-form-multi/contact-form-multi.php') || is_plugin_active('contact-form-multi-pro/contact-form-multi-pro.php')) { if (!get_option('cntctfrmmlt_options')) { cntctfrm_settings(); } extract(shortcode_atts(array('id' => $cntctfrmmlt_ide, 'lang' => 'en'), $atts)); if (isset($atts['id'])) { $cntctfrm_options = get_option('cntctfrmmlt_options_' . $atts['id']); /* if no options with the specified id */ if (!$cntctfrm_options) { $cntctfrm_options = get_option('cntctfrmmlt_options'); } } else { $cntctfrm_options = get_option('cntctfrmmlt_options'); } } else { $cntctfrm_options = get_option('cntctfrm_options'); extract(shortcode_atts(array('lang' => 'en'), $atts)); } /* check lang and replace with en default if need */ foreach ($cntctfrm_options as $key => $value) { if (is_array($value) && array_key_exists('en', $value) && (!array_key_exists($lang, $value) || isset($cntctfrm_options[$key][$lang]) && $cntctfrm_options[$key][$lang] == '')) { $cntctfrm_options[$key][$lang] = $cntctfrm_options[$key]['en']; } } $page_url = esc_url(add_query_arg(array()) . '#cntctfrm_contact_form'); /* If contact form submited */ $cntctfrm_form_submited = isset($_POST['cntctfrm_form_submited']) ? $_POST['cntctfrm_form_submited'] : 0; $name = isset($_POST['cntctfrm_contact_name']) && $cntctfrm_form_count == $cntctfrm_form_submited ? htmlspecialchars(stripslashes($_POST['cntctfrm_contact_name'])) : ""; $address = isset($_POST['cntctfrm_contact_address']) && $cntctfrm_form_count == $cntctfrm_form_submited ? htmlspecialchars(stripslashes($_POST['cntctfrm_contact_address'])) : ""; $email = isset($_POST['cntctfrm_contact_email']) && $cntctfrm_form_count == $cntctfrm_form_submited ? htmlspecialchars(stripslashes($_POST['cntctfrm_contact_email'])) : ""; $subject = isset($_POST['cntctfrm_contact_subject']) && $cntctfrm_form_count == $cntctfrm_form_submited ? htmlspecialchars(stripslashes($_POST['cntctfrm_contact_subject'])) : ""; $message = isset($_POST['cntctfrm_contact_message']) && $cntctfrm_form_count == $cntctfrm_form_submited ? htmlspecialchars(stripslashes($_POST['cntctfrm_contact_message'])) : ""; $phone = isset($_POST['cntctfrm_contact_phone']) && $cntctfrm_form_count == $cntctfrm_form_submited ? htmlspecialchars(stripslashes($_POST['cntctfrm_contact_phone'])) : ""; $name = strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $name))); $address = strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $address))); $email = strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $email))); $subject = strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $subject))); $message = strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $message))); $phone = strip_tags(preg_replace('/<[^>]*>/', '', preg_replace('/<script.*<\\/[^>]*>/', '', $phone))); $send_copy = isset($_POST['cntctfrm_contact_send_copy']) && $cntctfrm_form_count == $cntctfrm_form_submited ? $_POST['cntctfrm_contact_send_copy'] : ""; /* If it is good */ if (true === $cntctfrm_result && $cntctfrm_form_count == $cntctfrm_form_submited) { $_SESSION['cntctfrm_send_mail'] = true; if (1 == $cntctfrm_options['cntctfrm_action_after_send']) { $content .= '<div id="cntctfrm_contact_form' . $cntctfrm_form_countid . '"><div id="cntctfrm_thanks">' . $cntctfrm_options['cntctfrm_thank_text'][$lang] . '</div></div>'; } else { $content .= "<script type='text/javascript'>window.location.href = '" . $cntctfrm_options['cntctfrm_redirect_url'] . "';</script>"; } } elseif (false === $cntctfrm_result && $cntctfrm_form_count == $cntctfrm_form_submited) { /* If email not be delivered */ $error_message['error_form'] = __("Sorry, email message could not be delivered.", 'contact-form-plugin'); } if (true !== $cntctfrm_result || $cntctfrm_form_count != $cntctfrm_form_submited) { $_SESSION['cntctfrm_send_mail'] = false; $cntctfrm_classes = $cntctfrm_options['cntctfrm_layout'] === 1 ? ' cntctfrm_one_column' : ' cntctfrm_two_columns'; $cntctfrm_classes .= is_rtl() ? ' cntctfrm_rtl' : ' cntctfrm_ltr'; /* Output form */ $content .= '<form method="post" id="cntctfrm_contact_form' . $cntctfrm_form_countid . '" class="cntctfrm_contact_form' . $cntctfrm_classes . '"'; $content .= ' action="' . $page_url . $cntctfrm_form_countid . '" enctype="multipart/form-data">'; if (isset($error_message['error_form']) && $cntctfrm_form_count == $cntctfrm_form_submited) { $content .= '<div class="cntctfrm_error_text">' . $error_message['error_form'] . '</div>'; } $cntctfrm_ordered_fields = cntctfrm_get_ordered_fields(); for ($i = 1; $i <= $cntctfrm_options['cntctfrm_layout']; $i++) { $cntctfrm_column = $i == 1 ? 'first_column' : 'second_column'; $content .= '<div id="cntctfrm_' . $cntctfrm_column . '" class="cntctfrm_column">'; foreach ($cntctfrm_ordered_fields[$cntctfrm_column] as $cntctfrm_field) { switch ($cntctfrm_field) { case 'cntctfrm_contact_name': if (1 == $cntctfrm_options['cntctfrm_display_name_field']) { $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_name_wrap">'; $content .= '<div class="cntctfrm_label cntctfrm_label_name"> <label for="cntctfrm_contact_name' . $cntctfrm_form_countid . '">' . $cntctfrm_options['cntctfrm_name_label'][$lang] . ($cntctfrm_options['cntctfrm_required_name_field'] == 1 ? ' <span class="required">' . $cntctfrm_options['cntctfrm_required_symbol'] . '</span></label>' : '</label>'); $content .= '</div>'; if (isset($error_message['error_name']) && $cntctfrm_form_count == $cntctfrm_form_submited) { $content .= '<div class="cntctfrm_error_text">' . $error_message['error_name'] . '</div>'; } $content .= '<div class="cntctfrm_input cntctfrm_input_name"> <input class="text" type="text" size="40" value="' . $name . '" name="cntctfrm_contact_name" id="cntctfrm_contact_name' . $cntctfrm_form_countid . '" />'; $content .= '</div>'; $content .= '</div>'; } break; case 'cntctfrm_contact_address': if (1 == $cntctfrm_options['cntctfrm_display_address_field']) { $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_address_wrap">'; $content .= '<div class="cntctfrm_label cntctfrm_label_address"> <label for="cntctfrm_contact_address' . $cntctfrm_form_countid . '">' . $cntctfrm_options['cntctfrm_address_label'][$lang] . ($cntctfrm_options['cntctfrm_required_address_field'] == 1 ? ' <span class="required">' . $cntctfrm_options['cntctfrm_required_symbol'] . '</span></label>' : '</label>') . '</div>'; if (isset($error_message['error_address']) && $cntctfrm_form_count == $cntctfrm_form_submited) { $content .= '<div class="cntctfrm_error_text">' . $error_message['error_address'] . '</div>'; } $content .= '<div class="cntctfrm_input cntctfrm_input_address"> <input class="text" type="text" size="40" value="' . $address . '" name="cntctfrm_contact_address" id="cntctfrm_contact_address' . $cntctfrm_form_countid . '" />'; $content .= '</div>'; $content .= '</div>'; } break; case 'cntctfrm_contact_email': $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_email_wrap">'; $content .= '<div class="cntctfrm_label cntctfrm_label_email"> <label for="cntctfrm_contact_email' . $cntctfrm_form_countid . '">' . $cntctfrm_options['cntctfrm_email_label'][$lang] . ($cntctfrm_options['cntctfrm_required_email_field'] == 1 ? ' <span class="required">' . $cntctfrm_options['cntctfrm_required_symbol'] . '</span></label>' : '</label>') . ' </div>'; if (isset($error_message['error_email']) && $cntctfrm_form_count == $cntctfrm_form_submited) { $content .= '<div class="cntctfrm_error_text">' . $error_message['error_email'] . '</div>'; } $content .= '<div class="cntctfrm_input cntctfrm_input_email"> <input class="text" type="text" size="40" value="' . $email . '" name="cntctfrm_contact_email" id="cntctfrm_contact_email' . $cntctfrm_form_countid . '" />'; $content .= '</div>'; $content .= '</div>'; break; case 'cntctfrm_contact_phone': if (1 == $cntctfrm_options['cntctfrm_display_phone_field']) { $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_phone_wrap">'; $content .= '<div class="cntctfrm_label cntctfrm_label_phone"> <label for="cntctfrm_contact_phone' . $cntctfrm_form_countid . '">' . $cntctfrm_options['cntctfrm_phone_label'][$lang] . ($cntctfrm_options['cntctfrm_required_phone_field'] == 1 ? ' <span class="required">' . $cntctfrm_options['cntctfrm_required_symbol'] . '</span></label>' : '</label>') . ' </div>'; if (isset($error_message['error_phone']) && $cntctfrm_form_count == $cntctfrm_form_submited) { $content .= '<div class="cntctfrm_error_text">' . $error_message['error_phone'] . '</div>'; } $content .= '<div class="cntctfrm_input cntctfrm_input_phone"> <input class="text" type="text" size="40" value="' . $phone . '" name="cntctfrm_contact_phone" id="cntctfrm_contact_phone' . $cntctfrm_form_countid . '" />'; $content .= '</div>'; $content .= '</div>'; } break; case 'cntctfrm_contact_subject': $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_subject_wrap">'; $content .= '<div class="cntctfrm_label cntctfrm_label_subject"> <label for="cntctfrm_contact_subject' . $cntctfrm_form_countid . '">' . $cntctfrm_options['cntctfrm_subject_label'][$lang] . ($cntctfrm_options['cntctfrm_required_subject_field'] == 1 ? ' <span class="required">' . $cntctfrm_options['cntctfrm_required_symbol'] . '</span></label>' : '</label>') . ' </div>'; if (isset($error_message['error_subject']) && $cntctfrm_form_count == $cntctfrm_form_submited) { $content .= '<div class="cntctfrm_error_text">' . $error_message['error_subject'] . '</div>'; } $content .= '<div class="cntctfrm_input cntctfrm_input_subject"> <input class="text" type="text" size="40" value="' . $subject . '" name="cntctfrm_contact_subject" id="cntctfrm_contact_subject' . $cntctfrm_form_countid . '" />'; $content .= '</div>'; $content .= '</div>'; break; case 'cntctfrm_contact_message': $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_message_wrap">'; $content .= '<div class="cntctfrm_label cntctfrm_label_message"> <label for="cntctfrm_contact_message' . $cntctfrm_form_countid . '">' . $cntctfrm_options['cntctfrm_message_label'][$lang] . ($cntctfrm_options['cntctfrm_required_message_field'] == 1 ? ' <span class="required">' . $cntctfrm_options['cntctfrm_required_symbol'] . '</span></label>' : '</label>') . ' </div>'; if (isset($error_message['error_message']) && $cntctfrm_form_count == $cntctfrm_form_submited) { $content .= '<div class="cntctfrm_error_text">' . $error_message['error_message'] . '</div>'; } $content .= '<div class="cntctfrm_input cntctfrm_input_message"> <textarea rows="5" cols="30" name="cntctfrm_contact_message" id="cntctfrm_contact_message' . $cntctfrm_form_countid . '">' . $message . '</textarea>'; $content .= '</div>'; $content .= '</div>'; break; case 'cntctfrm_contact_attachment': if (1 == $cntctfrm_options['cntctfrm_attachment']) { $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_attachment_wrap">'; $content .= '<div class="cntctfrm_label cntctfrm_label_attachment"> <label for="cntctfrm_contact_attachment' . $cntctfrm_form_countid . '">' . $cntctfrm_options['cntctfrm_attachment_label'][$lang] . '</label> </div>'; if (isset($error_message['error_attachment']) && $cntctfrm_form_count == $cntctfrm_form_submited) { $content .= '<div class="cntctfrm_error_text">' . $error_message['error_attachment'] . '</div>'; } $content .= '<div class="cntctfrm_input cntctfrm_input_attachment"> <input type="file" name="cntctfrm_contact_attachment" id="cntctfrm_contact_attachment' . $cntctfrm_form_countid . '"' . (isset($error_message['error_attachment']) ? "class='error'" : "") . ' />'; if (1 == $cntctfrm_options['cntctfrm_attachment_explanations']) { $content .= '<label class="cntctfrm_contact_attachment_extensions"><br />' . $cntctfrm_options['cntctfrm_attachment_tooltip'][$lang] . '</label>'; } $content .= '</div>'; $content .= '</div>'; } break; case 'cntctfrm_contact_send_copy': if (1 == $cntctfrm_options['cntctfrm_send_copy']) { $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_attachment_wrap">'; $content .= '<div class="cntctfrm_checkbox cntctfrm_checkbox_send_copy"> <input type="checkbox" value="1" name="cntctfrm_contact_send_copy" id="cntctfrm_contact_send_copy"' . ($send_copy == '1' ? ' checked="checked" ' : "") . ' /> <label for="cntctfrm_contact_send_copy">' . $cntctfrm_options['cntctfrm_send_copy_label'][$lang] . '</label>'; $content .= '</div>'; $content .= '</div>'; } break; case 'cntctfrm_captcha': if (has_filter('cntctfrm_display_captcha')) { $content .= '<div class="cntctfrmpr_field_wrap cntctfrmpr_field_captcha_wrap">'; $content .= '<div class="cntctfrm_input cntctfrm_input_captcha">'; $content .= apply_filters('cntctfrm_display_captcha', $cntctfrm_form_count == $cntctfrm_form_submited ? $error_message : false, '', 'bws_contact'); $content .= '</div>'; $content .= '</div>'; } break; default: break; } } $content .= '</div>'; } $content .= '<div class="clear"></div>'; $cntctfrm_direction = is_rtl() ? 'rtl' : 'ltr'; $cntctfrm_submit_position_value = array('ltr' => array('left' => 1, 'right' => 2), 'rtl' => array('left' => 2, 'right' => 1)); $content .= '<div class="cntctfrm_submit_wrap">'; for ($i = 1; $i <= 2; $i++) { $cntctfrm_column = $i == 1 ? 'first_column' : 'second_column'; $content .= '<div id="cntctfrm_submit_' . $cntctfrm_column . '" class="cntctfrm_column">'; if ($i == $cntctfrm_submit_position_value[$cntctfrm_direction][$cntctfrm_options['cntctfrm_submit_position']]) { $content .= '<div class="cntctfrm_input cntctfrm_input_submit" style="text-align: ' . $cntctfrm_options['cntctfrm_submit_position'] . ' !important;">'; if (isset($atts['id'])) { $content .= '<input type="hidden" value="' . esc_attr($atts['id']) . '" name="cntctfrmmlt_shortcode_id">'; } $content .= '<input type="hidden" value="send" name="cntctfrm_contact_action"><input type="hidden" value="Version: 3.30" /> <input type="hidden" value="' . esc_attr($lang) . '" name="cntctfrm_language"> <input type="hidden" value="' . $cntctfrm_form_count . '" name="cntctfrm_form_submited"> <input type="submit" value="' . $cntctfrm_options['cntctfrm_submit_label'][$lang] . '" class="cntctfrm_contact_submit" /> </div>'; } $content .= '</div>'; } $content .= '<div class="clear"></div> </div> </form>'; } return $content; }