PluginProbe
Polylang / 2.5.2
Polylang v2.5.2
3.8.10 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 All 234 releases
← All changes | include/links-abstract-domain.php +7 -15 3.0 → 2.5.2 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Links model for use when using one domain or subdomain per language
8 5 *
@@ -10,20 +7,19 @@
10 7 */
11 8 abstract class PLL_Links_Abstract_Domain extends PLL_Links_Permalinks {
12 9
13 10 /**
14 - * Constructor.
11 + * Constructor
15 12 *
16 13 * @since 2.0
17 14 *
18 - * @param PLL_Model $model Instance of PLL_Model.
15 + * @param object $model PLL_Model instance
19 16 */
20 17 public function __construct( &$model ) {
21 18 parent::__construct( $model );
22 19
23 - // Avoid cross domain requests ( mainly for custom fonts ).
20 + // Avoid cross domain requests ( mainly for custom fonts )
24 21 add_filter( 'content_url', array( $this, 'site_url' ) );
25 - add_filter( 'theme_root_uri', array( $this, 'site_url' ) ); // The above filter is not sufficient with WPMU Domain Mapping.
26 22 add_filter( 'plugins_url', array( $this, 'site_url' ) );
27 23 add_filter( 'rest_url', array( $this, 'site_url' ) );
28 24 add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
29 25 }
@@ -38,26 +34,22 @@
38 34 * @param string $url optional, defaults to current url
39 35 * @return string language slug
40 36 */
41 37 public function get_language_from_url( $url = '' ) {
42 - if ( empty( $url ) ) {
43 - $url = pll_get_requested_url();
44 - }
45 -
46 - $host = wp_parse_url( $url, PHP_URL_HOST );
38 + $host = empty( $url ) ? $_SERVER['HTTP_HOST'] : parse_url( $url, PHP_URL_HOST );
47 39 return ( $lang = array_search( $host, $this->get_hosts() ) ) ? $lang : '';
48 40 }
49 41
50 42 /**
51 - * Sets the home urls.
43 + * Sets the home urls
52 44 *
53 45 * @since 2.2
54 46 *
55 - * @param PLL_Language $language Language object.
47 + * @param object $language
56 48 */
57 49 protected function set_home_url( $language ) {
58 50 $home_url = $this->home_url( $language );
59 - $language->set_home_url( $home_url, $home_url ); // Search url and home url are the same.
51 + $language->set_home_url( $home_url, $home_url ); // Search url and home url are the same
60 52 }
61 53
62 54 /**
63 55 * Returns the current site url