- 29 个 PHP 文件添加 declare(strict_types=1) - CHANGELOG 补全 2.5.0、3.0.0、3.1.0、3.2.0、3.2.1 版本记录 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
93 lines
1.8 KiB
PHP
93 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Process Options
|
|
*
|
|
* Configuration options for MarkdownProcessor.
|
|
*
|
|
* @package WPMind\Modules\Geo
|
|
* @since 3.1.0
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace WPMind\Modules\Geo;
|
|
|
|
/**
|
|
* Class ProcessOptions
|
|
*
|
|
* Configurable options for Markdown processing pipeline.
|
|
*/
|
|
class ProcessOptions {
|
|
|
|
/**
|
|
* Whether to add metadata section.
|
|
*
|
|
* @var bool
|
|
*/
|
|
public bool $add_metadata = true;
|
|
|
|
/**
|
|
* Whether to allow content rewriting/optimization.
|
|
*
|
|
* @var bool
|
|
*/
|
|
public bool $allow_rewrite = true;
|
|
|
|
/**
|
|
* Whether to skip language-specific optimization (Chinese).
|
|
*
|
|
* @var bool
|
|
*/
|
|
public bool $skip_language_opt = false;
|
|
|
|
/**
|
|
* Whether to skip GEO signal injection.
|
|
*
|
|
* @var bool
|
|
*/
|
|
public bool $skip_geo_signals = false;
|
|
|
|
/**
|
|
* Create options from array.
|
|
*
|
|
* @param array $options Options array.
|
|
* @return self
|
|
*/
|
|
public static function from_array( array $options ): self {
|
|
$instance = new self();
|
|
|
|
if ( isset( $options['add_metadata'] ) ) {
|
|
$instance->add_metadata = (bool) $options['add_metadata'];
|
|
}
|
|
|
|
if ( isset( $options['allow_rewrite'] ) ) {
|
|
$instance->allow_rewrite = (bool) $options['allow_rewrite'];
|
|
}
|
|
|
|
if ( isset( $options['skip_language_opt'] ) ) {
|
|
$instance->skip_language_opt = (bool) $options['skip_language_opt'];
|
|
}
|
|
|
|
if ( isset( $options['skip_geo_signals'] ) ) {
|
|
$instance->skip_geo_signals = (bool) $options['skip_geo_signals'];
|
|
}
|
|
|
|
return $instance;
|
|
}
|
|
|
|
/**
|
|
* Create options from WordPress settings.
|
|
*
|
|
* @return self
|
|
*/
|
|
public static function from_settings(): self {
|
|
$instance = new self();
|
|
|
|
$instance->add_metadata = true;
|
|
$instance->allow_rewrite = true;
|
|
$instance->skip_language_opt = ! get_option( 'wpmind_chinese_optimize', true );
|
|
$instance->skip_geo_signals = ! get_option( 'wpmind_geo_signals', true );
|
|
|
|
return $instance;
|
|
}
|
|
}
|