PluginProbe
Polylang / 2.3
Polylang v2.3
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 +14 -27 2.72.3 View file →
@@ -24,9 +24,9 @@
24 24 * @return null|string|array null if displaying, array if raw is requested, string otherwise
25 25 */
26 26 function pll_the_languages( $args = '' ) {
27 27 if ( PLL() instanceof PLL_Frontend ) {
28 - $switcher = new PLL_Switcher();
28 + $switcher = new PLL_Switcher;
29 29 return $switcher->the_languages( PLL()->links, $args );
30 30 }
31 31 return '';
32 32 }
@@ -36,15 +36,12 @@
36 36 * Returns the language set in admin language filter on backend ( false if set to all languages )
37 37 *
38 38 * @since 0.8.1
39 39 *
40 - * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
41 - * @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
42 42 */
43 43 function pll_current_language( $field = 'slug' ) {
44 - if ( OBJECT === $field ) {
45 - return PLL()->curlang;
46 - }
47 44 return isset( PLL()->curlang->$field ) ? PLL()->curlang->$field : false;
48 45 }
49 46
50 47 /**
@@ -51,22 +48,13 @@
51 48 * Returns the default language
52 49 *
53 50 * @since 1.0
54 51 *
55 - * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
56 - * @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
57 54 */
58 55 function pll_default_language( $field = 'slug' ) {
59 - if ( isset( PLL()->options['default_lang'] ) ) {
60 - $lang = PLL()->model->get_language( PLL()->options['default_lang'] );
61 - if ( $lang ) {
62 - if ( OBJECT === $field ) {
63 - return $lang;
64 - }
65 - return isset( $lang->$field ) ? $lang->$field : false;
66 - }
67 - }
68 - return false;
56 + return isset( PLL()->options['default_lang'] ) && ( $lang = PLL()->model->get_language( PLL()->options['default_lang'] ) ) && isset( $lang->$field ) ? $lang->$field : false;
69 57 }
70 58
71 59 /**
72 60 * Among the post and its translations, returns the id of the post which is in the language represented by $slug
@@ -134,9 +122,9 @@
134 122 * @param string $string the string to translate
135 123 * @return string the string translation in the current language
136 124 */
137 125 function pll__( $string ) {
138 - return is_scalar( $string ) ? __( $string, 'pll_string' ) : $string; // PHPCS:ignore WordPress.WP.I18n
126 + return is_scalar( $string ) ? __( $string, 'pll_string' ) : $string;
139 127 }
140 128
141 129 /**
142 130 * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output.
@@ -163,9 +151,8 @@
163 151 }
164 152
165 153 /**
166 154 * Echoes a translated string ( previously registered with pll_register_string )
167 - * It is an equivalent of _e() and is not escaped.
168 155 *
169 156 * @since 0.6
170 157 *
171 158 * @param string $string The string to translate
@@ -170,9 +157,9 @@
170 157 *
171 158 * @param string $string The string to translate
172 159 */
173 160 function pll_e( $string ) {
174 - echo pll__( $string ); // phpcs:ignore
161 + echo pll__( $string );
175 162 }
176 163
177 164 /**
178 165 * Echoes a translated string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output.
@@ -181,9 +168,9 @@
181 168 *
182 169 * @param string $string The string to translate
183 170 */
184 171 function pll_esc_html_e( $string ) {
185 - echo pll_esc_html__( $string ); // phpcs:ignore WordPress.Security.EscapeOutput
172 + echo pll_esc_html__( $string );
186 173 }
187 174
188 175 /**
189 176 * Echoes a translated a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes.
@@ -192,9 +179,9 @@
192 179 *
193 180 * @param string $string The string to translate
194 181 */
195 182 function pll_esc_attr_e( $string ) {
196 - echo pll_esc_attr__( $string ); // phpcs:ignore WordPress.Security.EscapeOutput
183 + echo pll_esc_attr__( $string );
197 184 }
198 185
199 186 /**
200 187 * Translates a string ( previously registered with pll_register_string )
@@ -371,11 +358,11 @@
371 358 * Count posts in a language
372 359 *
373 360 * @since 1.5
374 361 *
375 - * @param string $lang Language code.
376 - * @param array $args WP_Query arguments ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format, post_status ).
377 - * @return int Posts count.
362 + * @param string $lang language code
363 + * @param array $args ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format )
364 + * @return int posts count
378 365 */
379 366 function pll_count_posts( $lang, $args = array() ) {
380 367 return PLL()->model->count_posts( PLL()->model->get_language( $lang ), $args );
381 368 }
@@ -386,7 +373,7 @@
386 373 * Internal methods may be changed without prior notice
387 374 *
388 375 * @since 1.8
389 376 */
390 -function PLL() { // PHPCS:ignore WordPress.NamingConventions.ValidFunctionName
377 +function PLL() {
391 378 return $GLOBALS['polylang'];
392 379 }