| @@ -110,11 +110,11 @@ | ||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | foreach ( |
| 113 | 113 | [ |
| 114 | - SettingsService::getString('destination_base', 'destination'), | |
| 115 | - SettingsService::getString('activity_base', 'activity'), | |
| 116 | - SettingsService::getString('trip_category_base', 'trip-category'), | |
| 114 | + SettingsService::getDestinationBase(), | |
| 115 | + SettingsService::getActivityBase(), | |
| 116 | + SettingsService::getTripCategoryBase(), | |
| 117 | 117 | ] as $base |
| 118 | 118 | ) { |
| 119 | 119 | $bk = preg_replace('/[^a-z0-9_-]/i', '', $base) ?: ''; |
| 120 | 120 | if ($bk === '' || $bk === $tripSlugKey) { |
| @@ -127,12 +127,8 @@ | ||
| 127 | 127 | return true; |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if (!empty($_GET['yatra_login_page'])) { | |
| 132 | - return true; | |
| 133 | - } | |
| 134 | - | |
| 135 | 131 | if (!empty($_GET['reference']) && is_string($_GET['reference']) && trim(wp_unslash($_GET['reference'])) !== '') { |
| 136 | 132 | return true; |
| 137 | 133 | } |
| 138 | 134 | |
| @@ -175,9 +171,11 @@ | ||
| 175 | 171 | $rem = isset($_GET['yatra_remaining_checkout']) ? (string) wp_unslash($_GET['yatra_remaining_checkout']) : ''; |
| 176 | 172 | if ($rem !== '') { |
| 177 | 173 | $t = preg_replace('/[^a-zA-Z0-9_-]/', '', $rem) ?? ''; |
| 178 | 174 | if ($t !== '') { |
| 179 | - return trailingslashit(home_url('/remaining-checkout/' . $t . '/')); | |
| 175 | + $pb = SettingsService::getPermalinkBases(); | |
| 176 | + | |
| 177 | + return trailingslashit(home_url('/' . $pb['remaining_checkout_prefix'] . '/' . $t . '/')); | |
| 180 | 178 | } |
| 181 | 179 | } |
| 182 | 180 | |
| 183 | 181 | $verify = isset($_GET['yatra_verify_email']) ? (string) wp_unslash($_GET['yatra_verify_email']) : ''; |
| @@ -183,22 +181,20 @@ | ||
| 183 | 181 | $verify = isset($_GET['yatra_verify_email']) ? (string) wp_unslash($_GET['yatra_verify_email']) : ''; |
| 184 | 182 | if ($verify !== '') { |
| 185 | 183 | $t = preg_replace('/[^a-zA-Z0-9_-]/', '', $verify) ?? ''; |
| 186 | 184 | if ($t !== '') { |
| 187 | - return trailingslashit(home_url('/yatra-verify-email/' . $t . '/')); | |
| 185 | + $pb = SettingsService::getPermalinkBases(); | |
| 186 | + | |
| 187 | + return trailingslashit(home_url('/' . $pb['email_verification_prefix'] . '/' . $t . '/')); | |
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if (!empty($_GET['yatra_login_page'])) { | |
| 192 | - return trailingslashit(home_url('/login/')); | |
| 193 | - } | |
| 194 | - | |
| 195 | 191 | $trip_base = SettingsService::getTripBase(); |
| 196 | 192 | $booking_base = SettingsService::getBookingBase(); |
| 197 | 193 | $account_base = SettingsService::getAccountBase(); |
| 198 | - $dest_base = SettingsService::getString('destination_base', 'destination'); | |
| 199 | - $act_base = SettingsService::getString('activity_base', 'activity'); | |
| 200 | - $cat_base = SettingsService::getString('trip_category_base', 'trip-category'); | |
| 194 | + $dest_base = SettingsService::getDestinationBase(); | |
| 195 | + $act_base = SettingsService::getActivityBase(); | |
| 196 | + $cat_base = SettingsService::getTripCategoryBase(); | |
| 201 | 197 | |
| 202 | 198 | $rawPage = isset($_GET['yatra_page']) ? trim(wp_unslash((string) $_GET['yatra_page'])) : ''; |
| 203 | 199 | $page = $rawPage !== '' ? (preg_replace('/[^a-z0-9_-]/i', '', $rawPage) ?? '') : ''; |
| 204 | 200 | |
| @@ -204,13 +200,13 @@ | ||
| 204 | 200 | |
| 205 | 201 | $tripSlugKey = preg_replace('/[^a-z0-9_-]/i', '', $trip_base) ?: 'trip'; |
| 206 | 202 | $tripSlug = ''; |
| 207 | 203 | if (isset($_GET[$tripSlugKey])) { |
| 208 | - $tripSlug = sanitize_title(wp_unslash((string) $_GET[$tripSlugKey])); | |
| 204 | + $tripSlug = \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET[$tripSlugKey])); | |
| 209 | 205 | } elseif (isset($_GET['yatra_trip'])) { |
| 210 | - $tripSlug = sanitize_title(wp_unslash((string) $_GET['yatra_trip'])); | |
| 206 | + $tripSlug = \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET['yatra_trip'])); | |
| 211 | 207 | } elseif (isset($_GET['yatra_trip_slug'])) { |
| 212 | - $tripSlug = sanitize_title(wp_unslash((string) $_GET['yatra_trip_slug'])); | |
| 208 | + $tripSlug = \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET['yatra_trip_slug'])); | |
| 213 | 209 | } |
| 214 | 210 | |
| 215 | 211 | if ($page === '' && $tripSlug !== '') { |
| 216 | 212 | return trailingslashit(home_url('/' . $trip_base . '/' . $tripSlug . '/')); |
| @@ -232,12 +228,12 @@ | ||
| 232 | 228 | continue; |
| 233 | 229 | } |
| 234 | 230 | $s = ''; |
| 235 | 231 | if (isset($_GET[$bk])) { |
| 236 | - $s = sanitize_title(wp_unslash((string) $_GET[$bk])); | |
| 232 | + $s = \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET[$bk])); | |
| 237 | 233 | } |
| 238 | 234 | if ($s === '' && isset($_GET[$legacySlugKey])) { |
| 239 | - $s = sanitize_title(wp_unslash((string) $_GET[$legacySlugKey])); | |
| 235 | + $s = \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET[$legacySlugKey])); | |
| 240 | 236 | } |
| 241 | 237 | if ($s !== '') { |
| 242 | 238 | return trailingslashit(home_url('/' . $tbase . '/' . $s . '/')); |
| 243 | 239 | } |
| @@ -266,9 +262,9 @@ | ||
| 266 | 262 | return function_exists('yatra_get_trip_listing_url') ? yatra_get_trip_listing_url() : trailingslashit(home_url('/' . $trip_base . '/')); |
| 267 | 263 | } |
| 268 | 264 | |
| 269 | 265 | if ($page === $booking_base && !SettingsService::useCustomBookingPage()) { |
| 270 | - $tripParam = isset($_GET['trip']) ? sanitize_title(wp_unslash((string) $_GET['trip'])) : ''; | |
| 266 | + $tripParam = isset($_GET['trip']) ? \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET['trip'])) : ''; | |
| 271 | 267 | if ($tripParam !== '') { |
| 272 | 268 | return function_exists('yatra_get_booking_url') ? yatra_get_booking_url($tripParam) : trailingslashit(home_url('/' . $booking_base . '/' . $tripParam . '/')); |
| 273 | 269 | } |
| 274 | 270 | |
| @@ -279,9 +275,9 @@ | ||
| 279 | 275 | $page_id = SettingsService::getBookingPageId(); |
| 280 | 276 | if ($page_id > 0) { |
| 281 | 277 | $url = get_permalink((int) $page_id); |
| 282 | 278 | if ($url) { |
| 283 | - $tripParam = isset($_GET['trip']) ? sanitize_title(wp_unslash((string) $_GET['trip'])) : ''; | |
| 279 | + $tripParam = isset($_GET['trip']) ? \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET['trip'])) : ''; | |
| 284 | 280 | if ($tripParam !== '') { |
| 285 | 281 | return add_query_arg('trip', $tripParam, $url); |
| 286 | 282 | } |
| 287 | 283 | |
| @@ -304,12 +300,12 @@ | ||
| 304 | 300 | } |
| 305 | 301 | $bk = preg_replace('/[^a-z0-9_-]/i', '', $base) ?: ''; |
| 306 | 302 | $slug = ''; |
| 307 | 303 | if ($bk !== '' && isset($_GET[$bk])) { |
| 308 | - $slug = sanitize_title(wp_unslash((string) $_GET[$bk])); | |
| 304 | + $slug = \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET[$bk])); | |
| 309 | 305 | } |
| 310 | 306 | if ($slug === '' && isset($_GET[$legacySlugKey])) { |
| 311 | - $slug = sanitize_title(wp_unslash((string) $_GET[$legacySlugKey])); | |
| 307 | + $slug = \Yatra\Helpers\SlugHelper::generate(wp_unslash((string) $_GET[$legacySlugKey])); | |
| 312 | 308 | } |
| 313 | 309 | $url = trailingslashit(home_url('/' . $base . '/')); |
| 314 | 310 | if ($slug !== '') { |
| 315 | 311 | $url = trailingslashit(home_url('/' . $base . '/' . $slug . '/')); |
| @@ -409,11 +405,11 @@ | ||
| 409 | 405 | */ |
| 410 | 406 | private static function plainQueryKeysToStrip(): array |
| 411 | 407 | { |
| 412 | 408 | $tripKey = preg_replace('/[^a-z0-9_-]/i', '', SettingsService::getTripBase()) ?: 'trip'; |
| 413 | - $destKey = preg_replace('/[^a-z0-9_-]/i', '', SettingsService::getString('destination_base', 'destination')) ?: 'destination'; | |
| 414 | - $actKey = preg_replace('/[^a-z0-9_-]/i', '', SettingsService::getString('activity_base', 'activity')) ?: 'activity'; | |
| 415 | - $catKey = preg_replace('/[^a-z0-9_-]/i', '', SettingsService::getString('trip_category_base', 'trip-category')) ?: 'trip-category'; | |
| 409 | + $destKey = preg_replace('/[^a-z0-9_-]/i', '', SettingsService::getDestinationBase()) ?: 'destination'; | |
| 410 | + $actKey = preg_replace('/[^a-z0-9_-]/i', '', SettingsService::getActivityBase()) ?: 'activity'; | |
| 411 | + $catKey = preg_replace('/[^a-z0-9_-]/i', '', SettingsService::getTripCategoryBase()) ?: 'trip-category'; | |
| 416 | 412 | |
| 417 | 413 | return array_values(array_unique([ |
| 418 | 414 | 'yatra_page', |
| 419 | 415 | 'yatra_trip', |
| @@ -423,9 +419,8 @@ | ||
| 423 | 419 | 'yatra_category_slug', |
| 424 | 420 | 'yatra_booking_confirmation', |
| 425 | 421 | 'yatra_remaining_checkout', |
| 426 | 422 | 'yatra_verify_email', |
| 427 | - 'yatra_login_page', | |
| 428 | 423 | 'reference', |
| 429 | 424 | 'trip', |
| 430 | 425 | 'paged', |
| 431 | 426 | 'page', |