As the sun rises and the forest mist clears, and the clouds return and the caves darken, these changes of light and shadow are the morning and evening in the mountains. Wildflowers bloom with their subtle fragrance, fine trees flourish with their dense shade, the wind and frost are pure and clean, and the water recedes to reveal the rocks—these are the four seasons in the mountains. Going out in the morning and returning in the evening, the scenery of the four seasons is different, and the joy is endless.至于负者歌于途,行者休于树,前者呼,后者应,伛偻提携,往来而不绝者,滁人游也。临溪而渔,溪深而鱼肥,酿泉为酒,泉香而酒洌,山肴野蔌,杂然而前陈者,太守宴也。宴酣之乐,非丝非竹,射者中,弈者胜,觥筹交错,起坐而喧哗者,众宾欢也。苍颜白发,颓然乎其间者,太守醉也。
<?php
/**
* @package Polylang
*/
namespace WP_Syntex\Polylang\Options;
use WP_Error;
use WP_Syntex\Polylang\Options\Options;
defined( 'ABSPATH' ) || exit;
/**
* Class defining a decorator for options when Polylang is not active on the current site.
*
* @since 3.8
*/
class Inactive_Option extends Abstract_Option {
public const ERROR_CODE = 'pll_not_active';
/**
* The option to decorate.
*
* @var Abstract_Option
*/
private $option;
/**
* The key of the option to decorate.
*
* @var string
*
* @phpstan-var non-falsy-string
*/
private static $key = 'not-an-option';
/**
* Constructor.
*
* @since 3.8
*
* @param Abstract_Option $option The option to wrap.
*/
public function __construct( Abstract_Option $option ) {
$this->option = $option;
$this->errors = new WP_Error();
// Make sure the option doesn't contain any value.
$this->option->reset();
}
/**
* Returns option key.
*
* @since 3.8
*
* @return string
*
* @phpstan-return non-falsy-string
*/
public static function key(): string {
return self::$key;
}
/**
* Does nothing except adding an error.
*
* @since 3.8
*
* @param mixed $value Value to set.
* @param Options $options All options.
* @return bool True if the value has been assigned. False in case of errors.
*/
public function set( $value, Options $options ): bool { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
if ( ! in_array( self::ERROR_CODE, $this->errors->get_error_codes(), true ) ) {
$this->errors->add(
self::ERROR_CODE,
/* translators: %s is a blog ID. */
sprintf( __( 'Polylang is not active on site %s.', 'polylang' ), (int) get_current_blog_id() )
);
}
return false;
}
/**
* Returns the value of the option, usually the default value for inactive options.
*
* @since 3.8
*
* @return mixed
*/
public function get() {
return $this->option->get();
}
/**
* Returns an empty schema.
*
* @since 3.8
*
* @return array The schema.
*/
public function get_schema(): array {
return array();
}
/**
* Returns the default value.
*
* @since 3.8
*
* @return mixed
*/
protected function get_default() {
return $this->option->get();
}
/**
* Not used but required by `Abstract_Option`.
*
* @since 3.8
*
* @return array Partial schema.
*/
protected function get_data_structure(): array {
return array();
}
/**
* Not used but required by `Abstract_Option`.
*
* @since 3.8
*
* @return string
*/
protected function get_description(): string {
return '';
}
}