| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/wordpress-seo/inc/sitemaps/ |
Upload File : |
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\XML_Sitemaps
*/
/**
* Sitemap Cache Data object, manages sitemap data stored in cache.
*/
class WPSEO_Sitemap_Cache_Data implements WPSEO_Sitemap_Cache_Data_Interface, Serializable {
/**
* Sitemap XML data.
*
* @var string
*/
private $sitemap = '';
/**
* Status of the sitemap, usable or not.
*
* @var string
*/
private $status = self::UNKNOWN;
/**
* Set the sitemap XML data
*
* @param string $sitemap XML Content of the sitemap.
*/
public function set_sitemap( $sitemap ) {
if ( ! is_string( $sitemap ) ) {
$sitemap = '';
}
$this->sitemap = $sitemap;
/*
* Empty sitemap is not usable.
*/
if ( ! empty( $sitemap ) ) {
$this->set_status( self::OK );
}
else {
$this->set_status( self::ERROR );
}
}
/**
* Set the status of the sitemap, is it usable.
*
* @param bool|string $valid Is the sitemap valid or not.
*
* @return void
*/
public function set_status( $valid ) {
if ( self::OK === $valid ) {
$this->status = self::OK;
return;
}
if ( self::ERROR === $valid ) {
$this->status = self::ERROR;
$this->sitemap = '';
return;
}
$this->status = self::UNKNOWN;
}
/**
* Is the sitemap usable.
*
* @return bool True if usable, False if bad or unknown.
*/
public function is_usable() {
return self::OK === $this->status;
}
/**
* Get the XML content of the sitemap.
*
* @return string The content of the sitemap.
*/
public function get_sitemap() {
return $this->sitemap;
}
/**
* Get the status of the sitemap.
*
* @return string Status of the sitemap, 'ok'/'error'/'unknown'.
*/
public function get_status() {
return $this->status;
}
/**
* String representation of object.
*
* @link http://php.net/manual/en/serializable.serialize.php
*
* @since 5.1.0
*
* @return string The string representation of the object or null.
*/
public function serialize() {
$data = array(
'status' => $this->status,
'xml' => $this->sitemap,
);
return serialize( $data );
}
/**
* Constructs the object.
*
* @link http://php.net/manual/en/serializable.unserialize.php
*
* @since 5.1.0
*
* @param string $serialized The string representation of the object.
*
* @return void
*/
public function unserialize( $serialized ) {
$data = unserialize( $serialized );
$this->set_sitemap( $data['xml'] );
$this->set_status( $data['status'] );
}
}