| @@ -1,5 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * @package Polylang | |
| 4 | + */ | |
| 2 | 5 | |
| 3 | 6 | /** |
| 4 | 7 | * A language object is made of two terms in 'language' and 'term_language' taxonomies |
| 5 | 8 | * manipulating only one object per language instead of two terms should make things easier |
| @@ -80,9 +83,9 @@ | ||
| 80 | 83 | $this->description = &$this->locale; // Backward compatibility with Polylang < 1.2 |
| 81 | 84 | |
| 82 | 85 | $this->mo_id = PLL_MO::get_id( $this ); |
| 83 | 86 | |
| 84 | - $languages = include PLL_SETTINGS_INC . '/languages.php'; | |
| 87 | + $languages = include POLYLANG_DIR . '/settings/languages.php'; | |
| 85 | 88 | $this->w3c = isset( $languages[ $this->locale ]['w3c'] ) ? $languages[ $this->locale ]['w3c'] : str_replace( '_', '-', $this->locale ); |
| 86 | 89 | if ( isset( $languages[ $this->locale ]['facebook'] ) ) { |
| 87 | 90 | $this->facebook = $languages[ $this->locale ]['facebook']; |
| 88 | 91 | } |
| @@ -236,23 +239,23 @@ | ||
| 236 | 239 | ); |
| 237 | 240 | } |
| 238 | 241 | |
| 239 | 242 | /** |
| 240 | - * Replace flag by custom flag | |
| 241 | - * Takes care of url scheme | |
| 243 | + * Returns the html of the custom flag if any, or the default flag otherwise. | |
| 242 | 244 | * |
| 243 | - * @since 1.7 | |
| 245 | + * @since 2.8 | |
| 244 | 246 | */ |
| 245 | - public function set_custom_flag() { | |
| 246 | - // Overwrite with custom flags on frontend only | |
| 247 | - if ( ! empty( $this->custom_flag ) ) { | |
| 248 | - $this->flag = $this->custom_flag; | |
| 249 | - $this->flag_url = $this->custom_flag_url; | |
| 250 | - unset( $this->custom_flag, $this->custom_flag_url ); // hide this | |
| 251 | - } | |
| 247 | + public function get_display_flag() { | |
| 248 | + return empty( $this->custom_flag ) ? $this->flag : $this->custom_flag; | |
| 249 | + } | |
| 252 | 250 | |
| 253 | - // Set url scheme, also for default flags | |
| 254 | - $this->flag_url = set_url_scheme( $this->flag_url ); | |
| 251 | + /** | |
| 252 | + * Returns the url of the custom flag if any, or the default flag otherwise. | |
| 253 | + * | |
| 254 | + * @since 2.8 | |
| 255 | + */ | |
| 256 | + public function get_display_flag_url() { | |
| 257 | + return empty( $this->custom_flag_url ) ? $this->flag : $this->custom_flag_url; | |
| 255 | 258 | } |
| 256 | 259 | |
| 257 | 260 | /** |
| 258 | 261 | * Updates post and term count |
| @@ -277,16 +280,23 @@ | ||
| 277 | 280 | $this->home_url = $home_url; |
| 278 | 281 | } |
| 279 | 282 | |
| 280 | 283 | /** |
| 281 | - * Set home_url scheme | |
| 282 | - * this can't be cached across pages | |
| 284 | + * Sets the scheme of the home url and the flag urls | |
| 283 | 285 | * |
| 284 | - * @since 1.6.4 | |
| 286 | + * This can't be cached across pages. | |
| 287 | + * | |
| 288 | + * @since 2.8 | |
| 285 | 289 | */ |
| 286 | - public function set_home_url_scheme() { | |
| 290 | + public function set_url_scheme() { | |
| 287 | 291 | $this->home_url = set_url_scheme( $this->home_url ); |
| 288 | 292 | $this->search_url = set_url_scheme( $this->search_url ); |
| 293 | + | |
| 294 | + // Set url scheme, also for the flags. | |
| 295 | + $this->flag_url = set_url_scheme( $this->flag_url ); | |
| 296 | + if ( ! empty( $this->custom_flag_url ) ) { | |
| 297 | + $this->custom_flag_url = set_url_scheme( $this->custom_flag_url ); | |
| 298 | + } | |
| 289 | 299 | } |
| 290 | 300 | |
| 291 | 301 | /** |
| 292 | 302 | * Returns the language locale |