PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
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/filters-links.php +52 -19 2.7.13.1.4 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Manages links filters needed on both frontend and admin
5 8 *
@@ -5,11 +8,40 @@
5 8 *
6 9 * @since 1.8
7 10 */
8 11 class PLL_Filters_Links {
9 - public $links, $links_model, $model, $options, $curlang;
12 + /**
13 + * Stores the plugin options.
14 + *
15 + * @var array
16 + */
17 + public $options;
10 18
11 19 /**
20 + * @var PLL_Model
21 + */
22 + public $model;
23 +
24 + /**
25 + * Instance of a child class of PLL_Links_Model.
26 + *
27 + * @var PLL_Links_Model
28 + */
29 + public $links_model;
30 +
31 + /**
32 + * @var PLL_Links
33 + */
34 + public $links;
35 +
36 + /**
37 + * Current language.
38 + *
39 + * @var PLL_Language
40 + */
41 + public $curlang;
42 +
43 + /**
12 44 * Constructor
13 45 *
14 46 * @since 1.8
15 47 *
@@ -71,15 +103,15 @@
71 103 return wp_get_post_parent_id( $post_id ) ? $link : $this->links_model->switch_language_in_link( $link, $this->model->post->get_language( $post_id ) );
72 104 }
73 105
74 106 /**
75 - * Modifies custom posts links
107 + * Modifies custom posts links.
76 108 *
77 109 * @since 1.6
78 110 *
79 - * @param string $link post link
80 - * @param object $post post object
81 - * @return string modified post link
111 + * @param string $link Post link.
112 + * @param WP_Post $post Post object.
113 + * @return string Modified post link.
82 114 */
83 115 public function post_type_link( $link, $post ) {
84 116 // /!\ WP does not use pretty permalinks for preview
85 117 if ( ( false === strpos( $link, 'preview=true' ) || false === strpos( $link, 'p=' ) ) && $this->model->is_translated_post_type( $post->post_type ) ) {
@@ -86,15 +118,15 @@
86 118 $lang = $this->model->post->get_language( $post->ID );
87 119 $link = $this->options['force_lang'] ? $this->links_model->switch_language_in_link( $link, $lang ) : $link;
88 120
89 121 /**
90 - * Filter a post or custom post type link
122 + * Filters a post or custom post type link.
91 123 *
92 124 * @since 1.6
93 125 *
94 - * @param string $link the post link
95 - * @param object $lang the current language
96 - * @param object $post the post object
126 + * @param string $link The post link.
127 + * @param PLL_Language $lang The current language.
128 + * @param WP_Post $post The post object.
97 129 */
98 130 $link = apply_filters( 'pll_post_type_link', $link, $lang, $post );
99 131 }
100 132
@@ -101,16 +133,16 @@
101 133 return $link;
102 134 }
103 135
104 136 /**
105 - * Modifies term link
137 + * Modifies term links.
106 138 *
107 139 * @since 0.7
108 140 *
109 - * @param string $link term link
110 - * @param object $term term object
111 - * @param string $tax taxonomy name
112 - * @return string modified term link
141 + * @param string $link Term link.
142 + * @param WP_Term $term Term object.
143 + * @param string $tax Taxonomy name;
144 + * @return string Modified term link.
113 145 */
114 146 public function term_link( $link, $term, $tax ) {
115 147 if ( $this->model->is_translated_taxonomy( $tax ) ) {
116 148 $lang = $this->model->term->get_language( $term->term_id );
@@ -120,18 +152,19 @@
120 152 * Filter a term link
121 153 *
122 154 * @since 1.6
123 155 *
124 - * @param string $link the term link
125 - * @param object $lang the current language
126 - * @param object $term the term object
156 + * @param string $link The term link.
157 + * @param PLL_Language $lang The current language.
158 + * @param WP_Term $term The term object.
127 159 */
128 160 return apply_filters( 'pll_term_link', $link, $lang, $term );
129 161 }
130 162
131 - // in case someone calls get_term_link for the 'language' taxonomy
163 + // In case someone calls get_term_link for the 'language' taxonomy.
132 164 if ( 'language' === $tax ) {
133 - return $this->links_model->home_url( $term );
165 + $lang = $this->model->get_language( $term->term_id );
166 + return $this->links_model->home_url( $lang );
134 167 }
135 168
136 169 return $link;
137 170 }