Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu.../sitemaps
File: class-wp-sitemaps-index.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Sitemaps: WP_Sitemaps_Index class.
[2] Fix | Delete
*
[3] Fix | Delete
* Generates the sitemap index.
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Sitemaps
[7] Fix | Delete
* @since 5.5.0
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Class WP_Sitemaps_Index.
[12] Fix | Delete
* Builds the sitemap index page that lists the links to all of the sitemaps.
[13] Fix | Delete
*
[14] Fix | Delete
* @since 5.5.0
[15] Fix | Delete
*/
[16] Fix | Delete
#[AllowDynamicProperties]
[17] Fix | Delete
class WP_Sitemaps_Index {
[18] Fix | Delete
/**
[19] Fix | Delete
* The main registry of supported sitemaps.
[20] Fix | Delete
*
[21] Fix | Delete
* @since 5.5.0
[22] Fix | Delete
* @var WP_Sitemaps_Registry
[23] Fix | Delete
*/
[24] Fix | Delete
protected $registry;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Maximum number of sitemaps to include in an index.
[28] Fix | Delete
*
[29] Fix | Delete
* @since 5.5.0
[30] Fix | Delete
*
[31] Fix | Delete
* @var int Maximum number of sitemaps.
[32] Fix | Delete
*/
[33] Fix | Delete
private $max_sitemaps = 50000;
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* WP_Sitemaps_Index constructor.
[37] Fix | Delete
*
[38] Fix | Delete
* @since 5.5.0
[39] Fix | Delete
*
[40] Fix | Delete
* @param WP_Sitemaps_Registry $registry Sitemap provider registry.
[41] Fix | Delete
*/
[42] Fix | Delete
public function __construct( WP_Sitemaps_Registry $registry ) {
[43] Fix | Delete
$this->registry = $registry;
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Gets a sitemap list for the index.
[48] Fix | Delete
*
[49] Fix | Delete
* @since 5.5.0
[50] Fix | Delete
*
[51] Fix | Delete
* @return array[] Array of all sitemaps.
[52] Fix | Delete
*/
[53] Fix | Delete
public function get_sitemap_list() {
[54] Fix | Delete
$sitemaps = array();
[55] Fix | Delete
[56] Fix | Delete
$providers = $this->registry->get_providers();
[57] Fix | Delete
/* @var WP_Sitemaps_Provider $provider */
[58] Fix | Delete
foreach ( $providers as $name => $provider ) {
[59] Fix | Delete
$sitemap_entries = $provider->get_sitemap_entries();
[60] Fix | Delete
[61] Fix | Delete
// Prevent issues with array_push and empty arrays on PHP < 7.3.
[62] Fix | Delete
if ( ! $sitemap_entries ) {
[63] Fix | Delete
continue;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
// Using array_push is more efficient than array_merge in a loop.
[67] Fix | Delete
array_push( $sitemaps, ...$sitemap_entries );
[68] Fix | Delete
if ( count( $sitemaps ) >= $this->max_sitemaps ) {
[69] Fix | Delete
break;
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
return array_slice( $sitemaps, 0, $this->max_sitemaps, true );
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Builds the URL for the sitemap index.
[78] Fix | Delete
*
[79] Fix | Delete
* @since 5.5.0
[80] Fix | Delete
*
[81] Fix | Delete
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
[82] Fix | Delete
*
[83] Fix | Delete
* @return string The sitemap index URL.
[84] Fix | Delete
*/
[85] Fix | Delete
public function get_index_url() {
[86] Fix | Delete
global $wp_rewrite;
[87] Fix | Delete
[88] Fix | Delete
if ( ! $wp_rewrite->using_permalinks() ) {
[89] Fix | Delete
return home_url( '/?sitemap=index' );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
return home_url( '/wp-sitemap.xml' );
[93] Fix | Delete
}
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function