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