| Server IP : 62.60.133.156 / Your IP : 216.73.217.51 Web Server : LiteSpeed System : Linux linux24.centraldnserver.com 4.18.0-553.141.2.lve.el8.x86_64 #1 SMP Wed Jul 8 16:10:02 UTC 2026 x86_64 User : mimradmin ( 1166) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, exec, popen, proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/mimradmin/.trash/wp-content/plugins/wp-rocket/inc/Engine/Preload/Frontend/ |
Upload File : |
<?php
namespace WP_Rocket\Engine\Preload\Frontend;
use WP_Rocket\Engine\Preload\Controller\CheckExcludedTrait;
use WP_Rocket\Engine\Preload\Controller\Queue;
use WP_Rocket\Engine\Preload\Database\Queries\Cache;
class FetchSitemap {
use CheckExcludedTrait;
/**
* Parse controller.
*
* @var SitemapParser
*/
protected $sitemap_parser;
/**
* Queue instance.
*
* @var Queue
*/
protected $queue;
/**
* DB query.
*
* @var Cache
*/
protected $query;
/**
* Instantiate the class.
*
* @param SitemapParser $sitemap_parser Parse controller.
* @param Queue $queue Queue instance.
* @param Cache $rocket_cache DB query.
*/
public function __construct( SitemapParser $sitemap_parser, Queue $queue, Cache $rocket_cache ) {
$this->sitemap_parser = $sitemap_parser;
$this->queue = $queue;
$this->query = $rocket_cache;
}
/**
* Parse a sitemap.
*
* @param string $url url from the sitemap.
*/
public function parse_sitemap( string $url ) {
$response = wp_safe_remote_get( $url );
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
return;
}
$data = wp_remote_retrieve_body( $response );
if ( ! $data ) {
return;
}
$this->sitemap_parser->set_content( $data );
$links = $this->sitemap_parser->get_links();
foreach ( $links as $link ) {
if ( ! $this->is_excluded_by_filter( $link ) ) {
$this->query->create_or_nothing(
[
'url' => $link,
]
);
}
}
$children = $this->sitemap_parser->get_children();
foreach ( $children as $child ) {
$this->queue->add_job_preload_job_parse_sitemap_async( $child );
}
}
}