PluginProbe
Listdom: AI-powered Business Directory with Classifieds Ads Listings / trunk
Listdom: AI-powered Business Directory with Classifieds Ads Listings vtrunk
6.0.0 5.9.0 5.8.1 5.8.0 5.7.0 5.6.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.2.1 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.8.0 1.9.0 All 75 releases
listdom / app / includes / api.php

api.php in Listdom: AI-powered Business Directory with Classifieds Ads Listings trunk, at app/includes/api.php

39 lines 841 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class LSD_API extends LSD_Base
4 {
5 public string $namespace = 'listdom/v1';
6 public string $version = '1';
7 protected LSD_db $db;
8
9 public function __construct()
10 {
11 // DB Library
12 $this->db = new LSD_db();
13 }
14
15 public function init()
16 {
17 add_action('rest_api_init', [$this, 'language'], 20);
18
19 $routes = new LSD_API_Routes();
20 $routes->init();
21 }
22
23 public function language()
24 {
25 // Requested Language
26 $locale = null;
27 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && is_string($_SERVER['HTTP_ACCEPT_LANGUAGE']))
28 {
29 $locale = sanitize_text_field(wp_unslash($_SERVER['HTTP_ACCEPT_LANGUAGE']));
30 }
31
32 // No Locale
33 if (!$locale) return;
34
35 // Switch the Language
36 LSD_i18n::set($locale);
37 }
38 }
39