PluginProbe
Polylang / 3.4.2
Polylang v3.4.2
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
polylang / include / links.php

links.php in Polylang 3.4.2, at include/links.php

72 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Polylang
4 */
5
6 /**
7 * Manages links related functions
8 *
9 * @since 1.2
10 */
11 class PLL_Links {
12 /**
13 * Stores the plugin options.
14 *
15 * @var array
16 */
17 public $options;
18
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 * Current language (used to filter the content).
33 *
34 * @var PLL_Language|null
35 */
36 public $curlang;
37
38 /**
39 * Constructor
40 *
41 * @since 1.2
42 *
43 * @param object $polylang
44 */
45 public function __construct( &$polylang ) {
46 $this->links_model = &$polylang->links_model;
47 $this->model = &$polylang->model;
48 $this->options = &$polylang->options;
49 }
50
51 /**
52 * Returns the home url in the requested language.
53 *
54 * @since 1.3
55 *
56 * @param PLL_Language|string $language The language.
57 * @param bool $is_search Optional, whether we need the home url for a search form, defaults to false.
58 * @return string
59 */
60 public function get_home_url( $language, $is_search = false ) {
61 if ( ! $language instanceof PLL_Language ) {
62 $language = $this->model->get_language( $language );
63 }
64
65 if ( empty( $language ) ) {
66 return home_url( '/' );
67 }
68
69 return $is_search ? $language->get_search_url() : $language->get_home_url();
70 }
71 }
72