prefix . 'afm_list'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, fname varchar(55) DEFAULT '' NOT NULL, lname varchar(55) DEFAULT '' NOT NULL, phone varchar(15) DEFAULT '' NOT NULL, email varchar(55) DEFAULT '' NOT NULL, location varchar(55) DEFAULT '' NOT NULL, visit varchar(55) DEFAULT '' NOT NULL, comment text NOT NULL, callback_status varchar(10) DEFAULT 'No' NOT NULL, request_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, response_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, UNIQUE KEY id (id) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); } register_activation_hook( __FILE__, 'afm_plugins_default_mail_settings' ); function afm_plugins_default_mail_settings(){ global $wpdb; if(get_option( 'afm_admin_mail_to_option' ) == ''){ update_option( 'afm_admin_mail_to_option', get_option( 'admin_email' ) ); } if(get_option( 'afm_admin_mail_subject' ) == ''){ update_option( 'afm_admin_mail_subject', 'Regarding appointment form submission' ); } if(get_option( 'afm_admin_mail_from_email' ) == ''){ update_option( 'afm_admin_mail_from_email', get_option( 'admin_email' ) ); } if(get_option( 'afm_admin_mail_from_name' ) == ''){ update_option( 'afm_admin_mail_from_name', 'Appointment' ); } //update_option( 'afm_admin_mail_to_bcc', $afm_admin_mail_to_bcc ); if(get_option( 'afm_admin_send_success_msg' ) == ''){ update_option( 'afm_admin_send_success_msg', "Thank you for booking an appointment with WP 4.2.2 Test, we will call you back to confirm a time and date within 48 hours." ); } if(get_option( 'afm_admin_send_err_msg' ) == ''){ update_option( 'afm_admin_send_err_msg', "An error found. Mail sending failed." ); } if(get_option( 'afm_admin_send_name_msg' ) == ''){ update_option( 'afm_admin_send_name_msg', get_bloginfo('name') ); } if(get_option( 'afm_admin_send_email_msg' ) == ''){ update_option( 'afm_admin_send_email_msg', get_option( 'admin_email' ) ); } if(get_option( 'afm_admin_send_subject_msg' ) == ''){ update_option( 'afm_admin_send_subject_msg', "Thank you for booking an appointment" ); } if(get_option( 'afm_invalid_captcha_err_msg' ) == ''){ update_option( "afm_invalid_captcha_err_msg", "Enter captcha is wrong." ); } if(get_option( 'afm_null_captcha_err_msg' ) == ''){ update_option( "afm_null_captcha_err_msg", "Captcha is required." ); } if(get_option( 'afm_null_fname_err_msg' ) == ''){ update_option( "afm_null_fname_err_msg", "First name is required." ); } if(get_option( 'afm_null_lname_err_msg' ) == ''){ update_option( "afm_null_lname_err_msg", "Last name is required." ); } if(get_option( 'afm_null_phone_err_msg' ) == ''){ update_option( "afm_null_phone_err_msg", "Phone number is required." ); } if(get_option( 'afm_valid_phone_err_msg' ) == ''){ update_option( "afm_valid_phone_err_msg", "Phone number is invalid." ); } if(get_option( 'afm_null_email_err_msg' ) == ''){ update_option( "afm_null_email_err_msg", "Email is required." ); } if(get_option( 'afm_valid_email_err_msg' ) == ''){ update_option( "afm_valid_email_err_msg", "Email is not valid." ); } if(get_option( 'afm_null_location_err_msg' ) == ''){ update_option( "afm_null_location_err_msg", "Location is required." ); } if(get_option( 'afm_null_visit_err_msg' ) == ''){ update_option( "afm_null_visit_err_msg", "Visit is required." ); } if(get_option( 'afm_null_comment_err_msg' ) == ''){ update_option( "afm_null_comment_err_msg", "Comment is required." ); } } function afm_insert_visitor_mail_data($fname, $lname, $phone, $email, $location, $visit, $comment) { global $wpdb; $table_name = $wpdb->prefix . 'afm_list'; $wpdb->insert( $table_name, array( 'request_time' => current_time( 'mysql' ), 'fname' => $fname, 'lname' => $lname, 'phone' => $phone, 'email' => $email, 'location' => $location, 'visit' => $visit, 'comment' => $comment ) ); } function afm_display_html_form() { $options = get_option('afm_custom_css_option'); if(!empty($options['afm_custom_css_field'])): ?>

Book an appointment

'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo '

' . get_option( "afm_null_fname_err_msg" ) . '

'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo '

' . get_option( "afm_null_lname_err_msg" ) . '

'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo '

' . get_option( "afm_null_phone_err_msg" ) . '

'; echo '
'; echo '

Please enter valid phone number.

'; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '

' . get_option( "afm_null_email_err_msg" ) . '

'; echo '
'; echo '

' . get_option( "afm_valid_email_err_msg" ) . '


'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo '

' . get_option( "afm_null_location_err_msg" ) . '

'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo '

' . get_option( "afm_null_visit_err_msg" ) . '

'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo '

' . get_option( "afm_null_comment_err_msg" ) . '

'; echo '
'; echo '
'; $args = array( 'chars_num'=> '6', // number of characters //'tcolor' => 'C5C6C8', // text color // 'ncolor' => 'f00', // noise color 'dots' => 50, // number of dots 'lines'=> 40, // number of lines, 'width'=>'220', // number of width, 'height'=>'70' // number of height ); /* START 29-06-15 */ $num1 = rand(0,10); // pick a random number from 0 to 10 inclusive $num2 = rand(0,10); // same idea $o = rand(0,2); // 0 = plus, 1 = minus, 2 = multiply /* This function will use the integer value of $operand to show either a plus, minus, or times. */ function operand($o) { switch($o) { case 0: return "+"; break; case 1: return "-"; break; case 2: return "*"; break; default: return "?"; break; //Remark: We shouldn't ever get down here. } } ?> '; echo '

