PluginProbe
Polylang / 1.5
Polylang v1.5
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-model.php

links-model.php in Polylang 1.5, at include/links-model.php

77 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * links model abstract class
5 *
6 * @since 1.5
7 */
8 abstract class PLL_Links_Model {
9 public $model, $options;
10 protected $home;
11
12 /*
13 * constructor
14 *
15 * @since 1.5
16 *
17 * @param object $model PLL_Model instance
18 */
19 public function __construct(&$model) {
20 $this->model = &$model;
21 $this->options = &$model->options;
22
23 $this->home = get_option('home');
24 }
25
26 /*
27 * returns the link to the first page when using pretty permalinks
28 *
29 * @since 1.2
30 *
31 * @param string $url url to modify
32 * @return string modified url
33 */
34 public function remove_paged_from_link($url) {
35 return preg_replace('#\/page\/[0-9]+\/#', '/', $url); // FIXME trailing slash ?
36 }
37
38 /*
39 * returns the link to the paged page when using pretty permalinks
40 *
41 * @since 1.5
42 *
43 * @param string $url url to modify
44 * @param int $page
45 * @return string modified url
46 */
47 public function add_paged_to_link($url, $page) {
48 return trailingslashit($url) . 'page/' . $page; // FIXME trailing slash ?
49 }
50
51
52 /*
53 * changes the language code in url
54 *
55 * @since 1.5
56 *
57 * @param string $url url to modify
58 * @param object $lang language
59 * @return string modified url
60 */
61 public function switch_language_in_link($url, $lang) {
62 $url = $this->remove_language_from_link($url);
63 return $this->add_language_to_link($url, $lang);
64 }
65
66 /*
67 * get hosts managed on the website
68 *
69 * @since 1.5
70 *
71 * @return array list of hosts
72 */
73 public function get_hosts() {
74 return array(parse_url($this->home, PHP_URL_HOST));
75 }
76 }
77