suggestCats = $suggestCats; $this->suggestTags = $suggestTags; $this->suggestMax = $suggestMax; $this->suggestMinscore = $suggestMinscore; $this->suggestMinscoreEnabled = $suggestMinscoreEnabled; $this->suggestTitle = $suggestTitle; $this->suggestBefore = $suggestBefore; $this->suggestAfter = $suggestAfter; $this->suggestEntryBefore = $suggestEntryBefore; $this->suggestEntryAfter = $suggestEntryAfter; $this->suggestNoResults = $suggestNoResults; } /** * Normalize the raw `get_option('abj404_settings')` array (or any * compatible payload) into a typed VO. A non-array input falls back * to the documented defaults, matching the behaviour of * `PluginLogic::getOptions()` when the option row is missing. * * @param mixed $raw */ public static function fromOptionsArray($raw): self { $options = is_array($raw) ? $raw : array(); return new self( self::coerceBoolString($options, 'suggest_cats', '1'), self::coerceBoolString($options, 'suggest_tags', '1'), self::coercePositiveInt($options, 'suggest_max', 5), self::coerceNonNegativeInt($options, 'suggest_minscore', 25), self::coerceBoolString($options, 'suggest_minscore_enabled', '0'), self::coerceString($options, 'suggest_title', '
{suggest_noresults_text}
') ); } /** * Legacy '0'/'1' string. Consumers that echo into form HTML or pass * to SpellChecker (which expects the legacy shape) want this. */ public function getSuggestCatsString(): string { return $this->suggestCats; } public function getSuggestTagsString(): string { return $this->suggestTags; } public function shouldSuggestCategories(): bool { return $this->suggestCats === '1'; } public function shouldSuggestTags(): bool { return $this->suggestTags === '1'; } public function getSuggestMax(): int { return $this->suggestMax; } public function getSuggestMinscore(): int { return $this->suggestMinscore; } public function isMinscoreEnabled(): bool { return $this->suggestMinscoreEnabled === '1'; } public function getSuggestTitleHtml(): string { return $this->suggestTitle; } public function getSuggestBeforeHtml(): string { return $this->suggestBefore; } public function getSuggestAfterHtml(): string { return $this->suggestAfter; } public function getSuggestEntryBeforeHtml(): string { return $this->suggestEntryBefore; } public function getSuggestEntryAfterHtml(): string { return $this->suggestEntryAfter; } public function getSuggestNoResultsHtml(): string { return $this->suggestNoResults; } /** * @param array