Container
1 week ago
UI
1 week ago
ActionFilterLoader.php
1 week ago
DependencyAssets.php
1 week ago
IStandAloneAction.php
4 years ago
NullSitePress.php
1 week ago
NullSitePress.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\StandAlone; |
| 4 | |
| 5 | use WPML\Core\ISitePress; |
| 6 | use WPML_WP_API; |
| 7 | |
| 8 | class NullSitePress implements ISitePress { |
| 9 | |
| 10 | private ?WPML_WP_API $wp_api = null; |
| 11 | |
| 12 | public function get_active_languages( $refresh = false, $major_first = false, $order_by = 'english_name' ) { |
| 13 | $code = $this->get_current_language(); |
| 14 | return [ |
| 15 | $code => [ |
| 16 | 'id' => 1, |
| 17 | 'code' => $code, |
| 18 | 'major' => 1, |
| 19 | 'active' => 1, |
| 20 | 'default_locale' => get_locale(), |
| 21 | 'encode_url' => 0, |
| 22 | 'tag' => $code, |
| 23 | 'english_name' => $code, |
| 24 | 'native_name' => $code, |
| 25 | 'display_name' => $code, |
| 26 | ], |
| 27 | ]; |
| 28 | } |
| 29 | |
| 30 | public function get_admin_language() { |
| 31 | return $this->get_current_language(); |
| 32 | } |
| 33 | |
| 34 | public function get_current_language() { |
| 35 | return preg_replace( '/_.+/', '', get_locale() ); |
| 36 | } |
| 37 | |
| 38 | public function switch_lang( $code = null, $cookie_lang = false ) { |
| 39 | |
| 40 | } |
| 41 | |
| 42 | public function get_default_language() { |
| 43 | return $this->get_current_language(); |
| 44 | } |
| 45 | |
| 46 | public function get_element_translations( |
| 47 | $trid, |
| 48 | $el_type = 'post_post', |
| 49 | $skip_empty = false, |
| 50 | $all_statuses = false, |
| 51 | $skip_cache = false, |
| 52 | $skip_recursions = false, |
| 53 | $skipPrivilegeChecking = false |
| 54 | ) { |
| 55 | return []; |
| 56 | } |
| 57 | |
| 58 | public function get_flag_url( $code ) { |
| 59 | return ''; |
| 60 | } |
| 61 | |
| 62 | public function get_language_from_url( $url ) { |
| 63 | return $this->get_current_language(); |
| 64 | } |
| 65 | |
| 66 | public function get_search_form_filter( $form ) { |
| 67 | return $form; |
| 68 | } |
| 69 | |
| 70 | public function get_setting( $key, $default = false ) { |
| 71 | return $default; |
| 72 | } |
| 73 | |
| 74 | public function get_settings() { |
| 75 | return []; |
| 76 | } |
| 77 | |
| 78 | public function get_wp_api() { |
| 79 | if ( ! ( $this->wp_api instanceof \WPML_WP_API ) ) { |
| 80 | $this->wp_api = new WPML_WP_API(); |
| 81 | } |
| 82 | |
| 83 | return $this->wp_api; |
| 84 | } |
| 85 | |
| 86 | public function is_rtl( $lang = false ) { |
| 87 | return is_rtl(); |
| 88 | } |
| 89 | |
| 90 | public function get_language_for_element( $element_id, $element_type ) { |
| 91 | return $this->get_current_language(); |
| 92 | } |
| 93 | } |
| 94 |