' . get_option( "afm_null_captcha_err_msg" ) . '

'; echo '
'; echo '

' . get_option( "afm_invalid_captcha_err_msg" ) . '


'; echo '
'; echo ''; echo ''; echo ''; ?> admin_url( 'admin-ajax.php' ) ) ); } add_action( 'wp_enqueue_scripts', 'afm_plugin_add_styles' ); function afm_plugin_admin_add_styles(){ wp_register_style( 'afm-admin-style', plugin_dir_url( __FILE__ ) . 'lib/css/admin.css' ); wp_enqueue_style('afm-admin-style'); wp_register_script( 'afm-admin-script', plugin_dir_url( __FILE__ ) . 'lib/js/admin.js' ); wp_enqueue_script('afm-admin-script'); } add_action( 'admin_enqueue_scripts', 'afm_plugin_admin_add_styles' ); function set_html_content_type() { return 'text/html'; } add_action( 'admin_menu', 'register_afm_settings_menu_page' ); function register_afm_settings_menu_page() { add_menu_page( 'AFM Settings', 'AFM Settings', 'manage_options', 'afm-plugin-settings-page', 'afm_plugin_settings_callback', '', 6 ); add_submenu_page( 'afm-plugin-settings-page', 'Manage Mail List', 'Manage Mail List', 'manage_options', 'afm-manage-list-page', 'afm_manage_list_page_callback' ); add_submenu_page( null, 'Edit Mail List', 'Edit Mail List', 'manage_options', 'afm-edit-mail-list', 'afm_edit_mail_list_callback' ); add_submenu_page( 'afm-plugin-settings-page', 'AFM Custom CSS', 'AFM Custom CSS', 'manage_options', 'afm-custom-css-page', 'afm_custom_css_page_callback' ); } function afm_plugin_settings_callback() { if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); } ?>

Appointment Form Manager Settings

Options saved

'; $afm_admin_mail_id = sanitize_email($_POST['afm_admin_mail_id']); $afm_admin_mail_from_email = esc_attr($_POST['afm_admin_mail_from_email']); $afm_admin_mail_from_name = esc_attr($_POST['afm_admin_mail_from_name']); $afm_admin_mail_subject = sanitize_text_field($_POST['afm_admin_mail_subject']); $afm_admin_mail_to_bcc = sanitize_text_field($_POST['afm_admin_mail_to_bcc']); if(empty($afm_admin_mail_id)){ $afm_admin_mail_id = get_option( 'admin_email' ); } if(empty($afm_admin_mail_to_bcc)){ $afm_admin_mail_to_bcc = "no"; } else if(!empty($afm_admin_mail_to_bcc)){ $afm_admin_mail_to_bcc = "yes"; } update_option( 'afm_admin_mail_to_option', $afm_admin_mail_id ); update_option( 'afm_admin_mail_subject', $afm_admin_mail_subject ); update_option( 'afm_admin_mail_from_email', $afm_admin_mail_from_email ); update_option( 'afm_admin_mail_from_name', $afm_admin_mail_from_name ); update_option( 'afm_admin_mail_to_bcc', $afm_admin_mail_to_bcc ); } if(isset($_POST['afm_admin_msg_setting_saved'])){ echo '

