|
3 | 3 | * Multisite Language Switcher Plugin |
4 | 4 | * |
5 | 5 | * Plugin Name: Multisite Language Switcher |
6 | | - * Version: 2.10.1 |
| 6 | + * Version: 3.0.0 |
7 | 7 | * Plugin URI: http://msls.co/ |
8 | 8 | * Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation. |
9 | 9 | * Author: Dennis Ploetner |
|
45 | 45 | * @author Dennis Ploetner <re@lloc.de> |
46 | 46 | */ |
47 | 47 | if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) { |
48 | | - define( 'MSLS_PLUGIN_VERSION', '2.10.1' ); |
| 48 | + define( 'MSLS_PLUGIN_VERSION', '3.0.0' ); |
49 | 49 | define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) ); |
50 | 50 | define( 'MSLS_PLUGIN__FILE__', __FILE__ ); |
51 | 51 |
|
52 | 52 | require_once __DIR__ . '/includes/aliases.php'; |
53 | 53 | require_once __DIR__ . '/includes/deprectated.php'; |
| 54 | + require_once __DIR__ . '/includes/api.php'; |
54 | 55 |
|
55 | | - /** |
56 | | - * Get the output for using the links to the translations in your code |
57 | | - * |
58 | | - * @package Msls |
59 | | - * @param mixed $attr |
60 | | - * @return string |
61 | | - */ |
62 | | - function msls_get_switcher( $attr ): string { |
63 | | - $arr = is_array( $attr ) ? $attr : array(); |
64 | | - $obj = apply_filters( 'msls_get_output', null ); |
65 | | - |
66 | | - return ! is_null( $obj ) ? strval( $obj->set_tags( $arr ) ) : ''; |
67 | | - } |
68 | | - |
69 | | - /** |
70 | | - * Output the links to the translations in your template |
71 | | - * |
72 | | - * You can call this function directly like that |
73 | | - * |
74 | | - * if ( function_exists ( 'the_msls' ) ) |
75 | | - * the_msls(); |
76 | | - * |
77 | | - * or just use it as shortcode [sc_msls] |
78 | | - * |
79 | | - * @package Msls |
80 | | - * @uses get_the_msls |
81 | | - * |
82 | | - * @param string[] $arr |
83 | | - */ |
84 | | - function msls_the_switcher( array $arr = array() ): void { |
85 | | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
86 | | - echo msls_get_switcher( $arr ); |
87 | | - } |
88 | | - |
89 | | - /** |
90 | | - * Gets the URL of the country flag-icon for a specific locale |
91 | | - * |
92 | | - * @param string $locale |
93 | | - * |
94 | | - * @return string |
95 | | - */ |
96 | | - function msls_get_flag_url( string $locale ): string { |
97 | | - return ( new \lloc\Msls\Options\Options() )->get_flag_url( $locale ); |
98 | | - } |
99 | | - |
100 | | - /** |
101 | | - * Gets the description for a blog for a specific locale |
102 | | - * |
103 | | - * @param string $locale |
104 | | - * @param string $preset |
105 | | - * |
106 | | - * @return string |
107 | | - */ |
108 | | - function msls_get_blog_description( string $locale, string $preset = '' ): string { |
109 | | - $blog = msls_blog( $locale ); |
110 | | - |
111 | | - return $blog ? $blog->get_description() : $preset; |
112 | | - } |
113 | | - |
114 | | - /** |
115 | | - * Gets the permalink for a translation of the current post in a given language |
116 | | - * |
117 | | - * @param string $locale |
118 | | - * @param string $preset |
119 | | - * |
120 | | - * @return string |
121 | | - */ |
122 | | - function msls_get_permalink( string $locale, string $preset = '' ): string { |
123 | | - $url = null; |
124 | | - $blog = msls_blog( $locale ); |
125 | | - |
126 | | - if ( $blog ) { |
127 | | - $options = \lloc\Msls\Options\Options::create(); |
128 | | - $url = $blog->get_url( $options ); |
129 | | - } |
130 | | - |
131 | | - return $url ?? $preset; |
132 | | - } |
133 | | - |
134 | | - /** |
135 | | - * Looks for the Blog instance for a specific locale |
136 | | - * |
137 | | - * @param string $locale |
138 | | - * |
139 | | - * @return \lloc\Msls\Blog\Blog|null |
140 | | - */ |
141 | | - function msls_blog( string $locale ): ?\lloc\Msls\Blog\Blog { |
142 | | - return msls_blog_collection()->get_blog( $locale ); |
143 | | - } |
144 | | - |
145 | | - /** |
146 | | - * Gets the Blog Collection instance |
147 | | - * |
148 | | - * @return \lloc\Msls\Blog\Collection |
149 | | - */ |
150 | | - function msls_blog_collection(): \lloc\Msls\Blog\Collection { |
151 | | - return \lloc\Msls\Blog\Collection::instance(); |
152 | | - } |
153 | | - |
154 | | - /** |
155 | | - * Gets the Options instance |
156 | | - * |
157 | | - * @return \lloc\Msls\Options\Options |
158 | | - */ |
159 | | - function msls_options(): \lloc\Msls\Options\Options { |
160 | | - return \lloc\Msls\Options\Options::instance(); |
161 | | - } |
162 | | - |
163 | | - /** |
164 | | - * Gets the MslsContentTypes instance |
165 | | - * |
166 | | - * @return \lloc\Msls\ContentTypes\ContentTypes |
167 | | - */ |
168 | | - function msls_content_types(): \lloc\Msls\ContentTypes\ContentTypes { |
169 | | - return \lloc\Msls\ContentTypes\ContentTypes::create(); |
170 | | - } |
171 | | - |
172 | | - /** |
173 | | - * Gets the MslsPostType instance |
174 | | - * |
175 | | - * @return \lloc\Msls\ContentTypes\PostType |
176 | | - */ |
177 | | - function msls_post_type(): \lloc\Msls\ContentTypes\PostType { |
178 | | - return \lloc\Msls\ContentTypes\PostType::instance(); |
179 | | - } |
180 | | - |
181 | | - /** |
182 | | - * Gets the MslsTaxonomy instance |
183 | | - * |
184 | | - * @return \lloc\Msls\ContentTypes\Taxonomy |
185 | | - */ |
186 | | - function msls_taxonomy(): \lloc\Msls\ContentTypes\Taxonomy { |
187 | | - return \lloc\Msls\ContentTypes\Taxonomy::instance(); |
188 | | - } |
189 | | - |
190 | | - /** |
191 | | - * Gets the Output instance |
192 | | - * |
193 | | - * @return \lloc\Msls\Frontend\Output |
194 | | - */ |
195 | | - function msls_output(): \lloc\Msls\Frontend\Output { |
196 | | - return \lloc\Msls\Frontend\Output::create(); |
197 | | - } |
198 | | - |
199 | | - /** |
200 | | - * Retrieves the OptionsPost instance. |
201 | | - * |
202 | | - * @param int $id |
203 | | - * |
204 | | - * @return \lloc\Msls\Options\Post\Post |
205 | | - */ |
206 | | - function msls_get_post( int $id ): \lloc\Msls\Options\Post\Post { |
207 | | - return new \lloc\Msls\Options\Post\Post( $id ); |
208 | | - } |
209 | | - |
210 | | - /** |
211 | | - * Retrieves the OptionsTax instance. |
212 | | - * |
213 | | - * Determines the current query based on conditional tags: |
214 | | - * - is_category |
215 | | - * - is_tag |
216 | | - * - is_tax |
217 | | - * |
218 | | - * @param int $id |
219 | | - * @return \lloc\Msls\Options\Tax\OptionsTaxInterface |
220 | | - */ |
221 | | - function msls_get_tax( int $id ): \lloc\Msls\Options\Tax\OptionsTaxInterface { |
222 | | - return \lloc\Msls\Options\Tax\Tax::create( $id ); |
223 | | - } |
224 | | - |
225 | | - /** |
226 | | - * Retrieves the OptionsQuery instance. |
227 | | - * |
228 | | - * Determines the current query based on conditional tags: |
229 | | - * - is_day |
230 | | - * - is_month |
231 | | - * - is_year |
232 | | - * - is_author |
233 | | - * - is_post_type_archive |
234 | | - * |
235 | | - * @return ?\lloc\Msls\Options\Query\Query |
236 | | - */ |
237 | | - function msls_get_query(): ?\lloc\Msls\Options\Query\Query { |
238 | | - return \lloc\Msls\Options\Query\Query::create(); |
239 | | - } |
240 | | - |
241 | | - /** |
242 | | - * Trivial void function for actions that do not return anything. |
243 | | - * |
244 | | - * @return void |
245 | | - */ |
246 | | - function msls_return_void(): void { |
247 | | - } |
248 | | - |
249 | | - lloc\Msls\MslsPlugin::init(); |
| 56 | + lloc\Msls\Plugin::init(); |
250 | 57 | lloc\Msls\Cli\Cli::init(); |
251 | 58 | } |
0 commit comments