public function process_shortcode($args = array(), $content = '') { global $wpdb, $appointments; $args = wp_parse_args($args, $this->_defaults_to_args()); extract($args); $appointments->get_lsw(); if (!trim($args['order_by'])) { $args['order_by'] = 'ID'; } if ($args['worker']) { $services = appointments_get_worker_services($args['worker']); // Find first service by this worker $fsby = $services[0]->ID; if ($fsby && !@$_REQUEST['app_service_id']) { $_REQUEST['app_service_id'] = $fsby; // Set this as first service $appointments->get_lsw(); // Update } // Re-sort worker services if (!empty($services) && !empty($args['order_by']) && 'ID' !== $args['order_by']) { $services = $this->_reorder_services($services, $args['order_by']); } } else { $services = $appointments->get_services($args['order_by']); } $services = apply_filters('app_services', $services); // If there are no workers do nothing if (!$services || empty($services)) { return ''; } ob_start(); ?> <div class="app_services"> <div class="app_services_dropdown"> <div class="app_services_dropdown_title" id="app_services_dropdown_title"> <?php echo $args['select']; ?> </div> <div class="app_services_dropdown_select"> <select id="app_select_services" name="app_select_services" class="app_select_services"> <?php foreach ($services as $service) { ?> <option value="<?php echo $service->ID; ?> " <?php selected($service->ID, $appointments->service); ?> ><?php echo stripslashes($service->name); ?> </option> <?php } ?> </select> <input type="button" class="app_services_button" value="<?php echo esc_attr($args['show']); ?> "> </div> </div> <div class="app_service_excerpts"> <?php if ($args['autorefresh']) { // Only display the selected service ?> <?php $service = appointments_get_service($appointments->service); if ($service) { $page = apply_filters('app_service_page', $service->page, $service->ID); ?> <div class="app_service_excerpt" id="app_service_excerpt_<?php echo $service->ID; ?> "> <?php $service_description = ''; switch ($args['description']) { case 'none': break; case 'content': $service_description = $appointments->get_content($page, $args['thumb_size'], $args['thumb_class'], $service->ID); break; default: $service_description = $appointments->get_excerpt($page, $args['thumb_size'], $args['thumb_class'], $service->ID); break; } echo apply_filters('app-services-service_description', $service_description, $service, $args['description']); ?> </div> <?php } ?> <?php } else { ?> <?php foreach ($services as $service) { ?> <?php $page = apply_filters('app_service_page', $service->page, $service->ID); ?> <div <?php echo $service->ID != $appointments->service ? 'style="display:none"' : ''; ?> class="app_service_excerpt" id="app_service_excerpt_<?php echo $service->ID; ?> "> <?php $service_description = ''; switch ($args['description']) { case 'none': break; case 'content': $service_description = $appointments->get_content($page, $args['thumb_size'], $args['thumb_class'], $service->ID, absint($args['ajax'])); break; default: $service_description = $appointments->get_excerpt($page, $args['thumb_size'], $args['thumb_class'], $service->ID, absint($args['ajax'])); break; } echo apply_filters('app-services-service_description', $service_description, $service, $args['description']); ?> </div> <?php } ?> <?php } ?> </div> </div> <?php $s = ob_get_clean(); $wcalendar = isset($_GET['wcalendar']) && (int) $_GET['wcalendar'] ? (int) $_GET['wcalendar'] : false; // First remove these parameters and add them again to make wcalendar appear before js variable $href = add_query_arg(array("wcalendar" => false, "app_provider_id" => false, "app_service_id" => false)); $href = apply_filters('app_service_href', add_query_arg(array("wcalendar" => $wcalendar, "app_service_id" => "__selected_service__"), $href)); $href = $this->_js_esc_url($href) . '#app_services_dropdown_title'; if (!$args['_noscript']) { wp_enqueue_script('app-shortcode-services', appointments_plugin_url() . 'includes/shortcodes/js/app-services.js', array('jquery')); $ajax_url = admin_url('admin-ajax.php'); if (!is_ssl() && force_ssl_admin()) { $ajax_url = admin_url('admin-ajax.php', 'http'); } $i10n = array('size' => $args['thumb_size'], 'worker' => $args['worker'], 'ajaxurl' => $ajax_url, 'thumbclass' => $args['thumb_class'], 'autorefresh' => $args['autorefresh'], 'ajax' => $args['ajax'], 'first_service_id' => (int) $appointments->get_first_service_id(), 'reload_url' => $href); wp_localize_script('app-shortcode-services', 'appointmentsStrings', $i10n); } return $s; }
public function process_shortcode($args = array(), $content = '') { $args = wp_parse_args($args, $this->_defaults_to_args()); extract($args); global $appointments; // Get user form data from his cookie if (isset($_COOKIE["wpmudev_appointments_userdata"])) { $data = unserialize(stripslashes($_COOKIE["wpmudev_appointments_userdata"])); } else { $data = array(); } $n = isset($data["n"]) ? sanitize_text_field($data["n"]) : ''; // Name $e = isset($data["e"]) ? sanitize_text_field($data["e"]) : ''; // Email $p = isset($data["p"]) ? sanitize_text_field($data["p"]) : ''; // Phone $a = isset($data["a"]) ? sanitize_text_field($data["a"]) : ''; // Address $c = isset($data["c"]) ? sanitize_text_field($data["c"]) : ''; // City $g = isset($data["g"]) ? sanitize_text_field($data["g"]) : ''; // GCal selection if ($g) { $gcal_checked = ' checked="checked"'; } else { $gcal_checked = ''; } // User may have already saved his data before if (is_user_logged_in()) { global $current_user; $user_info = get_userdata($current_user->ID); $name_meta = get_user_meta($current_user->ID, 'app_name', true); if ($name_meta) { $n = $name_meta; } else { if ($user_info->display_name) { $n = $user_info->display_name; } else { if ($user_info->user_nicename) { $n = $user_info->user_nicename; } else { if ($user_info->user_login) { $n = $user_info->user_login; } } } } $email_meta = get_user_meta($current_user->ID, 'app_email', true); if ($email_meta) { $e = $email_meta; } else { if ($user_info->user_email) { $e = $user_info->user_email; } } $phone_meta = get_user_meta($current_user->ID, 'app_phone', true); if ($phone_meta) { $p = $phone_meta; } $address_meta = get_user_meta($current_user->ID, 'app_address', true); if ($address_meta) { $a = $address_meta; } $city_meta = get_user_meta($current_user->ID, 'app_city', true); if ($city_meta) { $c = $city_meta; } } $ret = ''; ob_start(); ?> <div class="appointments-confirmation-wrapper"> <fieldset> <legend><?php echo $args['title']; ?> </legend> <div class="appointments-confirmation-service"></div> <div class="appointments-confirmation-worker" style="display:none"></div> <div class="appointments-confirmation-start"></div> <div class="appointments-confirmation-end"></div> <div class="appointments-confirmation-price" style="display:none"></div> <div class="appointments-name-field" style="display:none"> <label> <span><?php echo $args['name']; ?> </span> <input type="text" class="appointments-name-field-entry" id="<?php echo esc_attr(apply_filters('app-shortcode-confirmation-name_field_id', 'appointments-field-customer_name')); ?> " value="<?php echo esc_attr($n); ?> " /> </label> </div> <div class="appointments-email-field" style="display:none"> <label> <span><?php echo $args['email']; ?> </span> <input type="text" class="appointments-email-field-entry" id="<?php echo esc_attr(apply_filters('app-shortcode-confirmation-email_field_id', 'appointments-field-customer_email')); ?> " value="<?php echo esc_attr($e); ?> " /> </label> </div> <div class="appointments-phone-field" style="display:none"> <label> <span><?php echo $args['phone']; ?> </span> <input type="text" class="appointments-phone-field-entry" id="<?php echo esc_attr(apply_filters('app-shortcode-confirmation-phone_field_id', 'appointments-field-customer_phone')); ?> " value="<?php echo esc_attr($p); ?> " /> </label> </div> <div class="appointments-address-field" style="display:none"> <label> <span><?php echo $args['address']; ?> </span> <input type="text" class="appointments-address-field-entry" id="<?php echo esc_attr(apply_filters('app-shortcode-confirmation-address_field_id', 'appointments-field-customer_address')); ?> " value="<?php echo esc_attr($a); ?> " /> </label> </div> <div class="appointments-city-field" style="display:none"> <label> <span><?php echo $args['city']; ?> </span> <input type="text" class="appointments-city-field-entry" id="<?php echo esc_attr(apply_filters('app-shortcode-confirmation-city_field_id', 'appointments-field-customer_city')); ?> " value="<?php echo esc_attr($c); ?> " /> </label> </div> <div class="appointments-note-field" style="display:none"> <label> <span><?php echo $args['note']; ?> </span> <input type="text" class="appointments-note-field-entry" id="<?php echo esc_attr(apply_filters('app-shortcode-confirmation-note_field_id', 'appointments-field-customer_note')); ?> " /> </label> </div> <div class="appointments-gcal-field" style="display:none"> <label> <span><?php echo $appointments->gcal_image; ?> </span> <input type="checkbox" class="appointments-gcal-field-entry" id="<?php echo esc_attr(apply_filters('app-shortcode-confirmation-gcal_field_id', 'appointments-field-customer_gcal')); ?> " <?php echo $gcal_checked; ?> /> <?php echo $args['gcal']; ?> </label> </div> <?php $ret = apply_filters('app_additional_fields', ob_get_clean()); ?> <?php ob_start(); ?> <div style="clear:both"></div> <div class="appointments-confirmation-buttons"> <input type="hidden" class="appointments-confirmation-final-value" /> <input type="button" class="appointments-confirmation-button" value="<?php echo esc_attr($button_text); ?> " /> <input type="button" class="appointments-confirmation-cancel-button" value="<?php echo esc_attr_x('Cancel', 'Drop current action', 'appointments'); ?> " /> </div> </fieldset> </div> <?php $ret = apply_filters('app_confirmation_fields', $ret . ob_get_clean()); wp_enqueue_script('app-shortcode-confirmation', appointments_plugin_url() . 'includes/shortcodes/js/app-confirmation.js', array('jquery')); $i10n = array('waitingGif' => appointments_plugin_url() . 'images/waiting.gif', 'isUserLoggedIn' => is_user_logged_in(), 'loginRequired' => $appointments->options["login_required"], 'ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce(), 'askName' => $appointments->options["ask_name"], 'askEmail' => $appointments->options["ask_email"], 'askPhone' => $appointments->options["ask_phone"], 'askAddress' => $appointments->options["ask_address"], 'askCity' => $appointments->options["ask_city"], 'askGCal' => isset($appointments->options["gcal"]) && 'yes' == $appointments->options["gcal"], 'warningText' => esc_js($args['warning_text']), 'confirmationText' => esc_js($args['confirm_text']), 'connectionErrorText' => esc_js(__('A connection problem occurred. Please try again.', 'appointments'))); wp_localize_script('app-shortcode-confirmation', 'AppShortcodeConfirmation', $i10n); return $ret; }