Options saved

'; $afm_admin_send_success_msg = esc_textarea($_POST['afm_admin_send_success_msg']); $afm_admin_send_err_msg = esc_textarea($_POST['afm_admin_send_err_msg']); $afm_admin_send_name_msg = sanitize_text_field($_POST['afm_admin_send_name_msg']); $afm_admin_send_email_msg = sanitize_email($_POST['afm_admin_send_email_msg']); $afm_admin_send_subject_msg = sanitize_text_field($_POST['afm_admin_send_subject_msg']); if(empty($afm_admin_send_success_msg)){ $afm_admin_send_success_msg = "Thank you for booking an appointment with " . get_bloginfo('name') . ", we will call you back to confirm a time and date within 48 hours."; } if(empty($afm_admin_send_err_msg)){ $afm_admin_send_err_msg = "Mail sending failed."; } if(empty($afm_admin_send_name_msg)){ $afm_admin_send_name_msg = get_bloginfo('name'); } if(empty($afm_admin_send_email_msg)){ $afm_admin_send_email_msg = get_bloginfo('admin_email'); } if(empty($afm_admin_send_subject_msg)){ $afm_admin_send_subject_msg = "Thank you for booking an appointment"; } update_option( 'afm_admin_send_success_msg', $afm_admin_send_success_msg ); update_option( 'afm_admin_send_err_msg', $afm_admin_send_err_msg ); update_option( 'afm_admin_send_name_msg', $afm_admin_send_name_msg ); update_option( 'afm_admin_send_email_msg', $afm_admin_send_email_msg ); update_option( 'afm_admin_send_subject_msg', $afm_admin_send_subject_msg ); } ?>

Admin Email Settings

Admin Mail:
From Name:
From Email:
Subject:

Response Email Settings

From Name:
From Email:
Subject:
Sender's message was sent successfully:
Sender's message was failed to send:
'; echo '

Manage Mail List

'; echo ''; echo '
'; $afm_mail_list = afm_get_all_mail_list_data(); ?>
id; $fname = $list -> fname; $lname = $list -> lname; $phone = $list -> phone; $email = $list -> email; $location = $list -> location; $visit = $list -> visit; $comment = $list -> comment; $callback_status = $list -> callback_status; $request_time = $list -> request_time; $response_time = $list -> response_time; ?>
IDFirst NameLast NamePhoneEmailLocationVisitCallbackActions
prefix . 'afm_list'; $results = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $table_name ORDER BY id DESC", ARRAY_A) ); return $results; } function afm_edit_mail_list_callback(){ echo '
'; echo '

Edit Mail ListView Mail List

