| @@ -13,52 +13,56 @@ | ||
| 13 | 13 | $html = ''; |
| 14 | 14 | $app = App::getInstance(); |
| 15 | 15 | |
| 16 | 16 | foreach ($details as $location) { |
| 17 | + $locationType = Arr::get($location, 'type', ''); | |
| 18 | + $displayOnBooking = Arr::get($location, 'display_on_booking') === 'yes'; | |
| 19 | + $meetingLink = esc_html(Arr::get($location, 'meeting_link', '')); | |
| 20 | + $description = esc_html(Arr::get($location, 'description', '')); | |
| 21 | + $title = esc_html(Arr::get($location, 'title', '')); | |
| 22 | + $hostPhoneNumber = esc_html(Arr::get($location, 'host_phone_number', '')); | |
| 17 | 23 | |
| 18 | - $displayOnBooking = Arr::get($location, 'display_on_booking') == 'yes'; | |
| 19 | - | |
| 20 | 24 | $html .= '<div class="slot_location fcal_icon_item fcal_img_item fcal_loc_google_meet">'; |
| 21 | - if ($location['type'] == 'google_meet') { | |
| 25 | + if ($locationType == 'google_meet') { | |
| 22 | 26 | $html .= '<img class="fcal_loc_icon" src="' . $app['url.assets'] . 'images/g-meet.svg" alt="Google Meet" />'; |
| 23 | 27 | $html .= '<span class="fcal_loc_text">' . __('Google Meet', 'fluent-booking') . '</span>'; |
| 24 | - } else if ($location['type'] == 'ms_teams') { | |
| 28 | + } else if ($locationType == 'ms_teams') { | |
| 25 | 29 | $html .= '<img class="fcal_loc_icon" src="' . $app['url.assets'] . 'images/ms-teams.svg" alt="MS Teams" />'; |
| 26 | 30 | $html .= '<span class="fcal_loc_text">' . __('MS Teams', 'fluent-booking') . '</span>'; |
| 27 | - } else if ($location['type'] == 'zoom_meeting') { | |
| 31 | + } else if ($locationType == 'zoom_meeting') { | |
| 28 | 32 | $html .= '<img class="fcal_loc_icon zoom_icon" src="' . $app['url.assets'] . 'images/zoom.svg" alt="Zoom Icon" />'; |
| 29 | 33 | $html .= '<span class="fcal_loc_text">' . __('Zoom Video', 'fluent-booking') . '</span>'; |
| 30 | - } else if ($location['type'] == 'online_meeting') { | |
| 34 | + } else if ($locationType == 'online_meeting') { | |
| 31 | 35 | $html .= '<img class="fcal_loc_icon link_icon" src="' . $app['url.assets'] . 'images/link.svg" alt="Online Meeting" />'; |
| 32 | - if ($displayOnBooking == 'yes') { | |
| 33 | - $html .= '<span class="fcal_loc_text">' . '<span class="fcal_loc_title">' . $location['meeting_link'] . '</span>'; | |
| 36 | + if ($displayOnBooking) { | |
| 37 | + $html .= '<span class="fcal_loc_text"><span class="fcal_loc_title">' . $meetingLink . '</span>'; | |
| 34 | 38 | } else { |
| 35 | 39 | $html .= '<span class="fcal_loc_text">' . __('Online Meeting', 'fluent-booking') . '</span>'; |
| 36 | 40 | } |
| 37 | - } else if ($location['type'] == 'in_person_guest') { | |
| 41 | + } else if ($locationType == 'in_person_guest') { | |
| 38 | 42 | $html .= '<img class="fcal_loc_icon location_icon" src="' . $app['url.assets'] . 'images/physical_location.svg" alt="' . __('In Person', 'fluent-booking') . '" />'; |
| 39 | 43 | $html .= '<span class="fcal_loc_text">' . __('In Person (Attendee Address)', 'fluent-booking') . '</span>'; |
| 40 | - } else if ($location['type'] == 'custom') { | |
| 44 | + } else if ($locationType == 'custom') { | |
| 41 | 45 | $html .= '<img class="fcal_loc_icon location_icon" src="' . $app['url.assets'] . 'images/physical_location.svg" alt="' . __('Custom Icon', 'fluent-booking') . '" />'; |
| 42 | - if ($displayOnBooking == 'yes') { | |
| 43 | - $html .= '<span class="fcal_loc_text">' . $location['description'] . '</span>'; | |
| 46 | + if ($displayOnBooking) { | |
| 47 | + $html .= '<span class="fcal_loc_text">' . $description . '</span>'; | |
| 44 | 48 | } else { |
| 45 | - $html .= '<span class="fcal_loc_text">' . $location['title'] . '</span>'; | |
| 49 | + $html .= '<span class="fcal_loc_text">' . $title . '</span>'; | |
| 46 | 50 | } |
| 47 | - } else if ($location['type'] == 'in_person_organizer') { | |
| 51 | + } else if ($locationType == 'in_person_organizer') { | |
| 48 | 52 | $html .= '<img class="fcal_loc_icon location_icon" src="' . $app['url.assets'] . 'images/physical_location.svg" alt="' . __('In Person', 'fluent-booking') . '" />'; |
| 49 | - if ($displayOnBooking == 'yes') { | |
| 50 | - $html .= '<span class="fcal_loc_text">' . $location['description'] . '</span>'; | |
| 53 | + if ($displayOnBooking) { | |
| 54 | + $html .= '<span class="fcal_loc_text">' . $description . '</span>'; | |
| 51 | 55 | } else { |
| 52 | 56 | $html .= '<span class="fcal_loc_text">' . __('In Person (Organizer Address)', 'fluent-booking') . '</span>'; |
| 53 | 57 | } |
| 54 | - } else if ($location['type'] == 'phone_guest') { | |
| 58 | + } else if ($locationType == 'phone_guest') { | |
| 55 | 59 | $html .= '<img class="fcal_loc_icon phone_icon" src="' . $app['url.assets'] . 'images/phone_call.svg" alt="' . __('Phone', 'fluent-booking') . '" />'; |
| 56 | 60 | $html .= '<span class="fcal_loc_text">' . __('Attendee Phone Number', 'fluent-booking') . '</span>'; |
| 57 | - } else if ($location['type'] == 'phone_organizer') { | |
| 61 | + } else if ($locationType == 'phone_organizer') { | |
| 58 | 62 | $html .= '<img class="fcal_loc_icon phone_icon" src="' . $app['url.assets'] . 'images/phone_call.svg" alt="' . __('Phone', 'fluent-booking') . '" />'; |
| 59 | - if ($displayOnBooking == 'yes') { | |
| 60 | - $html .= '<span class="fcal_loc_text">' . $location['host_phone_number'] . '</span>'; | |
| 63 | + if ($displayOnBooking) { | |
| 64 | + $html .= '<span class="fcal_loc_text">' . $hostPhoneNumber . '</span>'; | |
| 61 | 65 | } else { |
| 62 | 66 | $html .= '<span class="fcal_loc_text">' . __('Phone Call', 'fluent-booking') . '</span>'; |
| 63 | 67 | } |
| 64 | 68 | } |
| @@ -86,9 +90,8 @@ | ||
| 86 | 90 | } |
| 87 | 91 | |
| 88 | 92 | public static function getLocationDetails($calendarEvent, $userInput = [], $allInput = []) |
| 89 | 93 | { |
| 90 | - $userInput = array_map('sanitize_text_field', $userInput); | |
| 91 | 94 | $locations = $calendarEvent->location_settings; |
| 92 | 95 | |
| 93 | 96 | if (empty($locations)) { |
| 94 | 97 | return [ |
| @@ -111,11 +114,11 @@ | ||
| 111 | 114 | 'driver' => $type . '__:__0' |
| 112 | 115 | ]; |
| 113 | 116 | |
| 114 | 117 | if ($type == 'phone_guest') { |
| 115 | - $userInput['user_location_input'] = Arr::get($allInput, 'phone_number'); | |
| 118 | + $userInput['user_location_input'] = sanitize_text_field(Arr::get($allInput, 'phone_number')); | |
| 116 | 119 | } else if ($type == 'in_person_guest') { |
| 117 | - $userInput['user_location_input'] = Arr::get($allInput, 'address'); | |
| 120 | + $userInput['user_location_input'] = sanitize_textarea_field(Arr::get($allInput, 'address')); | |
| 118 | 121 | } |
| 119 | 122 | } |
| 120 | 123 | |
| 121 | 124 | $keyedLocations = []; |
| @@ -122,9 +125,9 @@ | ||
| 122 | 125 | foreach ($locations as $index => $location) { |
| 123 | 126 | $keyedLocations[$location['type'] . '__:__' . $index] = $location; |
| 124 | 127 | } |
| 125 | 128 | |
| 126 | - $driver = Arr::get($userInput, 'driver'); | |
| 129 | + $driver = sanitize_text_field(Arr::get($userInput, 'driver')); | |
| 127 | 130 | |
| 128 | 131 | if (empty($keyedLocations[$driver])) { |
| 129 | 132 | return [ |
| 130 | 133 | 'type' => 'custom', |
| @@ -136,13 +139,18 @@ | ||
| 136 | 139 | |
| 137 | 140 | $selectedType = $selectedLocation['type']; |
| 138 | 141 | |
| 139 | 142 | // custom user input location types |
| 140 | - if (in_array($selectedType, ['in_person_guest', 'phone_guest'])) { | |
| 143 | + if ($selectedType === 'phone_guest') { | |
| 141 | 144 | return [ |
| 142 | 145 | 'type' => $selectedType, |
| 143 | - 'description' => Arr::get($userInput, 'user_location_input') | |
| 146 | + 'description' => sanitize_text_field(Arr::get($userInput, 'user_location_input')) | |
| 144 | 147 | ]; |
| 148 | + } else if ($selectedType === 'in_person_guest') { | |
| 149 | + return [ | |
| 150 | + 'type' => $selectedType, | |
| 151 | + 'description' => sanitize_textarea_field(Arr::get($userInput, 'user_location_input')) | |
| 152 | + ]; | |
| 145 | 153 | } |
| 146 | 154 | |
| 147 | 155 | // Check provided description location type to store as description |
| 148 | 156 | if (in_array($selectedType, ['custom', 'phone_organizer', 'in_person_organizer'])) { |
| @@ -185,9 +193,9 @@ | ||
| 185 | 193 | $locationOptions = []; |
| 186 | 194 | foreach ($locationSettings as $index => $location) { |
| 187 | 195 | $title = Arr::get($location, 'title'); |
| 188 | 196 | |
| 189 | - $locationType = Arr::get($location, 'type'); | |
| 197 | + $locationType = (string) Arr::get($location, 'type', ''); | |
| 190 | 198 | |
| 191 | 199 | if ($locationType == 'custom') { |
| 192 | 200 | if (Arr::get($location, 'display_on_booking') == 'yes') { |
| 193 | 201 | $title = Arr::get($location, 'description'); |
| @@ -196,9 +204,9 @@ | ||
| 196 | 204 | } |
| 197 | 205 | } |
| 198 | 206 | |
| 199 | 207 | if (!$title) { |
| 200 | - $title = str_replace('_', ' ', ucfirst($locationType)); | |
| 208 | + $title = $locationType === '' ? '' : str_replace('_', ' ', ucfirst($locationType)); | |
| 201 | 209 | } |
| 202 | 210 | |
| 203 | 211 | $slug = Arr::get($location, 'type') . '__:__' . $index; |
| 204 | 212 | |