Source
* @return string|false|null If the URL has already been processed but could not be resolved, it will return `false`
<?php
class WPML_Absolute_Url_Persisted {
const OPTION_KEY = 'wpml_resolved_url_persist';
private static $instance;
/**
* @var array
*/
private $urls;
/**
* @return WPML_Absolute_Url_Persisted
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
protected function __construct() {}
private function __clone() {}
/**
* @throws Exception
*/
public function __wakeup() {
throw new Exception( 'Cannot unserialize singleton' );
}
/**
* Returns urls array.
*
* @return array Array with urls.
*/
private function get_urls() {
if ( null === $this->urls ) {
$this->urls = get_option( self::OPTION_KEY, array() );
if ( ! is_array( $this->urls ) ) {
$this->urls = array();
}
}
return $this->urls;
}
/** @return bool */
public function has_urls() {
return (bool) $this->get_urls();
}
/**
* @param string $original_url
* @param string $lang
* @param string|false $converted_url A `false` value means that the URL could not be resolved
*/
public function set( $original_url, $lang, $converted_url ) {