'; echo '
'; ?>
First Name
Last Name
Phone
Email
Location
Visit
Comment
Callback callback_status == 'Yes') { ?> Yes No Yes No
Request Time
Response Time
Back to Manage Mail List
prefix . 'afm_list'; $results = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $table_name WHERE id = %d", $id, ARRAY_A) ); return $results; } function afm_mail_list_update_status($status, $response, $afm_id){ global $wpdb; $table_name = $wpdb->prefix . 'afm_list'; $wpdb->update( $table_name, array( 'callback_status' => $status, 'response_time' => current_time( 'mysql' ) ), array( 'id' => $afm_id ), array( '%s', '%s' ), array( '%d' ) ); } function ajaxcontact_show_contact(){ ?>
Name


Email


Subject


Contents

Send Mail
#captcha-wrapper .afm-null-error{display: block;}#math{background: #f0bebe !important;}'; $error = 1; } else if(!empty($userAnswer) && ($userAnswer != $actual)) { $results = get_option( "afm_invalid_captcha_err_msg"); echo ''; $error = 1; } else{ $error = 0; } $admin_email = get_option('admin_email'); if( strlen($acffname) == 0 ){ $results = get_option( "afm_null_fname_err_msg" ); echo ''; $error = 1; } if( strlen($acflname) == 0 ){ $results = get_option( "afm_null_lname_err_msg" ); echo ''; $error = 1; } if( strlen($acfphone) == 0 ){ $results = get_option( "afm_null_phone_err_msg" ); echo ''; $error = 1; } else{ if( ( strlen($acfphone) < 10 ) || ( strlen($acfphone) > 12 ) ){ $results = get_option( "afm_valid_phone_err_msg" ); echo ''; $error = 1; } } /*if( strlen($acfemail) == 0 ){ $results = get_option( "afm_null_email_err_msg" ); echo ''; $error = 1; }*/ if (!filter_var($acfemail, FILTER_VALIDATE_EMAIL)){ $results = get_option( "afm_valid_email_err_msg" ); echo ''; $error = 1; } if( strlen($acflocation) == 0 ){ $results = get_option( "afm_null_location_err_msg" ); echo ''; $error = 1; } if( strlen($acfvisit) == 0 ){ $results = get_option( "afm_null_visit_err_msg" ); echo ''; $error = 1; } if( strlen($acfcomment) == 0 ){ $results = get_option( "afm_null_comment_err_msg" ); echo ''; $error = 1; } if($error == 0){ echo ''; $to = get_option( 'afm_admin_mail_to_option' ); $subject = get_option( 'afm_admin_mail_subject' ); if(empty($subject)){ $subject = "Appointment form submitted"; } $admin_mail = get_option( 'afm_admin_mail_to_option' ); $user_subject = "Thank you for booking an appointment"; $mail_body = "

First Name: $acffname

Surname: $acflname

Phone No: $acfphone

E-mail: $acfemail

Location: $acflocation

Type of Visit: $acfvisit

Comments: $acfcomment

"; $user_mail_body = "

" . get_option( 'afm_admin_send_success_msg') . "

"; //$custom_email = strtolower($acffname . "_" . $acflname . "@".ie"); $from_name = get_option( 'afm_admin_mail_from_name' ); $from_email = get_option( 'afm_admin_mail_from_email' ); $res_from_name = get_option( 'afm_admin_send_name_msg' ); $res_from_email = get_option( '$afm_admin_send_email_msg'); if(empty($from_name)){ $from_name = "$acffname $acflname"; } /*if(empty($from_email)){ $from_email = $custom_email; }*/ if(empty($res_from_name)){ $res_from_name = get_bloginfo('name'); } if(empty($res_from_email)){ $res_from_email = $to; } $headers[] = "From: $from_name <$from_email>"; if(get_option( 'afm_admin_mail_to_bcc') == 'yes'){ $headers[] = "Bcc: $to"; } $user_headers[] = "Reply-To: " . $to; $user_headers[] = "From: $res_from_name <$res_from_email>"; add_filter( 'wp_mail_content_type', 'set_html_content_type' ); // If email has been process for sending, display a success comment if ( wp_mail( $admin_mail, $subject, $mail_body, $headers ) ) { echo '
'; echo '

' . get_option( 'afm_admin_send_success_msg') . '

'; echo '
'; // Response mail wp_mail( $acfemail, $user_subject, $user_mail_body, $user_headers ); afm_insert_visitor_mail_data($acffname, $acflname, $acfphone, $acfemail, $acflocation, $acfvisit, $acfcomment); remove_filter( 'wp_mail_content_type', 'set_html_content_type' ); } else { echo '

' . get_option( 'afm_admin_send_err_msg') . '

'; } } // Return the String die($results); } // creating Ajax call for WordPress add_action( 'wp_ajax_nopriv_ajaxcontact_send_mail', 'ajaxcontact_send_mail' ); add_action( 'wp_ajax_ajaxcontact_send_mail', 'ajaxcontact_send_mail' ); function afm_custom_css_page_callback(){ if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); } ?>

Appointment Form Manager CSS Settings

Options saved

'; $afm_custom_css_option['afm_custom_css_field'] = sanitize_text_field($_POST['afm_custom_css_field']); $options = get_option('afm_custom_css_option'); if (empty($options)) { add_option('afm_custom_css_option', $afm_custom_css_option); $msg = 1; } else{ update_option( 'afm_custom_css_option', $afm_custom_css_option ); $msg = 1; } } $options = get_option('afm_custom_css_option'); ?>

Custom CSS Editor

You can put your custom css here.