function wbsf_settings_link($links) { $forms_link = '<a href="' . wbsf_get_url('forms') . '">Forms</a>'; $settings_link = '<a href="' . wbsf_get_url('settings') . '">Settings</a>'; array_unshift($links, $forms_link); array_unshift($links, $settings_link); return $links; }
function wbsf_settings() { global $wpdb; $link = wbsf_get_url('settings'); if (!isset($_REQUEST['settings-updated'])) { $_REQUEST['settings-updated'] = false; } ?> <div class="wrap wbsf_wrap"> <div class="add_new"><div id="icon-edit-pages" class="icon32"><br></div><h2>Bookmans Signup Forms Settings</h2></div> <?php if (false != $_REQUEST['settings-updated']) { ?> <div class="updated"><p><strong><?php _e('Settings saved'); ?> </strong></p></div> <?php } ?> <form method="post" action="options.php"> <?php settings_fields('wbsf_settings'); $settings = get_option('wbsf_settings_options'); ?> <table id="general-tab" class="form-table wbsf_setting_table"> <tr valign="top"><th scope="row"><?php _e('Select Page'); ?> </th> <td> <div class="relative"> <select id="wbsf_settings_options_entry_edit_page" class="regular-text large" name="wbsf_settings_options[entry_edit_page]"> <option value=""><?php echo esc_attr(__('Select page')); ?> </option> <?php $pages = get_pages(); foreach ($pages as $page) { ?> <option value="<?php echo $page->ID; ?> " <?php if ($settings['entry_edit_page'] == $page->ID) { echo 'selected="selected"'; } ?> ><?php echo $page->post_title; ?> </option> <?php } ?> </select> <label class="description" for="wbsf_settings_options_entry_edit_page"><?php _e('Select Page to show edit entry form for gues user.'); ?> </label> </div> </td> </tr> <tr valign="top"><th scope="row"><?php _e('Admin Email'); ?> </th> <td> <div class="relative"> <input type="text" id="wbsf_settings_options_email" class="regular-text" name="wbsf_settings_options[email]" value="<?php echo get_option('admin_email'); ?> " /> <label class="description" for="wbsf_settings_options_email"><?php _e('Admin Email address for mail notifications.'); ?> </label> </div> </td> </tr> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php _e('Save Settings'); ?> " /> </p> </form> </div> <?php }
function wbsf_entries() { global $wpdb; $url = wbsf_get_url('entries'); //Current page url /****************** Common Requests ******************/ $action = $_REQUEST['action']; $form_id = $_REQUEST['fid']; $entry_id = $_REQUEST['eid']; $form_type = $_REQUEST['form_type']; $step = 'entries'; //Reset to Step $status = $_REQUEST['status']; if ($action == 'view' && !empty($entry_id) && !empty($form_type)) { $entry = wbsf_get_entry($form_type, $entry_id); } /****************** Delete Entry Step ******************/ if ($action == 'delete' && !empty($entry_id) && !empty($form_type)) { $status = wbsf_delete_entry($form_type, $entry_id); if ($status == 1) { wbsf_redirect($url); } } ?> <div class="wrap wbsf_wrap"> <div class="add_new"><div id="icon-edit-pages" class="icon32"><br></div><h2><?php _e('Bookmans Signup Forms'); ?> </h2></div> <div class="wbsf_container"> <?php wbsf_status_info($step, $status); ?> <?php if ($action == 'view') { //Form Add/Edit Area ?> <div class="wbsf_add_new"><a class="button button-primary" href="<?php echo $url; ?> "><?php _e('Go Back'); ?> </a></div> <div class="wbsf_form_add"> <?php require_once 'entry_view_' . $form_type . '.php'; ?> </div> <?php } else { if (!$action) { // List of forms ?> <div class="wbsf_add_new"> <form name="wbsf_filter_entries" method="post" action=""> <select id="form_list" name="fid" class="wbsf_select regular-text large data-required"> <?php $forms_list = wbsf_get_forms($form_status = 1); if (count($forms_list)) { foreach ($forms_list as $form_list) { ?> <option value="<?php echo $form_list->fid; ?> " <?php if ($form_list->fid == $form_id) { echo 'selected="selected"'; } ?> ><?php echo $form_list->form_title; ?> </option> <?php } } ?> </select> <input type="submit" class="button-primary" name="wbsf_filter_entries" value="<?php _e('Filter'); ?> " /> </form> </div> <table class="table table-striped table-bordered" id="wbsf_dyntable"> <colgroup> <col class="con0" /> <col class="con1" /> <col class="con0" /> <col class="con1" /> <col class="con0" /> <col class="con1" /> <col class="con0" /> <col class="con1" /> </colgroup> <thead> <tr> <th class="head0"><?php _e('Name'); ?> </th> <th class="head0"><?php _e('Email'); ?> </th> <th class="head0"><?php _e('Registered ID'); ?> </th> <th class="head1"><?php _e('Assoc. Form'); ?> </th> <th class="head1"><?php _e('Form Type'); ?> </th> <th class="head1"><?php _e('Status'); ?> </th> <th class="head1"><?php _e('View'); ?> </th> <th class="head1"><?php _e('Delete'); ?> </th> </tr> </thead> <tbody> <?php $entries = wbsf_get_entries(1, $form_id); if (count($entries)) { foreach ($entries as $entry) { $form = wbsf_get_form($entry->fid); ?> <tr class="grade<?php if ($entry->confirm_status == 0) { echo 'U'; } else { echo 'X'; } ?> "> <td><?php echo $entry->parent_name; ?> </td> <td><?php echo $entry->email; ?> </td> <td><?php echo $entry->token; ?> </td> <td><a href="<?php echo $url; ?> &fid=<?php echo $entry->fid; ?> " class="button"><?php echo $form->form_title; ?> </a></td> <td><?php echo wbsf_form_type($form->form_type); ?> </td> <td><?php if ($entry->confirm_status == 1) { echo 'Verified'; } else { echo 'Not Verified'; } ?> </td> <td><a href="<?php echo $url; ?> &action=view&eid=<?php echo $entry->eid; ?> &form_type=<?php echo $form->form_type; ?> " class="button"><?php _e('View'); ?> </a></td> <td><a href="<?php echo $url; ?> &action=delete&eid=<?php echo $entry->eid; ?> &form_type=<?php echo $form->form_type; ?> " class="button wbsf_delete"><?php _e('Delete'); ?> </a></td> </tr> <?php } } ?> <?php $entries = wbsf_get_entries(2, $form_id); if (count($entries)) { foreach ($entries as $entry) { $form = wbsf_get_form($entry->fid); ?> <tr class="grade<?php if ($entry->confirm_status == 0) { echo 'U'; } else { echo 'X'; } ?> "> <td><?php echo $entry->parent_name; ?> </td> <td><?php echo $entry->email; ?> </td> <td><?php echo $entry->token; ?> </td> <td><a href="<?php echo $url; ?> &fid=<?php echo $entry->fid; ?> " class="button"><?php echo $form->form_title; ?> </a></td> <td><?php echo wbsf_form_type($form->form_type); ?> </td> <td><?php if ($entry->confirm_status == 1) { echo 'Verified'; } else { echo 'Not Verified'; } ?> </td> <td><a href="<?php echo $url; ?> &action=view&eid=<?php echo $entry->eid; ?> &form_type=<?php echo $form->form_type; ?> " class="button"><?php _e('View'); ?> </a></td> <td><a href="<?php echo $url; ?> &action=delete&eid=<?php echo $entry->eid; ?> &form_type=<?php echo $form->form_type; ?> " class="button wbsf_delete"><?php _e('Delete'); ?> </a></td> </tr> <?php } } ?> <?php $entries = wbsf_get_entries(3, $form_id); if (count($entries)) { foreach ($entries as $entry) { $form = wbsf_get_form($entry->fid); ?> <tr class="grade<?php if ($entry->confirm_status == 0) { echo 'U'; } else { echo 'X'; } ?> "> <td><?php echo $entry->parent_name; ?> </td> <td><?php echo $entry->email; ?> </td> <td><?php echo $entry->token; ?> </td> <td><a href="<?php echo $url; ?> &fid=<?php echo $entry->fid; ?> " class="button"><?php echo $form->form_title; ?> </a></td> <td><?php echo wbsf_form_type($form->form_type); ?> </td> <td><?php if ($entry->confirm_status == 1) { echo 'Verified'; } else { echo 'Not Verified'; } ?> </td> <td><a href="<?php echo $url; ?> &action=view&eid=<?php echo $entry->eid; ?> &form_type=<?php echo $form->form_type; ?> " class="button"><?php _e('View'); ?> </a></td> <td><a href="<?php echo $url; ?> &action=delete&eid=<?php echo $entry->eid; ?> &form_type=<?php echo $form->form_type; ?> " class="button wbsf_delete"><?php _e('Delete'); ?> </a></td> </tr> <?php } } ?> </tbody> </table> <?php } } ?> </div> <!-- end container --> </div> <!-- end wrapper --> <?php }
function wbsf_mail_admin($form_type, $entry_id) { $entry = wbsf_get_entry($form_type, $entry_id); $to = wbsf_options('email'); if (!$to) { $to = get_option('admin_email'); } $form = wbsf_get_form($entry->fid); $subject = "New Submission for " . $form->form_title; $message = ' <p>***This is an automated response - Do Not Reply***</p> <p>Hi,</p> <p>' . $entry->parent_name . ' registered for ' . $form->form_title . '.</p> <p><strong>Details:</strong></p> ' . wbsf_mail_admin_msg($form_type, $entry) . ' <p><a href="' . wbsf_get_url('entries') . '&action=view&eid=' . $entry->eid . '&form_type=' . $form_type . '">View Registration Details</a></p> <p> </p> <p>Thank You.</p>'; add_filter('wp_mail_content_type', 'wbsf_set_html_content_type'); wp_mail($to, $subject, $message); remove_filter('wp_mail_content_type', 'wbsf_set_html_content_type'); }
function wbsf_forms() { global $wpdb; $url = wbsf_get_url('forms'); //Current page url /****************** Common Requests ******************/ $action = $_REQUEST['action']; $step = 'forms'; //Reset to Step $status = $_REQUEST['status']; if (!$status && !$action) { $status = 'info'; //Reset to Status for Step } $form_id = $_REQUEST['fid']; if ($action == 'delete' && !empty($form_id)) { $status = wbsf_delete_form($form_id); if ($status == 1) { wbsf_redirect($url); } } if ($action == 'edit' && !empty($form_id)) { $form = wbsf_get_form($form_id); } /************** Create Form Step ***************/ if (isset($_REQUEST['form_add'])) { if (!empty($_REQUEST['form_add'])) { $data = array(); $data['form_title'] = $_POST['form_title']; $data['form_type'] = $_POST['form_type']; $data['form_prefix'] = $_POST['form_prefix']; $data['form_status'] = 1; $form_id = wbsf_create_form($data); if ($form_id) { wbsf_redirect($url); } } } /************** Update Form Step ***************/ if (isset($_REQUEST['form_update'])) { if (!empty($_REQUEST['form_update'])) { $data = array(); $data['form_title'] = $_POST['form_title']; $data['form_type'] = $_POST['form_type']; $data['form_prefix'] = $_POST['form_prefix']; $data['form_status'] = 1; $form_id = wbsf_update_form($form_id, $data); if ($form_id) { wbsf_redirect($url); } } } ?> <div class="wrap wbsf_wrap"> <div class="add_new"><div id="icon-edit-pages" class="icon32"><br></div><h2><?php _e('Bookmans Signup Forms'); ?> </h2></div> <div class="wbsf_container"> <?php wbsf_status_info($step, $status); ?> <?php if ($action == 'edit' || $action == 'add') { //Form Add/Edit Area ?> <div class="wbsf_form_add"> <form method="post" name="form_action" action="" id="form_action"> <table id="general-tab" class="form-table wbsf_setting_table"> <tr valign="top"> <th scope="row"><?php _e('Form Title'); ?> </th> <td><input type="text" id="form_title" name="form_title" id="wbsf-submit" class="wbsf_input regular-text data-required" value="<?php echo $form->form_title; ?> " /></td> </tr> <tr valign="top"><th scope="row"><?php _e('Form Type'); ?> </th> <td><select id="form_type" class="regular-text large data-required" name="form_type"> <option value=""><?php echo esc_attr(__('Select')); ?> </option> <?php for ($i = 1; $i <= 3; $i++) { ?> <option value="<?php echo $i; ?> " <?php if ($i == $form->form_type) { echo 'selected="selected"'; } ?> ><?php echo wbsf_form_type($i); ?> </option> <?php } ?> </select> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Registered ID Prefix'); ?> </th> <td><input type="text" id="form_prefix" name="form_prefix" id="wbsf-submit" class="wbsf_input regular-text data-required" value="<?php echo $form->form_prefix; ?> " /></td> </tr> </table> <p class="submit"> <?php if ($action == 'add') { ?> <input type="submit" id="wbsf-submit" class="button-primary" name="form_add" value="<?php _e('Create'); ?> " /><?php } else { ?> <input type="submit" class="button-primary" id="wbsf-submit" name="form_update" value="<?php _e('Update'); ?> " /><?php } ?> <a class="button" href="<?php echo $url; ?> "><?php _e('Cancel'); ?> </a> </p> </form> </div> <?php } else { if (!$action) { // List of forms ?> <div class="wbsf_add_new"><a class="button button-primary" href="<?php echo $url; ?> &action=add"><?php _e('Add new'); ?> </a></div> <table class="table table-striped table-bordered" id="wbsf_dyntable"> <colgroup> <col class="con0" /> <col class="con1" /> <col class="con0" /> <col class="con1" /> </colgroup> <thead> <tr> <th class="head0"><?php _e('Form Title'); ?> </th> <th class="head0"><?php _e('Short Code'); ?> </th> <th class="head1"><?php _e('Entries'); ?> </th> <th class="head1"><?php _e('Form Type'); ?> </th> <th class="head0"><?php _e('Edit'); ?> </th> <th class="head1"><?php _e('Delete'); ?> </th> </tr> </thead> <tbody> <?php $forms = wbsf_get_forms($form_status = 1); if (count($forms)) { foreach ($forms as $form) { ?> <tr class="gradeX"> <td><?php echo $form->form_title; ?> </td> <td><input type="text" value="[wbsf form=<?php echo $form->fid; ?> ]" class="shortcode" /></td> <td><a href="<?php echo wbsf_get_url('entries'); ?> &fid=<?php echo $form->fid; ?> " class="button"><?php _e('View Entries'); ?> (<?php echo wbsf_get_entries_count($form->fid); ?> )</a></td> <td><?php echo wbsf_form_type($form->form_type); ?> </td> <td><a href="<?php echo $url; ?> &action=edit&fid=<?php echo $form->fid; ?> " class="button"><?php _e('Edit'); ?> </a></td> <td><a href="<?php echo $url; ?> &action=delete&fid=<?php echo $form->fid; ?> " class="button wbsf_delete"><?php _e('Delete'); ?> </a></td> </tr> <?php } } ?> </tbody> </table> <?php } } ?> </div> <!-- end container --> </div> <!-- end wrapper --> <?php }