function rtb_print_form_confirm_field($slug, $title, $value, $args) { $slug = esc_attr($slug); $value = esc_attr($value); $classes = isset($args['classes']) ? $args['classes'] : array(); $classes[] = 'rtb-confirm'; ?> <div <?php echo rtb_print_element_class($slug, $classes); ?> > <?php echo rtb_print_form_error($slug); ?> <label for="rtb-<?php echo $slug; ?> "> <input type="checkbox" name="rtb-<?php echo $slug; ?> " id="rtb-<?php echo $slug; ?> " value="1" <?php checked($value, 1); ?> > <?php echo $title; ?> </label> </div> <?php }
/** * Print a field to toggle notifications when adding/editing a booking from * the admin * @since 1.3 */ function print_form_send_notifications_field($slug, $title, $value, $args) { $slug = esc_attr($slug); $title = esc_attr($title); $value = (bool) $value; $description = empty($args['description']) || empty($args['description']['prompt']) || empty($args['description']['text']) ? null : $args['description']; ?> <div class="<?php echo $slug; ?> "> <?php echo rtb_print_form_error($slug); ?> <label> <input type="checkbox" name="rtb-<?php echo esc_attr($slug); ?> " value="1"<?php checked($value); ?> > <?php echo $title; ?> <?php if (!empty($description)) { ?> <a href="#" class="rtb-description-prompt"> <?php echo $description['prompt']; ?> </a> <?php } ?> </label> <?php if (!empty($description)) { ?> <div class="rtb-description"> <?php echo $description['text']; ?> </div> <?php } ?> </div> <?php }
function rtb_print_form_radio_field($slug, $title, $value, $args) { $slug = esc_attr($slug); $value = esc_attr($value); $options = is_array($args['options']) ? $args['options'] : array(); $classes = isset($args['classes']) ? $args['classes'] : array(); ?> <div <?php echo rtb_print_element_class($slug, $classes); ?> > <?php echo rtb_print_form_error($slug); ?> <label> <?php echo $title; ?> </label> <?php foreach ($options as $opt_value => $opt_label) { ?> <label> <input type="radio" name="rtb-<?php echo $slug; ?> " id="rtb-<?php echo $slug; ?> " value="<?php echo esc_attr($opt_value); ?> " <?php checked($opt_value, $value); ?> > <?php echo $opt_label; ?> </label> <?php } ?> </div> <?php }
function cs_booking_form($params, $content = null) { global $rtb_controller; //wp_enqueue_style('intlTelInput', get_template_directory_uri() . '/framework/shortcodes/bookingtable/css/intlTelInput.css'); //wp_enqueue_script('intlTelInput',get_template_directory_uri() . '/framework/shortcodes/bookingtable/js/intlTelInput.min.js', array('jquery')); //wp_enqueue_script('bookingtable',get_template_directory_uri() . '/framework/shortcodes/bookingtable/js/bookingtable.js', array('intlTelInput')); // Only allow the form to be displayed once on a page if ($rtb_controller->form_rendered === true) { return; } else { $rtb_controller->form_rendered = true; } // Enqueue assets for the form rtb_enqueue_assets(); // Allow themes and plugins to override the booking form's HTML output. $output = apply_filters('rtb_booking_form_html_pre', ''); if (!empty($output)) { return $output; } // Process a booking request if (!empty($_POST['action']) && $_POST['action'] == 'booking_request') { if (get_class($rtb_controller->request) === 'stdClass') { require_once RTB_PLUGIN_DIR . '/includes/Booking.class.php'; $rtb_controller->request = new rtbBooking(); } $rtb_controller->request->insert_booking(); } // Define the form's action parameter $booking_page = $rtb_controller->settings->get_setting('booking-page'); if (!empty($booking_page)) { $booking_page = get_permalink($booking_page); } $settings = get_option('rtb-settings'); ob_start(); ?> <div class="cs-booking-form"> <?php if ($rtb_controller->request->request_inserted === true) { ?> <div class="rtb-message"> <p><?php echo $rtb_controller->settings->get_setting('success-message'); ?> </p> </div> <?php } else { ?> <form id="cs-booking-form" method="POST" action="<?php echo esc_attr($booking_page); ?> "> <input type="hidden" name="action" value="booking_request"> <?php do_action('rtb_booking_form_before_fields'); ?> <div class="row"> <div class="cs-bookTable-date col-xs-12 col-sm-6 col-md-6 col-lg-6"> <label for="rtb-date"><?php _e('When would you like to book?', THEMENAME); ?> </label> <span class="Selectoptions"><input type="text" name="rtb-date" id="rtb-date" value="<?php echo cs_booking_request_input('request_date'); ?> " placeholder="<?php _e('Select Date', THEMENAME); ?> "></span> <?php echo rtb_print_form_error('date'); ?> <div id="cs-booking-date"></div> </div> <div class="cs-bookTable-party col-xs-12 col-sm-2 col-md-2 col-lg-2"> <label for="rtb-party"><?php _e('Party Size :', THEMENAME); ?> </label> <span class="Selectoptions"><select name="rtb-party" id="rtb-party"> <?php if (empty($settings['party-size'])) { $settings['party-size'] = 20; } for ($i = 1; $i <= $settings['party-size']; $i++) { ?> <option value="<?php echo $i; ?> " <?php if (cs_booking_request_input('party') == $i) { echo 'selected'; } ?> ><?php echo $i; ?> </option> <?php } ?> </select> </span> </div> <div class="cs-bookTable-time col-xs-12 col-sm-4 col-md-4 col-lg-4"> <label for="rtb-time"><?php _e('Preferred dining time:', THEMENAME); ?> </label> <span class="Selectoptions"><input type="text" name="rtb-time" id="rtb-time" value="<?php echo cs_booking_request_input('request_time'); ?> " placeholder="<?php _e('Select Time', THEMENAME); ?> "></span> <?php echo rtb_print_form_error('time'); ?> <div id="cs-booking-time"></div> </div> </div> <div class="row"> <div class="name col-xs-12 col-sm-6 col-md-6 col-lg-6"> <input type="text" name="rtb-name" id="rtb-name" placeholder="<?php _e('Name', THEMENAME); ?> " value="<?php echo cs_booking_request_input('name'); ?> "> <?php echo rtb_print_form_error('name'); ?> </div> <div class="email col-xs-12 col-sm-6 col-md-6 col-lg-6"> <input type="text" name="rtb-email" id="rtb-email" placeholder="<?php _e('Email', THEMENAME); ?> " value="<?php echo cs_booking_request_input('email'); ?> "> <?php echo rtb_print_form_error('email'); ?> </div> </div> <div class="row"> <div class="phone col-xs-12 col-sm-6 col-md-6 col-lg-6"> <input type="text" name="rtb-phone" id="rtb-phone" placeholder="<?php _e('Phone', THEMENAME); ?> " value="<?php echo cs_booking_request_input('phone'); ?> "> <?php echo rtb_print_form_error('phone'); ?> </div> <div class="message col-xs-12 col-sm-6 col-md-6 col-lg-6"> <?php echo rtb_print_form_error('message'); ?> <input type="text" name="rtb-message" id="rtb-message" placeholder="<?php _e('Message', THEMENAME); ?> " value="<?php echo cs_booking_request_input('message'); ?> "> </div> </div> <?php do_action('rtb_booking_form_after_fields'); ?> <div class="cs-bookTable-submit"> <button class="btn btn-default" type="submit"><?php _e('BOOK MY TABLE', THEMENAME); ?> </button> <span class="des-text"><?php echo _e('Please submit your reservation details and we will contact you to confirm your booking ', THEMENAME); ?> </span> </div> </form> <?php } ?> </div> <?php $output = ob_get_clean(); $output = apply_filters('rtb_booking_form_html_post', $output); return $output; }
function rtb_print_form_textarea_field($slug, $title, $value) { $slug = esc_attr($slug); ?> <div class="<?php echo $slug; ?> "> <?php echo rtb_print_form_error($slug); ?> <label for="rtb-<?php echo $slug; ?> "> <?php _e($title, RTB_TEXTDOMAIN); ?> </label> <textarea name="rtb-<?php echo $slug; ?> " id="rtb-<?php echo $slug; ?> "><?php echo $value; ?> </textarea> </div> <?php }