get($field['type'])->displayValue($value, $field, $args); /** * Change the HTML of a value on the website (shortcode, and the content of a bound block). The HTML is * printed as it is: escape what you add. * * @since 1.0.0 * * @param string $html The value as the field type shows it. * @param mixed $value The value of the option. * @param array $field The stored field: type, field_name and its settings. * @param array $args Options of the shortcode. */ return (string) apply_filters(Plugin::PREFIX_ . 'display_value', $html, $value, $field, $args); } /** * The value for one attribute of a bound block, or null when there is none (the block keeps its own). * * @param string $name The option name of the field. * @param string $attribute The block attribute (content, text, url, alt, title, id, ...). */ public static function binding(string $name, string $attribute): ?string { $field = self::field($name); if ($field === null) { return null; } // Attributes that hold HTML (rich text): WordPress puts the value in the block as HTML, after wp_kses_post(). if (in_array($attribute, self::HTML_ATTRIBUTES, true)) { return self::html($name); } return FieldRegistry::instance()->get($field['type'])->bindingValue(self::value($field), $field, $attribute); } private static function field(string $name): ?array { // Pro takes over: it shows the values itself. if (Plugin::isDisabled()) { return null; } return PublicFields::get($name); } /** * Always through get_option(), so the filters of WordPress (pre_option_, option_) apply. A missing * option shows the default value of the field, as the options page does. * * @return mixed */ private static function value(array $field) { $value = get_option($field['field_name']); return $value === false ? ($field['default_value'] ?? '') : $value; } }