API / Minn\Runtime / OptionSanitizer

OptionSanitizer final class

Minn\Runtime\OptionSanitizer · public/minn/src/Minn/Runtime/OptionSanitizer.php · 114 lines

A core option's value cleaned as the reference's sanitize_option cleans it (probe sanitize-option), before sanitize_option_{$option}: counts as whole numbers, the site's name and tagline escaped, formats and mail settings stripped of markup, addresses checked and kept as they were (with a settings error) when they are not addresses, word lists split and trimmed, the timezone and language checked against what exists. Any other option is left to its filter, where register_setting puts a plugin's sanitize_callback.

Constants and properties

privateCOUNTS = array ( 0 => 'thumbnail_size_w', 1 => 'thumbnail_size_h', 2 => 'medium_size_w', 3 => 'medium_size_h', 4 => 'medium_large_size_w', 5 => 'medium_large_size_h', 6 => 'large_size_w', 7 => 'large_size_h', 8 => 'mailserver_port', 9 => 'comment_max_links', 10 => 'page_on_front', 11 => 'page_for_posts', 12 => 'rss_excerpt_length', 13 => 'default_category', 14 => 'default_email_category', 15 => 'default_link_category', 16 => 'close_comments_days_old', 17 => 'comments_per_page', 18 => 'thread_comments_depth', 19 => 'users_can_register', 20 => 'start_of_week', 21 => 'site_icon', 22 => 'fileupload_maxk', )
privateSTRIPPED = array ( 0 => 'date_format', 1 => 'time_format', 2 => 'mailserver_url', 3 => 'mailserver_login', 4 => 'mailserver_pass', 5 => 'upload_path', )
privateEMAIL = 'The email address entered did not appear to be a valid email address. Please enter a valid email address.'
privateERRORS = array ( 'siteurl' => 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.', 'home' => 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.', 'timezone_string' => 'The timezone you have entered is not valid. Please select a valid timezone.', 'permalink_structure' => 'A structure tag is required when using custom permalinks. <a href="https://wordpress.org/documentation/article/customize-permalinks/#choosing-your-permalink-structure">Learn more</a>', )

Public

staticclean(string $option, mixed $value): mixed#

The value as sanitize_option leaves it, through sanitize_option_{$option}.

Internals 8

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privaterule(string $option, mixed $value): array#

The option's own rule: the cleaned value, and the error that refuses it (null when it stands).

@return array{0: mixed, 1: string|null}
privatelists(string $option, mixed $value): array#
@return array{0: mixed, 1: string|null}
privateemail(string $value): array#
@return array{0: string, 1: string|null}
privateperPage(mixed $value): int#

A page size: a whole number, 1 when none, a negative one (but -1, all) made positive.

privatestructure(string $option, string $value): array#
@return array{0: string, 1: string|null}
privatewords(array $words): array|string#
$wordsarray<int|string, mixed>@return list<string>|string
privatedomains(array $domains): array|string#
$domainsarray<int|string, mixed>@return list<string>|string
privatelanguages(): array#

The languages the site may be set to: those installed, and the one wp-config names. @return list<string>

@return list<string>