PluginProbe
Polylang / 2.6.2
Polylang v2.6.2
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/api.php +8 -49 2.8.32.6.2 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Template tag: displays the language switcher
8 5 *
@@ -20,9 +17,8 @@
20 17 * post_id => if not null, link to translations of post defined by post_id, defaults to null
21 18 * raw => set this to true to build your own custom language switcher, defaults to 0
22 19 * item_spacing => whether to preserve or discard whitespace between list items, valid options are 'preserve' and 'discard', defaults to preserve
23 20 *
24 - * @api
25 21 * @since 0.5
26 22 *
27 23 * @param array $args optional
28 24 * @return null|string|array null if displaying, array if raw is requested, string otherwise
@@ -38,18 +34,14 @@
38 34 /**
39 35 * Returns the current language on frontend
40 36 * Returns the language set in admin language filter on backend ( false if set to all languages )
41 37 *
42 - * @api
43 38 * @since 0.8.1
44 39 *
45 - * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
46 - * @return string|PLL_Language|bool The requested field for the current language
40 + * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug'
41 + * @return string|bool The requested field for the current language
47 42 */
48 43 function pll_current_language( $field = 'slug' ) {
49 - if ( OBJECT === $field ) {
50 - return PLL()->curlang;
51 - }
52 44 return isset( PLL()->curlang->$field ) ? PLL()->curlang->$field : false;
53 45 }
54 46
55 47 /**
@@ -54,31 +46,20 @@
54 46
55 47 /**
56 48 * Returns the default language
57 49 *
58 - * @api
59 50 * @since 1.0
60 51 *
61 - * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
62 - * @return string|PLL_Language|bool The requested field for the default language
52 + * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug'
53 + * @return string The requested field for the default language
63 54 */
64 55 function pll_default_language( $field = 'slug' ) {
65 - if ( isset( PLL()->options['default_lang'] ) ) {
66 - $lang = PLL()->model->get_language( PLL()->options['default_lang'] );
67 - if ( $lang ) {
68 - if ( OBJECT === $field ) {
69 - return $lang;
70 - }
71 - return isset( $lang->$field ) ? $lang->$field : false;
72 - }
73 - }
74 - return false;
56 + return isset( PLL()->options['default_lang'] ) && ( $lang = PLL()->model->get_language( PLL()->options['default_lang'] ) ) && isset( $lang->$field ) ? $lang->$field : false;
75 57 }
76 58
77 59 /**
78 60 * Among the post and its translations, returns the id of the post which is in the language represented by $slug
79 61 *
80 - * @api
81 62 * @since 0.5
82 63 *
83 64 * @param int $post_id post id
84 65 * @param string $slug optional language code, defaults to current language
@@ -90,9 +71,8 @@
90 71
91 72 /**
92 73 * Among the term and its translations, returns the id of the term which is in the language represented by $slug
93 74 *
94 - * @api
95 75 * @since 0.5
96 76 *
97 77 * @param int $term_id term id
98 78 * @param string $slug optional language code, defaults to current language
@@ -104,9 +84,8 @@
104 84
105 85 /**
106 86 * Returns the home url in the current language
107 87 *
108 - * @api
109 88 * @since 0.8
110 89 *
111 90 * @param string $lang language code ( optional on frontend )
112 91 * @return string
@@ -121,9 +100,8 @@
121 100
122 101 /**
123 102 * Registers a string for translation in the "strings translation" panel
124 103 *
125 - * @api
126 104 * @since 0.6
127 105 *
128 106 * @param string $name a unique name for the string
129 107 * @param string $string the string to register
@@ -138,9 +116,8 @@
138 116
139 117 /**
140 118 * Translates a string ( previously registered with pll_register_string )
141 119 *
142 - * @api
143 120 * @since 0.6
144 121 *
145 122 * @param string $string the string to translate
146 123 * @return string the string translation in the current language
@@ -151,9 +128,8 @@
151 128
152 129 /**
153 130 * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output.
154 131 *
155 - * @api
156 132 * @since 2.1
157 133 *
158 134 * @param string $string the string to translate
159 135 * @return string translation in the current language
@@ -164,9 +140,8 @@
164 140
165 141 /**
166 142 * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes.
167 143 *
168 - * @api
169 144 * @since 2.1
170 145 *
171 146 * @param string $string The string to translate
172 147 * @return string
@@ -178,9 +153,8 @@
178 153 /**
179 154 * Echoes a translated string ( previously registered with pll_register_string )
180 155 * It is an equivalent of _e() and is not escaped.
181 156 *
182 - * @api
183 157 * @since 0.6
184 158 *
185 159 * @param string $string The string to translate
186 160 */
@@ -190,9 +164,8 @@
190 164
191 165 /**
192 166 * Echoes a translated string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output.
193 167 *
194 - * @api
195 168 * @since 2.1
196 169 *
197 170 * @param string $string The string to translate
198 171 */
@@ -202,9 +175,8 @@
202 175
203 176 /**
204 177 * Echoes a translated a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes.
205 178 *
206 - * @api
207 179 * @since 2.1
208 180 *
209 181 * @param string $string The string to translate
210 182 */
@@ -214,9 +186,8 @@
214 186
215 187 /**
216 188 * Translates a string ( previously registered with pll_register_string )
217 189 *
218 - * @api
219 190 * @since 1.5.4
220 191 *
221 192 * @param string $string the string to translate
222 193 * @param string $lang language code
@@ -248,9 +219,8 @@
248 219
249 220 /**
250 221 * Returns true if Polylang manages languages and translations for this post type
251 222 *
252 - * @api
253 223 * @since 1.0.1
254 224 *
255 225 * @param string $post_type Post type name
256 226 * @return bool
@@ -261,9 +231,8 @@
261 231
262 232 /**
263 233 * Returns true if Polylang manages languages and translations for this taxonomy
264 234 *
265 - * @api
266 235 * @since 1.0.1
267 236 *
268 237 * @param string $tax Taxonomy name
269 238 * @return bool
@@ -279,9 +248,8 @@
279 248 *
280 249 * hide_empty => hides languages with no posts if set to true ( defaults to false )
281 250 * fields => return only that field if set ( see PLL_Language for a list of fields )
282 251 *
283 - * @api
284 252 * @since 1.5
285 253 *
286 254 * @param array $args list of parameters
287 255 * @return array
@@ -293,9 +261,8 @@
293 261
294 262 /**
295 263 * Set the post language
296 264 *
297 - * @api
298 265 * @since 1.5
299 266 *
300 267 * @param int $id post id
301 268 * @param string $lang language code
@@ -306,9 +273,8 @@
306 273
307 274 /**
308 275 * Set the term language
309 276 *
310 - * @api
311 277 * @since 1.5
312 278 *
313 279 * @param int $id term id
314 280 * @param string $lang language code
@@ -319,9 +285,8 @@
319 285
320 286 /**
321 287 * Save posts translations
322 288 *
323 - * @api
324 289 * @since 1.5
325 290 *
326 291 * @param array $arr an associative array of translations with language code as key and post id as value
327 292 */
@@ -331,9 +296,8 @@
331 296
332 297 /**
333 298 * Save terms translations
334 299 *
335 - * @api
336 300 * @since 1.5
337 301 *
338 302 * @param array $arr an associative array of translations with language code as key and term id as value
339 303 */
@@ -343,9 +307,8 @@
343 307
344 308 /**
345 309 * Returns the post language
346 310 *
347 - * @api
348 311 * @since 1.5.4
349 312 *
350 313 * @param int $post_id
351 314 * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug'
@@ -357,9 +320,8 @@
357 320
358 321 /**
359 322 * Returns the term language
360 323 *
361 - * @api
362 324 * @since 1.5.4
363 325 *
364 326 * @param int $term_id
365 327 * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug'
@@ -371,9 +333,8 @@
371 333
372 334 /**
373 335 * Returns an array of translations of a post
374 336 *
375 - * @api
376 337 * @since 1.8
377 338 *
378 339 * @param int $post_id
379 340 * @return array an associative array of translations with language code as key and translation post_id as value
@@ -384,9 +345,8 @@
384 345
385 346 /**
386 347 * Returns an array of translations of a term
387 348 *
388 - * @api
389 349 * @since 1.8
390 350 *
391 351 * @param int $term_id
392 352 * @return array an associative array of translations with language code as key and translation term_id as value
@@ -397,14 +357,13 @@
397 357
398 358 /**
399 359 * Count posts in a language
400 360 *
401 - * @api
402 361 * @since 1.5
403 362 *
404 - * @param string $lang Language code.
405 - * @param array $args WP_Query arguments ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format, post_status ).
406 - * @return int Posts count.
363 + * @param string $lang language code
364 + * @param array $args ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format )
365 + * @return int posts count
407 366 */
408 367 function pll_count_posts( $lang, $args = array() ) {
409 368 return PLL()->model->count_posts( PLL()->model->get_language( $lang ), $args );
410 369 }