| @@ -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 | * |
| @@ -7,24 +4,21 @@ | ||
| 7 | 4 | * Template tag: displays the language switcher |
| 8 | 5 | * |
| 9 | 6 | * List of parameters accepted in $args: |
| 10 | 7 | * |
| 11 | - * - dropdown => displays a dropdown if set to 1, defaults to 0 | |
| 12 | - * - echo => echoes the switcher if set to 1 ( default ) | |
| 13 | - * - hide_if_empty => hides languages with no posts ( or pages ) if set to 1 ( default ) | |
| 14 | - * - show_flags => shows flags if set to 1, defaults to 0 | |
| 15 | - * - show_names => shows languages names if set to 1 ( default ) | |
| 16 | - * - display_names_as => whether to display the language name or its slug, valid options are 'slug' and 'name', | |
| 17 | - * defaults to name | |
| 18 | - * - force_home => forces linking to the home page is set to 1, defaults to 0 | |
| 19 | - * - hide_if_no_translation => hides the link if there is no translation if set to 1, defaults to 0 | |
| 20 | - * - hide_current => hides the current language if set to 1, defaults to 0 | |
| 21 | - * - post_id => if not null, link to translations of post defined by post_id, defaults to null | |
| 22 | - * - raw => set this to true to build your own custom language switcher, defaults to 0 | |
| 23 | - * - item_spacing => whether to preserve or discard whitespace between list items, valid options are | |
| 24 | - * 'preserve' and 'discard', defaults to preserve | |
| 8 | + * dropdown => displays a dropdown if set to 1, defaults to 0 | |
| 9 | + * echo => echoes the switcher if set to 1 ( default ) | |
| 10 | + * hide_if_empty => hides languages with no posts ( or pages ) if set to 1 ( default ) | |
| 11 | + * show_flags => shows flags if set to 1, defaults to 0 | |
| 12 | + * show_names => shows languages names if set to 1 ( default ) | |
| 13 | + * display_names_as => whether to display the language name or its slug, valid options are 'slug' and 'name', defaults to name | |
| 14 | + * force_home => forces linking to the home page is set to 1, defaults to 0 | |
| 15 | + * hide_if_no_translation => hides the link if there is no translation if set to 1, defaults to 0 | |
| 16 | + * hide_current => hides the current language if set to 1, defaults to 0 | |
| 17 | + * post_id => if not null, link to translations of post defined by post_id, defaults to null | |
| 18 | + * raw => set this to true to build your own custom language switcher, defaults to 0 | |
| 19 | + * item_spacing => whether to preserve or discard whitespace between list items, valid options are 'preserve' and 'discard', defaults to preserve | |
| 25 | 20 | * |
| 26 | - * @api | |
| 27 | 21 | * @since 0.5 |
| 28 | 22 | * |
| 29 | 23 | * @param array $args optional |
| 30 | 24 | * @return null|string|array null if displaying, array if raw is requested, string otherwise |
| @@ -40,9 +34,8 @@ | ||
| 40 | 34 | /** |
| 41 | 35 | * Returns the current language on frontend |
| 42 | 36 | * Returns the language set in admin language filter on backend ( false if set to all languages ) |
| 43 | 37 | * |
| 44 | - * @api | |
| 45 | 38 | * @since 0.8.1 |
| 46 | 39 | * |
| 47 | 40 | * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object. |
| 48 | 41 | * @return string|PLL_Language|bool The requested field for the current language |
| @@ -56,9 +49,8 @@ | ||
| 56 | 49 | |
| 57 | 50 | /** |
| 58 | 51 | * Returns the default language |
| 59 | 52 | * |
| 60 | - * @api | |
| 61 | 53 | * @since 1.0 |
| 62 | 54 | * |
| 63 | 55 | * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object. |
| 64 | 56 | * @return string|PLL_Language|bool The requested field for the default language |
| @@ -78,9 +70,8 @@ | ||
| 78 | 70 | |
| 79 | 71 | /** |
| 80 | 72 | * Among the post and its translations, returns the id of the post which is in the language represented by $slug |
| 81 | 73 | * |
| 82 | - * @api | |
| 83 | 74 | * @since 0.5 |
| 84 | 75 | * |
| 85 | 76 | * @param int $post_id post id |
| 86 | 77 | * @param string $slug optional language code, defaults to current language |
| @@ -92,9 +83,8 @@ | ||
| 92 | 83 | |
| 93 | 84 | /** |
| 94 | 85 | * Among the term and its translations, returns the id of the term which is in the language represented by $slug |
| 95 | 86 | * |
| 96 | - * @api | |
| 97 | 87 | * @since 0.5 |
| 98 | 88 | * |
| 99 | 89 | * @param int $term_id term id |
| 100 | 90 | * @param string $slug optional language code, defaults to current language |
| @@ -106,9 +96,8 @@ | ||
| 106 | 96 | |
| 107 | 97 | /** |
| 108 | 98 | * Returns the home url in the current language |
| 109 | 99 | * |
| 110 | - * @api | |
| 111 | 100 | * @since 0.8 |
| 112 | 101 | * |
| 113 | 102 | * @param string $lang language code ( optional on frontend ) |
| 114 | 103 | * @return string |
| @@ -123,9 +112,8 @@ | ||
| 123 | 112 | |
| 124 | 113 | /** |
| 125 | 114 | * Registers a string for translation in the "strings translation" panel |
| 126 | 115 | * |
| 127 | - * @api | |
| 128 | 116 | * @since 0.6 |
| 129 | 117 | * |
| 130 | 118 | * @param string $name a unique name for the string |
| 131 | 119 | * @param string $string the string to register |
| @@ -131,9 +119,9 @@ | ||
| 131 | 119 | * @param string $string the string to register |
| 132 | 120 | * @param string $context optional the group in which the string is registered, defaults to 'polylang' |
| 133 | 121 | * @param bool $multiline optional whether the string table should display a multiline textarea or a single line input, defaults to single line |
| 134 | 122 | */ |
| 135 | -function pll_register_string( $name, $string, $context = 'Polylang', $multiline = false ) { | |
| 123 | +function pll_register_string( $name, $string, $context = 'polylang', $multiline = false ) { | |
| 136 | 124 | if ( PLL() instanceof PLL_Admin_Base ) { |
| 137 | 125 | PLL_Admin_Strings::register_string( $name, $string, $context, $multiline ); |
| 138 | 126 | } |
| 139 | 127 | } |
| @@ -140,9 +128,8 @@ | ||
| 140 | 128 | |
| 141 | 129 | /** |
| 142 | 130 | * Translates a string ( previously registered with pll_register_string ) |
| 143 | 131 | * |
| 144 | - * @api | |
| 145 | 132 | * @since 0.6 |
| 146 | 133 | * |
| 147 | 134 | * @param string $string the string to translate |
| 148 | 135 | * @return string the string translation in the current language |
| @@ -153,9 +140,8 @@ | ||
| 153 | 140 | |
| 154 | 141 | /** |
| 155 | 142 | * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output. |
| 156 | 143 | * |
| 157 | - * @api | |
| 158 | 144 | * @since 2.1 |
| 159 | 145 | * |
| 160 | 146 | * @param string $string the string to translate |
| 161 | 147 | * @return string translation in the current language |
| @@ -166,9 +152,8 @@ | ||
| 166 | 152 | |
| 167 | 153 | /** |
| 168 | 154 | * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes. |
| 169 | 155 | * |
| 170 | - * @api | |
| 171 | 156 | * @since 2.1 |
| 172 | 157 | * |
| 173 | 158 | * @param string $string The string to translate |
| 174 | 159 | * @return string |
| @@ -180,9 +165,8 @@ | ||
| 180 | 165 | /** |
| 181 | 166 | * Echoes a translated string ( previously registered with pll_register_string ) |
| 182 | 167 | * It is an equivalent of _e() and is not escaped. |
| 183 | 168 | * |
| 184 | - * @api | |
| 185 | 169 | * @since 0.6 |
| 186 | 170 | * |
| 187 | 171 | * @param string $string The string to translate |
| 188 | 172 | */ |
| @@ -192,9 +176,8 @@ | ||
| 192 | 176 | |
| 193 | 177 | /** |
| 194 | 178 | * Echoes a translated string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output. |
| 195 | 179 | * |
| 196 | - * @api | |
| 197 | 180 | * @since 2.1 |
| 198 | 181 | * |
| 199 | 182 | * @param string $string The string to translate |
| 200 | 183 | */ |
| @@ -204,9 +187,8 @@ | ||
| 204 | 187 | |
| 205 | 188 | /** |
| 206 | 189 | * Echoes a translated a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes. |
| 207 | 190 | * |
| 208 | - * @api | |
| 209 | 191 | * @since 2.1 |
| 210 | 192 | * |
| 211 | 193 | * @param string $string The string to translate |
| 212 | 194 | */ |
| @@ -216,9 +198,8 @@ | ||
| 216 | 198 | |
| 217 | 199 | /** |
| 218 | 200 | * Translates a string ( previously registered with pll_register_string ) |
| 219 | 201 | * |
| 220 | - * @api | |
| 221 | 202 | * @since 1.5.4 |
| 222 | 203 | * |
| 223 | 204 | * @param string $string the string to translate |
| 224 | 205 | * @param string $lang language code |
| @@ -250,9 +231,8 @@ | ||
| 250 | 231 | |
| 251 | 232 | /** |
| 252 | 233 | * Returns true if Polylang manages languages and translations for this post type |
| 253 | 234 | * |
| 254 | - * @api | |
| 255 | 235 | * @since 1.0.1 |
| 256 | 236 | * |
| 257 | 237 | * @param string $post_type Post type name |
| 258 | 238 | * @return bool |
| @@ -263,9 +243,8 @@ | ||
| 263 | 243 | |
| 264 | 244 | /** |
| 265 | 245 | * Returns true if Polylang manages languages and translations for this taxonomy |
| 266 | 246 | * |
| 267 | - * @api | |
| 268 | 247 | * @since 1.0.1 |
| 269 | 248 | * |
| 270 | 249 | * @param string $tax Taxonomy name |
| 271 | 250 | * @return bool |
| @@ -281,9 +260,8 @@ | ||
| 281 | 260 | * |
| 282 | 261 | * hide_empty => hides languages with no posts if set to true ( defaults to false ) |
| 283 | 262 | * fields => return only that field if set ( see PLL_Language for a list of fields ) |
| 284 | 263 | * |
| 285 | - * @api | |
| 286 | 264 | * @since 1.5 |
| 287 | 265 | * |
| 288 | 266 | * @param array $args list of parameters |
| 289 | 267 | * @return array |
| @@ -295,9 +273,8 @@ | ||
| 295 | 273 | |
| 296 | 274 | /** |
| 297 | 275 | * Set the post language |
| 298 | 276 | * |
| 299 | - * @api | |
| 300 | 277 | * @since 1.5 |
| 301 | 278 | * |
| 302 | 279 | * @param int $id post id |
| 303 | 280 | * @param string $lang language code |
| @@ -308,9 +285,8 @@ | ||
| 308 | 285 | |
| 309 | 286 | /** |
| 310 | 287 | * Set the term language |
| 311 | 288 | * |
| 312 | - * @api | |
| 313 | 289 | * @since 1.5 |
| 314 | 290 | * |
| 315 | 291 | * @param int $id term id |
| 316 | 292 | * @param string $lang language code |
| @@ -321,9 +297,8 @@ | ||
| 321 | 297 | |
| 322 | 298 | /** |
| 323 | 299 | * Save posts translations |
| 324 | 300 | * |
| 325 | - * @api | |
| 326 | 301 | * @since 1.5 |
| 327 | 302 | * |
| 328 | 303 | * @param array $arr an associative array of translations with language code as key and post id as value |
| 329 | 304 | */ |
| @@ -333,9 +308,8 @@ | ||
| 333 | 308 | |
| 334 | 309 | /** |
| 335 | 310 | * Save terms translations |
| 336 | 311 | * |
| 337 | - * @api | |
| 338 | 312 | * @since 1.5 |
| 339 | 313 | * |
| 340 | 314 | * @param array $arr an associative array of translations with language code as key and term id as value |
| 341 | 315 | */ |
| @@ -345,9 +319,8 @@ | ||
| 345 | 319 | |
| 346 | 320 | /** |
| 347 | 321 | * Returns the post language |
| 348 | 322 | * |
| 349 | - * @api | |
| 350 | 323 | * @since 1.5.4 |
| 351 | 324 | * |
| 352 | 325 | * @param int $post_id |
| 353 | 326 | * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug' |
| @@ -359,9 +332,8 @@ | ||
| 359 | 332 | |
| 360 | 333 | /** |
| 361 | 334 | * Returns the term language |
| 362 | 335 | * |
| 363 | - * @api | |
| 364 | 336 | * @since 1.5.4 |
| 365 | 337 | * |
| 366 | 338 | * @param int $term_id |
| 367 | 339 | * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug' |
| @@ -373,9 +345,8 @@ | ||
| 373 | 345 | |
| 374 | 346 | /** |
| 375 | 347 | * Returns an array of translations of a post |
| 376 | 348 | * |
| 377 | - * @api | |
| 378 | 349 | * @since 1.8 |
| 379 | 350 | * |
| 380 | 351 | * @param int $post_id |
| 381 | 352 | * @return array an associative array of translations with language code as key and translation post_id as value |
| @@ -386,9 +357,8 @@ | ||
| 386 | 357 | |
| 387 | 358 | /** |
| 388 | 359 | * Returns an array of translations of a term |
| 389 | 360 | * |
| 390 | - * @api | |
| 391 | 361 | * @since 1.8 |
| 392 | 362 | * |
| 393 | 363 | * @param int $term_id |
| 394 | 364 | * @return array an associative array of translations with language code as key and translation term_id as value |
| @@ -399,14 +369,13 @@ | ||
| 399 | 369 | |
| 400 | 370 | /** |
| 401 | 371 | * Count posts in a language |
| 402 | 372 | * |
| 403 | - * @api | |
| 404 | 373 | * @since 1.5 |
| 405 | 374 | * |
| 406 | - * @param string $lang Language code. | |
| 407 | - * @param array $args WP_Query arguments ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format, post_status ). | |
| 408 | - * @return int Posts count. | |
| 375 | + * @param string $lang language code | |
| 376 | + * @param array $args ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format ) | |
| 377 | + * @return int posts count | |
| 409 | 378 | */ |
| 410 | 379 | function pll_count_posts( $lang, $args = array() ) { |
| 411 | 380 | return PLL()->model->count_posts( PLL()->model->get_language( $lang ), $args ); |
| 412 | 381 | } |