PluginProbe
Polylang / 3.2.8
Polylang v3.2.8
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 / modules / sitemaps / sitemaps-domain.php

sitemaps-domain.php in Polylang 3.2.8, at modules/sitemaps/sitemaps-domain.php

72 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 * @package Polylang
4 */
5
6 /**
7 * Handles the core sitemaps for subdomains and multiple domains.
8 *
9 * @since 3.0
10 */
11 class PLL_Sitemaps_Domain extends PLL_Abstract_Sitemaps {
12 /**
13 * @var PLL_Links_Abstract_Domain
14 */
15 protected $links_model;
16
17 /**
18 * Constructor.
19 *
20 * @since 3.0
21 *
22 * @param object $polylang Main Polylang object.
23 */
24 public function __construct( &$polylang ) {
25 $this->links_model = &$polylang->links_model;
26 }
27
28 /**
29 * Setups actions and filters.
30 *
31 * @since 3.0
32 *
33 * @return void
34 */
35 public function init() {
36 parent::init();
37
38 add_filter( 'wp_sitemaps_index_entry', array( $this, 'index_entry' ) );
39 add_filter( 'wp_sitemaps_stylesheet_url', array( $this->links_model, 'site_url' ) );
40 add_filter( 'wp_sitemaps_stylesheet_index_url', array( $this->links_model, 'site_url' ) );
41 add_filter( 'home_url', array( $this, 'sitemap_url' ) );
42 }
43
44 /**
45 * Filters the sitemap index entries for subdomains and multiple domains.
46 *
47 * @since 2.8
48 *
49 * @param array $sitemap_entry Sitemap entry for the post.
50 * @return array
51 */
52 public function index_entry( $sitemap_entry ) {
53 $sitemap_entry['loc'] = $this->links_model->site_url( $sitemap_entry['loc'] );
54 return $sitemap_entry;
55 }
56
57 /**
58 * Makes sure that the sitemap urls are always evaluated on the current domain.
59 *
60 * @since 2.8.4
61 *
62 * @param string $url A sitemap url.
63 * @return string
64 */
65 public function sitemap_url( $url ) {
66 if ( false !== strpos( $url, '/wp-sitemap' ) ) {
67 $url = $this->links_model->site_url( $url );
68 }
69 return $url;
70 }
71 }
72