PluginProbe
Polylang / 3.3
Polylang v3.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/links-default.php +28 -28 2.83.3 View file →
@@ -3,26 +3,29 @@
3 3 * @package Polylang
4 4 */
5 5
6 6 /**
7 - * Links model for default permalinks
8 - * for example mysite.com/?somevar=something&lang=en
9 - * implements the "links_model interface"
7 + * Links model for the default permalinks
8 + * for example mysite.com/?somevar=something&lang=en.
10 9 *
11 10 * @since 1.2
12 11 */
13 12 class PLL_Links_Default extends PLL_Links_Model {
13 + /**
14 + * Tells this child class of PLL_Links_Model does not use pretty permalinks.
15 + *
16 + * @var bool
17 + */
14 18 public $using_permalinks = false;
15 19
16 20 /**
17 - * Adds language information to an url
18 - * links_model interface
21 + * Adds the language code in a url.
19 22 *
20 23 * @since 1.2
21 24 *
22 - * @param string $url url to modify
23 - * @param object $lang language
24 - * @return string modified url
25 + * @param string $url The url to modify.
26 + * @param PLL_Language|false $lang The language object.
27 + * @return string The modified url.
25 28 */
26 29 public function add_language_to_link( $url, $lang ) {
27 30 return empty( $lang ) || ( $this->options['hide_default'] && $this->options['default_lang'] == $lang->slug ) ? $url : add_query_arg( 'lang', $lang->slug, $url );
28 31 }
@@ -27,15 +30,14 @@
27 30 return empty( $lang ) || ( $this->options['hide_default'] && $this->options['default_lang'] == $lang->slug ) ? $url : add_query_arg( 'lang', $lang->slug, $url );
28 31 }
29 32
30 33 /**
31 - * Removes the language information from an url
32 - * links_model interface
34 + * Removes the language information from an url.
33 35 *
34 36 * @since 1.2
35 37 *
36 - * @param string $url url to modify
37 - * @return string modified url
38 + * @param string $url The url to modify.
39 + * @return string The modified url.
38 40 */
39 41 public function remove_language_from_link( $url ) {
40 42 return remove_query_arg( 'lang', $url );
41 43 }
@@ -40,15 +42,14 @@
40 42 return remove_query_arg( 'lang', $url );
41 43 }
42 44
43 45 /**
44 - * Returns the link to the first page
45 - * links_model interface
46 + * Returns the link to the first page.
46 47 *
47 48 * @since 1.2
48 49 *
49 - * @param string $url url to modify
50 - * @return string modified url
50 + * @param string $url The url to modify.
51 + * @return string The modified url.
51 52 */
52 53 public function remove_paged_from_link( $url ) {
53 54 return remove_query_arg( 'paged', $url );
54 55 }
@@ -53,15 +54,15 @@
53 54 return remove_query_arg( 'paged', $url );
54 55 }
55 56
56 57 /**
57 - * Returns the link to the paged page when using pretty permalinks
58 + * Returns the link to the paged page.
58 59 *
59 60 * @since 1.5
60 61 *
61 - * @param string $url url to modify
62 - * @param int $page
63 - * @return string modified url
62 + * @param string $url The url to modify.
63 + * @param int $page The page number.
64 + * @return string The modified url.
64 65 */
65 66 public function add_paged_to_link( $url, $page ) {
66 67 return add_query_arg( array( 'paged' => $page ), $url );
67 68 }
@@ -66,16 +67,15 @@
66 67 return add_query_arg( array( 'paged' => $page ), $url );
67 68 }
68 69
69 70 /**
70 - * Gets the language slug from the url if present
71 - * links_model interface
71 + * Gets the language slug from the url if present.
72 72 *
73 73 * @since 1.2
74 - * @since 2.0 add $url argument
74 + * @since 2.0 Add the $url argument.
75 75 *
76 - * @param string $url optional, defaults to current url
77 - * @return string language slug
76 + * @param string $url Optional, defaults to the current url.
77 + * @return string Language slug.
78 78 */
79 79 public function get_language_from_url( $url = '' ) {
80 80 if ( empty( $url ) ) {
81 81 $url = pll_get_requested_url();
@@ -85,14 +85,14 @@
85 85 return preg_match( $pattern, trailingslashit( $url ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
86 86 }
87 87
88 88 /**
89 - * Returns the static front page url
89 + * Returns the static front page url in the given language.
90 90 *
91 91 * @since 1.8
92 92 *
93 - * @param object $lang
94 - * @return string
93 + * @param PLL_Language $lang The language object.
94 + * @return string The static front page url.
95 95 */
96 96 public function front_page_url( $lang ) {
97 97 if ( $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ) {
98 98 return trailingslashit( $this->home );