| @@ -1,5 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * @package Polylang | |
| 4 | + */ | |
| 2 | 5 | |
| 3 | 6 | /** |
| 4 | 7 | * Links model for use when the language code is added in url as a directory |
| 5 | 8 | * for example mysite.com/en/something |
| @@ -7,16 +10,21 @@ | ||
| 7 | 10 | * |
| 8 | 11 | * @since 1.2 |
| 9 | 12 | */ |
| 10 | 13 | class PLL_Links_Directory extends PLL_Links_Permalinks { |
| 14 | + /** | |
| 15 | + * Relative path to the home url. | |
| 16 | + * | |
| 17 | + * @var string | |
| 18 | + */ | |
| 11 | 19 | protected $home_relative; |
| 12 | 20 | |
| 13 | 21 | /** |
| 14 | - * Constructor | |
| 22 | + * Constructor. | |
| 15 | 23 | * |
| 16 | 24 | * @since 1.2 |
| 17 | 25 | * |
| 18 | - * @param object $model PLL_Model instance | |
| 26 | + * @param PLL_Model $model PLL_Model instance. | |
| 19 | 27 | */ |
| 20 | 28 | public function __construct( &$model ) { |
| 21 | 29 | parent::__construct( $model ); |
| 22 | 30 | |
| @@ -32,8 +40,10 @@ | ||
| 32 | 40 | /** |
| 33 | 41 | * Called only at first object creation to avoid duplicating filters when switching blog |
| 34 | 42 | * |
| 35 | 43 | * @since 1.6 |
| 44 | + * | |
| 45 | + * @return void | |
| 36 | 46 | */ |
| 37 | 47 | public function init() { |
| 38 | 48 | if ( did_action( 'setup_theme' ) ) { |
| 39 | 49 | $this->add_permastruct(); |
| @@ -45,16 +55,16 @@ | ||
| 45 | 55 | add_action( 'pre_option_rewrite_rules', array( $this, 'prepare_rewrite_rules' ) ); |
| 46 | 56 | } |
| 47 | 57 | |
| 48 | 58 | /** |
| 49 | - * Adds the language code in url | |
| 50 | - * links_model interface | |
| 59 | + * Adds the language code in a url. | |
| 60 | + * links_model interface. | |
| 51 | 61 | * |
| 52 | 62 | * @since 1.2 |
| 53 | 63 | * |
| 54 | - * @param string $url url to modify | |
| 55 | - * @param object $lang language | |
| 56 | - * @return string modified url | |
| 64 | + * @param string $url The url to modify. | |
| 65 | + * @param PLL_Language $lang The language object. | |
| 66 | + * @return string Modified url. | |
| 57 | 67 | */ |
| 58 | 68 | public function add_language_to_link( $url, $lang ) { |
| 59 | 69 | if ( ! empty( $lang ) ) { |
| 60 | 70 | $base = $this->options['rewrite'] ? '' : 'language/'; |
| @@ -122,14 +132,14 @@ | ||
| 122 | 132 | return preg_match( $pattern, trailingslashit( $path ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language |
| 123 | 133 | } |
| 124 | 134 | |
| 125 | 135 | /** |
| 126 | - * Returns the home url | |
| 127 | - * links_model interface | |
| 136 | + * Returns the home url in a given language. | |
| 137 | + * links_model interface. | |
| 128 | 138 | * |
| 129 | 139 | * @since 1.3.1 |
| 130 | 140 | * |
| 131 | - * @param object $lang PLL_Language object | |
| 141 | + * @param PLL_Language $lang PLL_Language object. | |
| 132 | 142 | * @return string |
| 133 | 143 | */ |
| 134 | 144 | public function home_url( $lang ) { |
| 135 | 145 | $base = $this->options['rewrite'] ? '' : 'language/'; |
| @@ -140,8 +150,10 @@ | ||
| 140 | 150 | /** |
| 141 | 151 | * Optionally removes 'language' in permalinks so that we get http://www.myblog/en/ instead of http://www.myblog/language/en/ |
| 142 | 152 | * |
| 143 | 153 | * @since 1.2 |
| 154 | + * | |
| 155 | + * @return void | |
| 144 | 156 | */ |
| 145 | 157 | public function add_permastruct() { |
| 146 | 158 | // Language information always in front of the uri ( 'with_front' => false ) |
| 147 | 159 | // The 3rd parameter structure has been modified in WP 3.4 |
| @@ -151,14 +163,14 @@ | ||
| 151 | 163 | } |
| 152 | 164 | } |
| 153 | 165 | |
| 154 | 166 | /** |
| 155 | - * Prepares rewrite rules filters | |
| 167 | + * Prepares the rewrite rules filters. | |
| 156 | 168 | * |
| 157 | 169 | * @since 0.8.1 |
| 158 | 170 | * |
| 159 | - * @param array $pre not used | |
| 160 | - * @return unmodified $pre | |
| 171 | + * @param mixed $pre Not used as the filter is used as an action. | |
| 172 | + * @return mixed | |
| 161 | 173 | */ |
| 162 | 174 | public function prepare_rewrite_rules( $pre ) { |
| 163 | 175 | // Don't modify the rules if there is no languages created yet |
| 164 | 176 | // Make sure to add filter only once and if all custom post types and taxonomies have been registered |
| @@ -176,15 +188,15 @@ | ||
| 176 | 188 | } |
| 177 | 189 | |
| 178 | 190 | /** |
| 179 | 191 | * The rewrite rules ! |
| 180 | - * always make sure the default language is at the end in case the language information is hidden for default language | |
| 181 | - * thanks to brbrbr http://wordpress.org/support/topic/plugin-polylang-rewrite-rules-not-correct | |
| 192 | + * Always make sure that the default language is at the end in case the language information is hidden for default language. | |
| 193 | + * Thanks to brbrbr http://wordpress.org/support/topic/plugin-polylang-rewrite-rules-not-correct. | |
| 182 | 194 | * |
| 183 | 195 | * @since 0.8.1 |
| 184 | 196 | * |
| 185 | - * @param array $rules rewrite rules | |
| 186 | - * @return array modified rewrite rules | |
| 197 | + * @param string[] $rules Rewrite rules. | |
| 198 | + * @return string[] Modified rewrite rules. | |
| 187 | 199 | */ |
| 188 | 200 | public function rewrite_rules( $rules ) { |
| 189 | 201 | $filter = str_replace( '_rewrite_rules', '', current_filter() ); |
| 190 | 202 | |